本文整理汇总了Golang中github.com/awslabs/aws-sdk-go/service/kinesis.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ExampleKinesis_DeleteStream
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))
}
示例2: ExampleKinesis_PutRecords
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))
}
示例3: TestMigrateStreams
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()
}
示例4: NewStreamProducer
// 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
}
示例5: NewStreamConsumer
// 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
}
示例6: init
func init() {
Before("@kinesis", func() {
World["client"] = kinesis.New(nil)
})
}
示例7: TestInterface
func TestInterface(t *testing.T) {
assert.Implements(t, (*kinesisiface.KinesisAPI)(nil), kinesis.New(nil))
}