kinesis-consumer/emitter/s3/manifest_emitter.go

40 lines
871 B
Go
Raw Normal View History

2016-02-09 03:39:09 +00:00
package s3
import (
"io"
2015-05-26 04:51:53 +00:00
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/kinesis"
)
// An implementation of Emitter that puts event data on S3 file, and then puts the
// S3 file path onto the output stream for processing by manifest application.
2016-02-09 03:39:09 +00:00
type ManifestEmitter struct {
OutputStream string
Bucket string
Prefix string
}
2016-02-09 03:39:09 +00:00
func (e ManifestEmitter) Emit(s3Key string, b io.ReadSeeker) error {
// put contents to S3 Bucket
2016-02-09 03:39:09 +00:00
s3 := &Emitter{Bucket: e.Bucket}
s3.Emit(s3Key, b)
// put file path on Kinesis output stream
params := &kinesis.PutRecordInput{
Data: []byte(s3Key),
PartitionKey: aws.String(s3Key),
StreamName: aws.String(e.OutputStream),
}
svc := kinesis.New(session.New())
_, err := svc.PutRecord(params)
if err != nil {
2016-02-09 03:39:09 +00:00
return err
}
2016-02-09 03:39:09 +00:00
return nil
}