Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

Commit

Permalink
Make worker count configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelavila committed Jun 12, 2019
1 parent 8e30fff commit 915c96c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions simple/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ import (

var logP = logging.Logger("provider.simple")

const (
provideOutgoingWorkerLimit = 8
)

// Provider announces blocks to the network
type Provider struct {
ctx context.Context
Expand All @@ -28,6 +24,8 @@ type Provider struct {
contentRouting routing.ContentRouting
// how long to wait for announce to complete before giving up
timeout time.Duration
// how many workers concurrently work through thhe queue
workerLimit int
}

type Option func(*Provider)
Expand All @@ -38,12 +36,19 @@ func WithTimeout(timeout time.Duration) Option {
}
}

func MaxWorkers(count int) Option {
return func(p *Provider) {
p.workerLimit = count
}
}

// NewProvider creates a provider that announces blocks to the network using a content router
func NewProvider(ctx context.Context, queue *q.Queue, contentRouting routing.ContentRouting, options ...Option) *Provider {
p := &Provider{
ctx: ctx,
queue: queue,
contentRouting: contentRouting,
workerLimit: 8,
}

for _, option := range options {
Expand Down

0 comments on commit 915c96c

Please sign in to comment.