Skip to content

Commit

Permalink
Merge pull request #25 from DocMerlin/master
Browse files Browse the repository at this point in the history
return an error when concurrency is set to less than 1
  • Loading branch information
twang-rs authored Nov 12, 2016
2 parents 3b35b32 + fa7ad99 commit 3c4f36f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions firehose.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func (p *Producer) firehoseFlush(counter *int, timer *time.Time) bool {

// Initialize a producer for Kinesis Firehose with the params supplied in the configuration file
func (p *Producer) Firehose() (*Producer, error) {
if conf.Concurrency.Producer < 1 {
return nil, BadConcurrencyError
}
p.setConcurrency(conf.Concurrency.Producer)
p.initChannels()
auth, err := authenticate(conf.AWS.AccessKey, conf.AWS.SecretKey)
Expand All @@ -78,6 +81,9 @@ func (p *Producer) Firehose() (*Producer, error) {

// Initialize a producer for Kinesis Firehose with the specified params
func (p *Producer) FirehoseC(stream, accessKey, secretKey, region string, concurrency int) (*Producer, error) {
if concurrency < 1 {
return nil, BadConcurrencyError
}
if stream == "" {
return nil, NullStreamError
}
Expand Down
4 changes: 3 additions & 1 deletion listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ type Listener struct {

func (l *Listener) init(stream, shard, shardIterType, accessKey, secretKey, region string, concurrency int) (*Listener, error) {
var err error

if concurrency < 1 {
return nil, BadConcurrencyError
}
if stream == "" {
return nil, NullStreamError
}
Expand Down
5 changes: 4 additions & 1 deletion producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const (
var (
ThroughputExceededError = errors.New("Configured AWS Kinesis throughput has been exceeded!")
KinesisFailureError = errors.New("AWS Kinesis internal failure.")
BadConcurrencyError = errors.New("Concurrency must be greater than zero.")
)

// Producer keeps a queue of messages on a channel and continually attempts
Expand Down Expand Up @@ -54,7 +55,9 @@ type Producer struct {

func (p *Producer) init(stream, shard, shardIterType, accessKey, secretKey, region string, concurrency int) (*Producer, error) {
var err error

if concurrency < 1 {
return nil, BadConcurrencyError
}
if stream == "" {
return nil, NullStreamError
}
Expand Down

0 comments on commit 3c4f36f

Please sign in to comment.