Skip to content

Commit

Permalink
Set the default Options when none is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
prep committed Jun 18, 2015
1 parent dfa5497 commit 3f07361
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ type Client struct {

// NewClient returns a new beanstalk Client object.
func NewClient(conn net.Conn, options *Options) *Client {
if options == nil {
options = DefaultOptions()
}

return &Client{
options: options,
conn: conn,
Expand Down
4 changes: 4 additions & 0 deletions consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type Consumer struct {

// NewConsumer returns a new Consumer object.
func NewConsumer(socket string, tubes []string, jobC chan<- *Job, options *Options) *Consumer {
if options == nil {
options = DefaultOptions()
}

consumer := &Consumer{
tubes: tubes,
jobC: jobC,
Expand Down
4 changes: 4 additions & 0 deletions producer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ type Producer struct {

// NewProducer returns a new Producer object.
func NewProducer(socket string, putC chan *Put, options *Options) *Producer {
if options == nil {
options = DefaultOptions()
}

producer := &Producer{
putC: putC,
stop: make(chan struct{}, 1),
Expand Down
3 changes: 1 addition & 2 deletions producer_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@ import "sync"
// incoming Put requests over the maintained Producers.
type ProducerPool struct {
producers []*Producer
options *Options
putC chan *Put
putTokens chan *Put
sync.Mutex
}

// NewProducerPool creates a pool of Producer objects.
func NewProducerPool(sockets []string, options *Options) *ProducerPool {
pool := &ProducerPool{putC: make(chan *Put), options: options}
pool := &ProducerPool{putC: make(chan *Put)}
pool.putTokens = make(chan *Put, len(sockets))

for _, socket := range sockets {
Expand Down
4 changes: 4 additions & 0 deletions put.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ type Put struct {
// NewPut returns a new Put object that operates on the specified producer
// channel.
func NewPut(putC chan<- *Put, options *Options) *Put {
if options == nil {
options = DefaultOptions()
}

timer := time.NewTimer(time.Second)
timer.Stop()

Expand Down

0 comments on commit 3f07361

Please sign in to comment.