kinesis-consumer/handler.go
Harlow Ward f0e6461cb6 Refactor to use handler func
The previous pipeline model required a lot of setup and abstracted away
the processing of records. By passing a HandlerFunc to the consumer we
keep the business logic of processing of records closer to the use of
the consumer.

* Add refactoring note and SHA to README
2016-02-06 17:50:17 -08:00

18 lines
435 B
Go

package connector
type Handler interface {
HandleRecords(b Buffer)
}
// HandlerFunc is a convenience type to avoid having to declare a struct
// to implement the Handler interface, it can be used like this:
//
// consumer.AddHandler(connector.HandlerFunc(func(b Buffer) {
// // ...
// }))
type HandlerFunc func(b Buffer)
// HandleRecords implements the Handler interface
func (h HandlerFunc) HandleRecords(b Buffer) {
h(b)
}