Skip to content

Commit

Permalink
Merge pull request #600 from urso/enh/use-const-for-magic-value
Browse files Browse the repository at this point in the history
Replace magic value with magic const
  • Loading branch information
ruflin committed Dec 30, 2015
2 parents 6971d15 + 739da6f commit 604615e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions libbeat/publisher/async.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func newAsyncPublisher(pub *PublisherType) *asyncPublisher {
}

p.outputs = outputs
p.messageWorker.init(&pub.wsPublisher, 1000, newPreprocessor(pub, p))
p.messageWorker.init(&pub.wsPublisher, defaultChanSize, newPreprocessor(pub, p))
return p
}

Expand Down Expand Up @@ -89,5 +89,5 @@ func asyncOutputer(ws *workerSignal, worker *outputWorker) worker {

debug("create bulk processing worker (interval=%v, bulk size=%v)",
flushInterval, maxBulkSize)
return newBulkWorker(ws, 1000, worker, flushInterval, maxBulkSize)
return newBulkWorker(ws, defaultChanSize, worker, flushInterval, maxBulkSize)
}
2 changes: 1 addition & 1 deletion libbeat/publisher/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func newTestPublisher(bulkSize int, response OutputResponse) *testPublisher {
ow.config.BulkMaxSize = &bulkSize
ow.handler = mh
ws := workerSignal{}
ow.messageWorker.init(&ws, 1000, mh)
ow.messageWorker.init(&ws, defaultChanSize, mh)

pub := &PublisherType{
Output: []*outputWorker{ow},
Expand Down
6 changes: 5 additions & 1 deletion libbeat/publisher/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ type Topology struct {
Ip string `json:"ip"`
}

const (
defaultChanSize = 1000
)

func init() {
publishDisabled = flag.Bool("N", false, "Disable actual publishing for testing")
}
Expand Down Expand Up @@ -211,7 +215,7 @@ func (publisher *PublisherType) init(
debug("Create output worker")

outputers = append(outputers,
newOutputWorker(config, output, &publisher.wsOutput, 1000))
newOutputWorker(config, output, &publisher.wsOutput, defaultChanSize))

if !config.Save_topology {
continue
Expand Down
2 changes: 1 addition & 1 deletion libbeat/publisher/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type syncClient func(message) bool

func newSyncPublisher(pub *PublisherType) *syncPublisher {
s := &syncPublisher{pub: pub}
s.messageWorker.init(&pub.wsPublisher, 1000, newPreprocessor(pub, s))
s.messageWorker.init(&pub.wsPublisher, defaultChanSize, newPreprocessor(pub, s))
return s
}

Expand Down

0 comments on commit 604615e

Please sign in to comment.