mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
reverse_proxy: Add grace_period for SRV upstreams to Caddyfile (#6264)
This commit is contained in:
parent
d2668cdbb0
commit
868af6a062
2 changed files with 48 additions and 1 deletions
|
@ -0,0 +1,38 @@
|
||||||
|
:8884 {
|
||||||
|
reverse_proxy {
|
||||||
|
dynamic srv {
|
||||||
|
name foo
|
||||||
|
refresh 5m
|
||||||
|
grace_period 5s
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
----------
|
||||||
|
{
|
||||||
|
"apps": {
|
||||||
|
"http": {
|
||||||
|
"servers": {
|
||||||
|
"srv0": {
|
||||||
|
"listen": [
|
||||||
|
":8884"
|
||||||
|
],
|
||||||
|
"routes": [
|
||||||
|
{
|
||||||
|
"handle": [
|
||||||
|
{
|
||||||
|
"dynamic_upstreams": {
|
||||||
|
"grace_period": 5000000000,
|
||||||
|
"name": "foo",
|
||||||
|
"refresh": 300000000000,
|
||||||
|
"source": "srv"
|
||||||
|
},
|
||||||
|
"handler": "reverse_proxy"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1356,6 +1356,7 @@ func (h *CopyResponseHeadersHandler) UnmarshalCaddyfile(d *caddyfile.Dispenser)
|
||||||
// resolvers <resolvers...>
|
// resolvers <resolvers...>
|
||||||
// dial_timeout <timeout>
|
// dial_timeout <timeout>
|
||||||
// dial_fallback_delay <timeout>
|
// dial_fallback_delay <timeout>
|
||||||
|
// grace_period <duration>
|
||||||
// }
|
// }
|
||||||
func (u *SRVUpstreams) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
func (u *SRVUpstreams) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||||
d.Next() // consume upstream source name
|
d.Next() // consume upstream source name
|
||||||
|
@ -1435,7 +1436,15 @@ func (u *SRVUpstreams) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
|
||||||
return d.Errf("bad delay value '%s': %v", d.Val(), err)
|
return d.Errf("bad delay value '%s': %v", d.Val(), err)
|
||||||
}
|
}
|
||||||
u.FallbackDelay = caddy.Duration(dur)
|
u.FallbackDelay = caddy.Duration(dur)
|
||||||
|
case "grace_period":
|
||||||
|
if !d.NextArg() {
|
||||||
|
return d.ArgErr()
|
||||||
|
}
|
||||||
|
dur, err := caddy.ParseDuration(d.Val())
|
||||||
|
if err != nil {
|
||||||
|
return d.Errf("bad grace period value '%s': %v", d.Val(), err)
|
||||||
|
}
|
||||||
|
u.GracePeriod = caddy.Duration(dur)
|
||||||
default:
|
default:
|
||||||
return d.Errf("unrecognized srv option '%s'", d.Val())
|
return d.Errf("unrecognized srv option '%s'", d.Val())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue