Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fabianlindfors/clockbound-go
Go client for AWS Clockbound
https://github.com/fabianlindfors/clockbound-go
Last synced: about 1 month ago
JSON representation
Go client for AWS Clockbound
- Host: GitHub
- URL: https://github.com/fabianlindfors/clockbound-go
- Owner: fabianlindfors
- License: mit
- Created: 2022-01-19T12:09:20.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-02-16T09:37:57.000Z (almost 3 years ago)
- Last Synced: 2024-10-15T23:56:30.748Z (3 months ago)
- Language: Go
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# clockbound-go
Native Go client for [AWS Clockbound](https://github.com/aws/clock-bound). Requires a running [ClockboundD daemon](https://github.com/aws/clock-bound/blob/main/clock-bound-d/README.md).
## Usage
```go
// Connects to the default /run/clockboundd/clockboundd.sock socket.
// Use clockbound.NewWithPath("/path/to/socket") to use a custom socket path.
clock, err := clockbound.New()
if err != nil {
panic(err)
}// Now() returns a bounded timestamp with type `Bounds`
bounds, err := clock.Now()
if err != nil {
panic(err)
}// `Bounds` has two fields, Earliest and Latest. They are two timestamps
// setting bounds on the actual current time.
// The timestamps are counted as nanoseconds since the UNIX epoch.
fmt.Printf("Earliest timestamp: %d\n", bounds.Earliest)
fmt.Printf("Latest timestamp: %d\n", bounds.Latest)// Before and After are convenience methods for checking if a timestamp is
// before or after the current time
// The parameter should be a timestamp of nanoseconds since the UNIX epoch.
before, err := clock.Before(0)
if err != nil {
panic(err)
}
// If before == true, then the timestamp is before the current timeafter, err := clock.After(0)
if err != nil {
panic(err)
}
// If after == true, then the timestamp is after the current time
```## License
clockbound-go is released under the [MIT license](LICENSE.md).