2014-07-25 06:03:41 +00:00
# Golang Kinesis Connectors
2014-07-25 06:03:41 +00:00
2015-05-23 23:18:10 +00:00
__Kinesis connector applications written in Go__
2014-07-25 06:03:41 +00:00
2016-02-09 03:41:36 +00:00
> With the new release of Kinesis Firehose I'd recommend using the [Lambda Streams to Firehose](https://github.com/awslabs/lambda-streams-to-firehose) project for loading data directly into S3 and Redshift.
2016-02-03 05:04:22 +00:00
2016-02-09 03:41:36 +00:00
Inspired by the [Amazon Kinesis Connector Library ](https://github.com/awslabs/amazon-kinesis-connectors ). This library is intended to be a lightweight wrapper around the Kinesis API to handle batching records, setting checkpoints, respecting ratelimits, and recovering from network errors.
2015-05-23 15:52:08 +00:00
2015-05-23 23:18:10 +00:00

2014-07-25 06:03:41 +00:00
## Overview
2014-07-25 06:03:41 +00:00
2016-02-03 05:04:22 +00:00
The consumer expects a handler func that will process a buffer of incoming records.
2016-02-09 03:42:26 +00:00
```go
2016-02-03 05:04:22 +00:00
func main() {
var(
app = flag.String("app", "", "The app name")
stream = flag.String("stream", "", "The stream name")
)
flag.Parse()
2014-07-25 06:03:41 +00:00
2016-02-10 06:31:15 +00:00
// create new consumer
2016-02-03 05:04:22 +00:00
c := connector.NewConsumer(*app, *stream)
2016-02-10 06:31:15 +00:00
// override default values
c.Set("maxBatchCount", 200)
// start consuming records from the queues
2016-02-03 05:04:22 +00:00
c.Start(connector.HandlerFunc(func(b connector.Buffer) {
fmt.Println(b.GetRecords())
// process the records
}))
2014-07-25 06:03:41 +00:00
2016-02-03 05:04:22 +00:00
select {}
}
```
2014-07-25 06:03:41 +00:00
2015-05-23 20:57:52 +00:00
### Installation
Get the package source:
2014-07-25 06:03:41 +00:00
$ go get github.com/harlow/kinesis-connectors
2016-02-10 07:39:57 +00:00
### Fetching Dependencies
Install `gvt` :
$ export GO15VENDOREXPERIMENT=1
$ go get github.com/FiloSottile/gvt
Install dependencies into `./vendor/` :
$ gvt restore
2016-02-09 03:39:09 +00:00
### Examples
2015-05-23 23:10:08 +00:00
2016-02-09 03:39:09 +00:00
Use the [seed stream ](https://github.com/harlow/kinesis-connectors/tree/master/examples/seed ) code to put sample data onto the stream.
2015-05-23 23:10:08 +00:00
2016-02-09 03:39:09 +00:00
* [Firehose ](https://github.com/harlow/kinesis-connectors/tree/master/examples/firehose )
2016-02-03 05:04:22 +00:00
* [S3 ](https://github.com/harlow/kinesis-connectors/tree/master/examples/s3 )
2015-05-23 23:10:08 +00:00
2015-05-26 06:09:59 +00:00
### Logging
2015-05-26 06:18:14 +00:00
Default logging is handled by [go-kit package log ](https://github.com/go-kit/kit/tree/master/log ). Applications can override the default loging behaviour by implementing the [Logger interface][log_interface].
2014-07-25 06:03:41 +00:00
2015-05-23 18:40:04 +00:00
```go
2016-05-01 05:23:35 +00:00
import(
"os"
"github.com/apex/log"
"github.com/apex/log/handlers/json"
)
2015-05-23 18:40:04 +00:00
2016-05-01 05:23:35 +00:00
func main() {
c := connector.NewConsumer("signupAgg", "signups")
c.SetLogHandler(json.New(os.Stderr))
// ...
}
```
2015-05-23 18:40:04 +00:00
2015-05-23 23:18:10 +00:00
## Contributing
2015-05-23 15:52:08 +00:00
2015-05-23 22:22:58 +00:00
Please see [CONTRIBUTING.md] for more information. Thank you, [contributors]!
2015-05-23 15:52:08 +00:00
[LICENSE]: /MIT-LICENSE
[CONTRIBUTING.md]: /CONTRIBUTING.md
2015-05-23 23:18:10 +00:00
## License
2015-05-23 15:52:08 +00:00
Copyright (c) 2015 Harlow Ward. It is free software, and may
be redistributed under the terms specified in the [LICENSE] file.
[contributors]: https://github.com/harlow/kinesis-connectors/graphs/contributors