canonical / canonical/microcluster
Allow storing application specific data in `state.State`
- Dominant language
- Go
- Stars
- 33
- Forks
- 39
- Avg merge
- 4h 49m
- Merged PRs (30d)
- 6
Description
Clients of microcluster will need to store data in memory. It would be useful for this to be integrated with microcluster so that it is possible to access data via the `state.State`.
As an example, the `oidc.Verifier` for LXD is stored as a field on the `Daemon`. This needs to persist in memory, otherwise cookie encryption keys will rotate on every request and OIDC authentication will fail. LXD site manager needs to use a similar pattern, but can only do so using a package level variable (either in isolation or via a field in another package level variable). Package level variables are generally not ideal for unit testing or readability.
I think it would be nice if `state.State` provided an API for getting/setting data that is application specific. A simple way to do this would be a `map[string]any` defined on `Daemon` with a mutex and getter/setter functions provided via the state parameter (e.g. `(state.State).GetAppConfig[T](string) (T, error)`, `(state.State).SetAppConfig(string, T)`).
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.