https://github.com/onsdigital/dis-redis
Dissemination client library for Redis or similar protocols.
https://github.com/onsdigital/dis-redis
Last synced: 5 months ago
JSON representation
Dissemination client library for Redis or similar protocols.
- Host: GitHub
- URL: https://github.com/onsdigital/dis-redis
- Owner: ONSdigital
- License: mit
- Created: 2025-05-06T12:20:13.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-28T06:23:53.000Z (12 months ago)
- Last Synced: 2025-06-28T07:28:56.636Z (12 months ago)
- Language: Go
- Size: 154 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# dis-redis
Dissemination client library for Redis or similar protocols. This library can be considered a wrapper around go-redis.
## redis package
Includes implementation of a health checker, that reuses the redis client to check requests can be made against the redis server.
### Setup dis-redis client
```golang
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)
}
...
```
### Health checker
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
```golang
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:
```json
{
"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"
}
```
## Getting started
Tests and static checks are run via:
```sh
make audit
make test
make lint
make build
```
* Run `make help` to see full list of make targets
### Dependencies
#### Tools
We use `dis-vulncheck` to do Go auditing, which you will [need to install](https://github.com/ONSdigital/dis-vulncheck).
## Contributing
See [CONTRIBUTING](CONTRIBUTING.md) for details.
## License
Copyright © 2025, Office for National Statistics
Released under MIT license, see [LICENSE](LICENSE.md) for details.