Dissemination client library for Redis or similar protocols. This library can be considered a wrapper around go-redis.
Includes implementation of a health checker, that reuses the redis client to check requests can be made against the redis server.
import disRedis "github.com/ONSdigital/dis-redis"
...
redisClient, redisClientErr := disRedis.NewClient(ctx, &disRedis.ClientConfig{
Address: cfg.redisURL
}
if redisClientErr != nil {
log.Fatal(ctx, "Failed to create dis-redis client", redisClientErr)
}
...Using dis-redis checker function currently performs a PING request against redis.
The healthcheck will only succeed if the request can be performend and the server responds with a PONG.
Instantiate a dis-redis client
import disRedis "github.com/ONSdigital/dis-redis"
...
cli := disRedis.NewClient(ctx, clientConfig)
...Call healthchecker with cli.Checker(context.Background()) and this will return a check object like so:
{
"name": "string",
"status": "string",
"message": "string",
"status_code": "int",
"last_checked": "ISO8601 - UTC date time",
"last_success": "ISO8601 - UTC date time",
"last_failure": "ISO8601 - UTC date time"
}Tests and static checks are run via:
make audit
make test
make lint
make build- Run
make helpto see full list of make targets
- No further dependencies other than those defined in
go.mod
See CONTRIBUTING for details.
Copyright © 2025, Office for National Statistics https://www.ons.gov.uk
Released under MIT license, see LICENSE for details.