mirror of
https://github.com/tiennm99/keepalive.git
synced 2026-10-11 03:13:31 +00:00
docs(config): clarify scoped intervals
This commit is contained in:
1 parent
7ac1fc3a7c
commit
30660b95f5
3 files changed
+20
-2
No files matched your search
@@ -11,6 +11,7 @@ Successor to the `*-keepalive` family: one binary, one image, six datastore adap
|
||||
By default, keepalive reads the first config file it finds: `config.yml`, `config.yaml`, `/config.yml`, then `/config.yaml`. One deployment can keep any number of services alive.
|
||||
|
||||
```yaml
|
||||
# Default interval for every service.
|
||||
interval: 1m
|
||||
counter_key: counter
|
||||
|
||||
@@ -21,6 +22,8 @@ services:
|
||||
namespace: keepalive
|
||||
|
||||
- adapter: valkey
|
||||
# One service can override the global interval.
|
||||
interval: 30s
|
||||
config:
|
||||
url: valkey://default@valkey-a.example.com:6379
|
||||
|
||||
@@ -50,7 +53,11 @@ services:
|
||||
|
||||
`name` is optional. When omitted, keepalive generates a name from `adapter` and the connection host, such as `redis-redis-a-example-com`. Duplicate generated names get suffixes like `redis-redis-a-example-com-2`.
|
||||
|
||||
`interval` and `counter_key` can be set globally or per service. Per-service values override global values.
|
||||
`interval` at the root sets the default schedule for every service and defaults to `1m`.
|
||||
`interval` inside a service overrides that default only for that service.
|
||||
In the example above, every service runs every `1m` except `valkey`, which runs every `30s`.
|
||||
|
||||
`counter_key` can be set globally or per service. Per-service values override global values.
|
||||
|
||||
## Supported adapters
|
||||
|
||||
|
||||
+3
-1
@@ -1,4 +1,4 @@
|
||||
# Optional defaults shared by every service.
|
||||
# Optional default interval shared by every service.
|
||||
interval: 1m
|
||||
counter_key: counter
|
||||
|
||||
@@ -9,6 +9,8 @@ services:
|
||||
namespace: keepalive
|
||||
|
||||
- adapter: valkey
|
||||
# Example: this service runs every 30s while others use the root interval.
|
||||
interval: 30s
|
||||
config:
|
||||
url: valkey://default@valkey-a.example.com:6379
|
||||
|
||||
|
||||
@@ -42,6 +42,15 @@ func TestConfigExampleYMLParses(t *testing.T) {
|
||||
t.Fatalf("services[%d].AdapterType = %q, want %q", i, services[i].AdapterType, want)
|
||||
}
|
||||
}
|
||||
if services[0].Interval != time.Minute {
|
||||
t.Fatalf("services[0].Interval = %s, want 1m", services[0].Interval)
|
||||
}
|
||||
if services[1].Interval != 30*time.Second {
|
||||
t.Fatalf("services[1].Interval = %s, want 30s", services[1].Interval)
|
||||
}
|
||||
if services[2].Interval != time.Minute {
|
||||
t.Fatalf("services[2].Interval = %s, want 1m", services[2].Interval)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFirstExistingConfigFileFindsYMLFallback(t *testing.T) {
|
||||
|
||||
Reference in new issue
Block a user