https://github.com/adrianosela/refresh
Go library to keep short-lived credentials fresh with various flexible strategies.
https://github.com/adrianosela/refresh
Last synced: 3 months ago
JSON representation
Go library to keep short-lived credentials fresh with various flexible strategies.
- Host: GitHub
- URL: https://github.com/adrianosela/refresh
- Owner: adrianosela
- License: mit
- Created: 2024-06-16T22:29:52.000Z (12 months ago)
- Default Branch: main
- Last Pushed: 2024-06-24T13:38:31.000Z (12 months ago)
- Last Synced: 2024-06-24T15:17:41.488Z (12 months ago)
- Language: Go
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Refresh
Go library to keep short-lived credentials fresh with flexible strategies.
[](https://goreportcard.com/report/github.com/adrianosela/refresh)
[](https://godoc.org/github.com/adrianosela/refresh)
[](https://github.com/adrianosela/refresh/issues)
[](https://github.com/adrianosela/refresh/blob/master/LICENSE)The idea is that you **only need to implement the logic for getting a new value**, and don't need to worry about the logic for keeping the value fresh (which typically involves reasoning about concurrency and strategizing on when to refresh the value).
### Usage:
```
// initialize a new Refresher with your own refresh function
refresher := refresh.NewRefresher(refreshStuffFunc)
defer refresher.Stop()// block until there's a valid value available (or timeout)
err := refresher.WaitForInitialValue(timeout)
if err != nil {
log.Fatalf("failed while waiting for initial value: %v", err)
}// concurrency-safe getter
value := refresher.GetCurrent()
```