@@ -12,8 +12,8 @@ import (
12
12
)
13
13
14
14
const (
15
- ACTION_KEY = "Action"
16
- REGION_ENV_NAME = "AWS_REGION_NAME"
15
+ ActionKey = "Action"
16
+ RegionEnvName = "AWS_REGION_NAME"
17
17
18
18
// Regions
19
19
USEast1 = "us-east-1"
@@ -29,11 +29,11 @@ const (
29
29
30
30
// NewRegionFromEnv creates a region from the an expected environment variable
31
31
func NewRegionFromEnv () string {
32
- return os .Getenv (REGION_ENV_NAME )
32
+ return os .Getenv (RegionEnvName )
33
33
}
34
34
35
35
// Structure for kinesis client
36
- type kinesis struct {
36
+ type Kinesis struct {
37
37
client * Client
38
38
endpoint string
39
39
region string
@@ -56,31 +56,31 @@ type KinesisClient interface {
56
56
57
57
// New returns an initialized AWS Kinesis client using the canonical live “production” endpoint
58
58
// for AWS Kinesis, i.e. https://kinesis.{region}.amazonaws.com
59
- func New (auth Auth , region string ) KinesisClient {
59
+ func New (auth Auth , region string ) * Kinesis {
60
60
endpoint := fmt .Sprintf (kinesisURL , region )
61
61
return NewWithEndpoint (auth , region , endpoint )
62
62
}
63
63
64
64
// NewWithClient returns an initialized AWS Kinesis client using the canonical live “production” endpoint
65
65
// for AWS Kinesis, i.e. https://kinesis.{region}.amazonaws.com but with the ability to create a custom client
66
66
// with specific configurations like a timeout
67
- func NewWithClient (auth Auth , region string , client * Client ) KinesisClient {
67
+ func NewWithClient (region string , client * Client ) * Kinesis {
68
68
endpoint := fmt .Sprintf (kinesisURL , region )
69
- return & kinesis {client : client , version : "20131202" , region : region , endpoint : endpoint }
69
+ return & Kinesis {client : client , version : "20131202" , region : region , endpoint : endpoint }
70
70
}
71
71
72
72
// NewWithEndpoint returns an initialized AWS Kinesis client using the specified endpoint.
73
73
// This is generally useful for testing, so a local Kinesis server can be used.
74
- func NewWithEndpoint (auth Auth , region string , endpoint string ) KinesisClient {
74
+ func NewWithEndpoint (auth Auth , region string , endpoint string ) * Kinesis {
75
75
// TODO: remove trailing slash on endpoint if there is one? does it matter?
76
76
// TODO: validate endpoint somehow?
77
- return & kinesis {client : NewClient (auth ), version : "20131202" , region : region , endpoint : endpoint }
77
+ return & Kinesis {client : NewClient (auth ), version : "20131202" , region : region , endpoint : endpoint }
78
78
}
79
79
80
80
// Create params object for request
81
81
func makeParams (action string ) map [string ]string {
82
82
params := make (map [string ]string )
83
- params [ACTION_KEY ] = action
83
+ params [ActionKey ] = action
84
84
return params
85
85
}
86
86
@@ -152,7 +152,7 @@ func buildError(r *http.Response) error {
152
152
}
153
153
154
154
// Query by AWS API
155
- func (kinesis * kinesis ) query (params map [string ]string , data interface {}, resp interface {}) error {
155
+ func (kinesis * Kinesis ) query (params map [string ]string , data interface {}, resp interface {}) error {
156
156
jsonData , err := json .Marshal (data )
157
157
if err != nil {
158
158
return err
@@ -171,7 +171,7 @@ func (kinesis *kinesis) query(params map[string]string, data interface{}, resp i
171
171
172
172
// headers
173
173
request .Header .Set ("Content-Type" , "application/x-amz-json-1.1" )
174
- request .Header .Set ("X-Amz-Target" , fmt .Sprintf ("Kinesis_%s.%s" , kinesis .version , params [ACTION_KEY ]))
174
+ request .Header .Set ("X-Amz-Target" , fmt .Sprintf ("Kinesis_%s.%s" , kinesis .version , params [ActionKey ]))
175
175
request .Header .Set ("User-Agent" , "Golang Kinesis" )
176
176
177
177
// response
@@ -195,7 +195,7 @@ func (kinesis *kinesis) query(params map[string]string, data interface{}, resp i
195
195
// CreateStream adds a new Amazon Kinesis stream to your AWS account
196
196
// StreamName is a name of stream, ShardCount is number of shards
197
197
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_CreateStream.html
198
- func (kinesis * kinesis ) CreateStream (StreamName string , ShardCount int ) error {
198
+ func (kinesis * Kinesis ) CreateStream (StreamName string , ShardCount int ) error {
199
199
params := makeParams ("CreateStream" )
200
200
requestParams := struct {
201
201
StreamName string
@@ -214,7 +214,7 @@ func (kinesis *kinesis) CreateStream(StreamName string, ShardCount int) error {
214
214
// DeleteStream deletes a stream and all of its shards and data from your AWS account
215
215
// StreamName is a name of stream
216
216
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_DeleteStream.html
217
- func (kinesis * kinesis ) DeleteStream (StreamName string ) error {
217
+ func (kinesis * Kinesis ) DeleteStream (StreamName string ) error {
218
218
params := makeParams ("DeleteStream" )
219
219
requestParams := struct {
220
220
StreamName string
@@ -230,7 +230,7 @@ func (kinesis *kinesis) DeleteStream(StreamName string) error {
230
230
231
231
// MergeShards merges two adjacent shards in a stream and combines them into a single shard to reduce the stream's capacity to ingest and transport data
232
232
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_MergeShards.html
233
- func (kinesis * kinesis ) MergeShards (args * RequestArgs ) error {
233
+ func (kinesis * Kinesis ) MergeShards (args * RequestArgs ) error {
234
234
params := makeParams ("MergeShards" )
235
235
err := kinesis .query (params , args .params , nil )
236
236
if err != nil {
@@ -241,7 +241,7 @@ func (kinesis *kinesis) MergeShards(args *RequestArgs) error {
241
241
242
242
// SplitShard splits a shard into two new shards in the stream, to increase the stream's capacity to ingest and transport data
243
243
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_SplitShard.html
244
- func (kinesis * kinesis ) SplitShard (args * RequestArgs ) error {
244
+ func (kinesis * Kinesis ) SplitShard (args * RequestArgs ) error {
245
245
params := makeParams ("SplitShard" )
246
246
err := kinesis .query (params , args .params , nil )
247
247
if err != nil {
@@ -258,7 +258,7 @@ type ListStreamsResp struct {
258
258
259
259
// ListStreams returns an array of the names of all the streams that are associated with the AWS account making the ListStreams request
260
260
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_ListStreams.html
261
- func (kinesis * kinesis ) ListStreams (args * RequestArgs ) (resp * ListStreamsResp , err error ) {
261
+ func (kinesis * Kinesis ) ListStreams (args * RequestArgs ) (resp * ListStreamsResp , err error ) {
262
262
params := makeParams ("ListStreams" )
263
263
resp = & ListStreamsResp {}
264
264
err = kinesis .query (params , args .params , resp )
@@ -300,7 +300,7 @@ type DescribeStreamResp struct {
300
300
// the shard spans, and the IDs of any earlier shards that played in a role in a MergeShards or
301
301
// SplitShard operation that created the shard
302
302
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_DescribeStream.html
303
- func (kinesis * kinesis ) DescribeStream (args * RequestArgs ) (resp * DescribeStreamResp , err error ) {
303
+ func (kinesis * Kinesis ) DescribeStream (args * RequestArgs ) (resp * DescribeStreamResp , err error ) {
304
304
params := makeParams ("DescribeStream" )
305
305
resp = & DescribeStreamResp {}
306
306
err = kinesis .query (params , args .params , resp )
@@ -317,7 +317,7 @@ type GetShardIteratorResp struct {
317
317
318
318
// GetShardIterator returns a shard iterator
319
319
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetShardIterator.html
320
- func (kinesis * kinesis ) GetShardIterator (args * RequestArgs ) (resp * GetShardIteratorResp , err error ) {
320
+ func (kinesis * Kinesis ) GetShardIterator (args * RequestArgs ) (resp * GetShardIteratorResp , err error ) {
321
321
params := makeParams ("GetShardIterator" )
322
322
resp = & GetShardIteratorResp {}
323
323
err = kinesis .query (params , args .params , resp )
@@ -346,7 +346,7 @@ type GetRecordsResp struct {
346
346
347
347
// GetRecords returns one or more data records from a shard
348
348
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_GetRecords.html
349
- func (kinesis * kinesis ) GetRecords (args * RequestArgs ) (resp * GetRecordsResp , err error ) {
349
+ func (kinesis * Kinesis ) GetRecords (args * RequestArgs ) (resp * GetRecordsResp , err error ) {
350
350
params := makeParams ("GetRecords" )
351
351
resp = & GetRecordsResp {}
352
352
err = kinesis .query (params , args .params , resp )
@@ -365,7 +365,7 @@ type PutRecordResp struct {
365
365
// PutRecord puts a data record into an Amazon Kinesis stream from a producer.
366
366
// args must contain a single record added with AddRecord.
367
367
// More info: http://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecord.html
368
- func (kinesis * kinesis ) PutRecord (args * RequestArgs ) (resp * PutRecordResp , err error ) {
368
+ func (kinesis * Kinesis ) PutRecord (args * RequestArgs ) (resp * PutRecordResp , err error ) {
369
369
params := makeParams ("PutRecord" )
370
370
371
371
if _ , ok := args .params ["Data" ]; ! ok && len (args .Records ) == 0 {
@@ -391,7 +391,7 @@ func (kinesis *kinesis) PutRecord(args *RequestArgs) (resp *PutRecordResp, err e
391
391
392
392
// PutRecords puts multiple data records into an Amazon Kinesis stream from a producer
393
393
// more info http://docs.aws.amazon.com/kinesis/latest/APIReference/API_PutRecords.html
394
- func (kinesis * kinesis ) PutRecords (args * RequestArgs ) (resp * PutRecordsResp , err error ) {
394
+ func (kinesis * Kinesis ) PutRecords (args * RequestArgs ) (resp * PutRecordsResp , err error ) {
395
395
params := makeParams ("PutRecords" )
396
396
resp = & PutRecordsResp {}
397
397
args .Add ("Records" , args .Records )
0 commit comments