feat(layer,queue): implement matchURLs option
Cadoles/bouncer/pipeline/head This commit looks good
Details
Cadoles/bouncer/pipeline/head This commit looks good
Details
This commit is contained in:
parent
1ffec1f173
commit
ce2c19f9b3
|
@ -22,6 +22,14 @@ Ce layer permet d'ajouter un mécanisme de file d'attente dynamique au proxy ass
|
||||||
- **Valeur par défaut:** `1m`
|
- **Valeur par défaut:** `1m`
|
||||||
- **Description:** Durée de vie d'une session dans la file d'attente sans activité avant expiration.
|
- **Description:** Durée de vie d'une session dans la file d'attente sans activité avant expiration.
|
||||||
|
|
||||||
|
### `matchURLs`
|
||||||
|
|
||||||
|
- **Type:** `[]string`
|
||||||
|
- **Valeur par défaut:** `["*"]`
|
||||||
|
- **Description:** Limiter l'action de la file d'attente à cette liste de patrons d'URLs.
|
||||||
|
|
||||||
|
Par exemple, si vous souhaitez limiter votre file à l'ensemble d'une section "`/blog`" d'un site, vous pouvez déclarer la valeur `["*/blog*"]`. Les autres URLs du site ne seront pas affectées par cette file d'attente.
|
||||||
|
|
||||||
### Schéma
|
### Schéma
|
||||||
|
|
||||||
Voir le [schéma JSON](../../../../internal/proxy/director/layer/queue/schema/layer-options.json).
|
Voir le [schéma JSON](../../../../internal/proxy/director/layer/queue/schema/layer-options.json).
|
|
@ -11,15 +11,15 @@ import (
|
||||||
|
|
||||||
type LayerOptions struct {
|
type LayerOptions struct {
|
||||||
Capacity int64 `mapstructure:"capacity"`
|
Capacity int64 `mapstructure:"capacity"`
|
||||||
Matchers []string `mapstructure:"matchers"`
|
|
||||||
KeepAlive time.Duration `mapstructure:"keepAlive"`
|
KeepAlive time.Duration `mapstructure:"keepAlive"`
|
||||||
|
MatchURLs []string `mapstructure:"matchURLs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func fromStoreOptions(storeOptions store.LayerOptions, defaultKeepAlive time.Duration) (*LayerOptions, error) {
|
func fromStoreOptions(storeOptions store.LayerOptions, defaultKeepAlive time.Duration) (*LayerOptions, error) {
|
||||||
layerOptions := LayerOptions{
|
layerOptions := LayerOptions{
|
||||||
Capacity: 1000,
|
Capacity: 1000,
|
||||||
Matchers: []string{"*"},
|
|
||||||
KeepAlive: defaultKeepAlive,
|
KeepAlive: defaultKeepAlive,
|
||||||
|
MatchURLs: []string{"*"},
|
||||||
}
|
}
|
||||||
|
|
||||||
config := mapstructure.DecoderConfig{
|
config := mapstructure.DecoderConfig{
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package queue
|
package queue
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
TemplateDir string
|
TemplateDir string
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"forge.cadoles.com/Cadoles/go-proxy"
|
"forge.cadoles.com/Cadoles/go-proxy"
|
||||||
|
"forge.cadoles.com/Cadoles/go-proxy/wildcard"
|
||||||
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director"
|
"forge.cadoles.com/cadoles/bouncer/internal/proxy/director"
|
||||||
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
||||||
"github.com/Masterminds/sprig/v3"
|
"github.com/Masterminds/sprig/v3"
|
||||||
|
@ -57,6 +58,13 @@ func (q *Queue) Middleware(layer *store.Layer) proxy.Middleware {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matches := wildcard.MatchAny(r.URL.String(), options.MatchURLs...)
|
||||||
|
if !matches {
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
defer q.updateMetrics(ctx, layer.Proxy, layer.Name, options)
|
defer q.updateMetrics(ctx, layer.Proxy, layer.Name, options)
|
||||||
|
|
||||||
cookieName := q.getCookieName(layer.Name)
|
cookieName := q.getCookieName(layer.Name)
|
||||||
|
|
|
@ -9,6 +9,12 @@
|
||||||
},
|
},
|
||||||
"keepAlive": {
|
"keepAlive": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
},
|
||||||
|
"matchURLs": {
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
|
|
Loading…
Reference in New Issue