Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/inconshreveable/go-keen
Keen IO Client SDK in Go
https://github.com/inconshreveable/go-keen
Last synced: 13 days ago
JSON representation
Keen IO Client SDK in Go
- Host: GitHub
- URL: https://github.com/inconshreveable/go-keen
- Owner: inconshreveable
- License: mit
- Created: 2014-02-06T00:58:03.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2023-02-28T16:57:55.000Z (over 1 year ago)
- Last Synced: 2024-06-18T21:50:38.014Z (5 months ago)
- Language: Go
- Size: 10.7 KB
- Stars: 25
- Watchers: 3
- Forks: 15
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Keen IO golang client SDK [![godoc reference](http://godoc.org/gopkg.in/inconshreveable/go-keen.v0?status.png)](http://godoc.org/gopkg.in/inconshreveable/go-keen.v0)
### Community-Supported SDK
This is an _unofficial_ community supported SDK. If you find any issues or have a request please post an [issue](https://github.com/inconshreveable/go-keen/issues).## API Stability
The master branch has no API stability guarantees. You can import the latest stable API with:
```go
import "gopkg.in/inconshreveable/go-keen.v0"
````## Writing Events
This is the very beginnings of a Keen IO client SDK in Go. Currently, only adding events to collections is supported.
The simplest API is to create a client object and then call AddEvent:
```go
package mainimport (
"github.com/inconshreveable/go-keen"
)type ExampleEvent struct {
UserId int
Amount int
Type string
Tags []string
}func main() {
keenClient := &keen.Client{ ApiKey: "XXX", ProjectToken: "XXX" }
keenClient.AddEvent("collection_name", &ExampleEvent{
UserId: 102,
Amount: 39,
Type: "ball",
Tags: []string{ "red", "bouncy" },
})
}
```## Batch event reporting
For production use, it makes more sense to add events to an internal buffer which is
flushed to Keen at a regular interval in a single batch upload call. The go-keen library provides
a BatchClient which allows you to do just that while keeping the same, simple API for adding
events. Do note that it does mean that you could lose events if your program exits or crashes before it
flushes the events to Keen.
```go
package mainimport (
"github.com/inconshreveable/go-keen"
"time"
)const keenFlushInterval = 10 * time.Second
type ExampleEvent struct {
UserId int
Amount int
Type string
Tags []string
}func main() {
keenClient := &keen.Client{ ApiKey: "XXX", ProjectToken: "XXX" }
keenBatchClient := keen.NewBatchClient(keenClient, keenFlushInterval)
keenBatchClient.AddEvent("collection_name", &ExampleEvent{
UserId: 102,
Amount: 39,
Type: "ball",
Tags: []string{ "red", "bouncy" },
})
}
```## TODO
Add support for all other Keen IO API endpoints, especially querying data.## LICENSE
MIT