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 always 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 { // 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 always return an // error which satisfies the awserr.Error interface. fmt.Println(err.Error()) } } // Pretty-print the response data. fmt.Println(awsutil.StringValue(resp)) }
func (m *Monitor) streamLogs() { Kinesis := kinesis.New(&aws.Config{}) for _ = range time.Tick(100 * time.Millisecond) { for _, stream := range m.streams() { l := m.getLines(stream) if l == nil { continue } records := &kinesis.PutRecordsInput{ Records: make([]*kinesis.PutRecordsRequestEntry, len(l)), StreamName: aws.String(stream), } for i, line := range l { records.Records[i] = &kinesis.PutRecordsRequestEntry{ Data: line, PartitionKey: aws.String(string(time.Now().UnixNano())), } } res, err := Kinesis.PutRecords(records) if err != nil { fmt.Fprintf(os.Stderr, "error: %s\n", err) } for _, r := range res.Records { if r.ErrorCode != nil { fmt.Printf("error: %s\n", *r.ErrorCode) } } fmt.Printf("upload to=kinesis stream=%q lines=%d\n", stream, len(res.Records)) } } }
func TestInterface(t *testing.T) { assert.Implements(t, (*kinesisiface.KinesisAPI)(nil), kinesis.New(nil)) }