func ExampleKinesis_DeleteStream() { svc := kinesis.New(nil) params := &kinesis.DeleteStreamInput{ StreamName: aws.String("StreamName"), // Required } resp, err := svc.DeleteStream(params) if err != nil { if awsErr, ok := err.(awserr.Error); ok { // Generic AWS Error with Code, Message, and original error (if any) fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr()) if reqErr, ok := err.(awserr.RequestFailure); ok { // A service error occurred fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID()) } } else { // This case should never be hit, The SDK should alwsy return an // error which satisfies the awserr.Error interface. fmt.Println(err.Error()) } } // Pretty-print the response data. fmt.Println(awsutil.StringValue(resp)) }
func ExampleKinesis_PutRecords() { svc := kinesis.New(nil) params := &kinesis.PutRecordsInput{ Records: []*kinesis.PutRecordsRequestEntry{ // Required &kinesis.PutRecordsRequestEntry{ // Required Data: []byte("PAYLOAD"), // Required PartitionKey: aws.String("PartitionKey"), // Required ExplicitHashKey: aws.String("HashKey"), }, // More values... }, StreamName: aws.String("StreamName"), // Required } resp, err := svc.PutRecords(params) if err != nil { if awsErr, ok := err.(awserr.Error); ok { // Generic AWS Error with Code, Message, and original error (if any) fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr()) if reqErr, ok := err.(awserr.RequestFailure); ok { // A service error occurred fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID()) } } else { // This case should never be hit, The SDK should alwsy return an // error which satisfies the awserr.Error interface. fmt.Println(err.Error()) } } // Pretty-print the response data. fmt.Println(awsutil.StringValue(resp)) }
func TestMigrateStreams(t *testing.T) { if os.Getenv("AWS_ACCESS_KEY_ID") == "" || os.Getenv("AWS_SECRET_ACCESS_KEY") == "" { log.Printf("WARNING: NO AWS CREDS SPECIFIED, SKIPPING MIGRATIONS TEST") return } config := &aws.Config{ Credentials: credentials.NewEnvCredentials(), Region: "us-east-1", } client := kinesis.New(config) sm := StreamMigrator{ Streams: []kinesis.CreateStreamInput{ kinesis.CreateStreamInput{ StreamName: aws.String(testDomain), ShardCount: aws.Long(1), }, }, Client: client, Timeout: 30, } sm.Migrate() sm.Migrate() }
// NewStreamProducer TODO func NewStreamProducer(opts *KinesisProducerConfig) (producer *KinesisStreamProducer) { producer = &KinesisStreamProducer{ client: kinesis.New(getAWSConfig(opts.AWSDebugMode)), successes: make(chan *KinesisMessage, opts.BufferSize), errors: make(chan *KinesisError, opts.BufferSize), input: make(chan *KinesisMessage, opts.BufferSize), killInput: make(chan bool, 1), config: opts, isManaged: false, } go producer.getMessages() return }
// NewStreamConsumer TODO func NewStreamConsumer(opts *Config) (consumer *StreamConsumer, err error) { if opts, err = validateConfig(opts); err != nil { return } dynamo := newDynamo(opts.ConsumerGroup, opts.ReadCapacity, opts.WriteCapacity) if err = dynamo.ValidateTable(); err != nil { return } consumer = &StreamConsumer{ client: kinesis.New(getAWSConfig(opts.AWSDebugMode)), config: opts, data: make(chan *KinesisRecord, opts.BufferSize), numRecordsPerIteration: aws.Long(opts.NumRecords), dynamo: dynamo, ownedShards: make([]string, 0), checkpoints: make(map[string]string), } return }
func init() { Before("@kinesis", func() { World["client"] = kinesis.New(nil) }) }
func TestInterface(t *testing.T) { assert.Implements(t, (*kinesisiface.KinesisAPI)(nil), kinesis.New(nil)) }