Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Commit

Permalink
refactor(BUX-411): defaultOptions moved right into NewTaskManager
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-4chain committed Dec 15, 2023
1 parent 432149f commit 0a04ed1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 19 deletions.
15 changes: 0 additions & 15 deletions taskmanager/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,6 @@ import (
// that overwrite default client options.
type ClientOps func(c *options)

// defaultClientOptions will return an clientOptions struct with the default settings
//
// Useful for starting with the default and then modifying as needed
func defaultClientOptions() *options {
// Set the default options
return &options{
debug: false,
newRelicEnabled: false,
taskq: &taskqOptions{
tasks: make(map[string]*taskq.Task),
config: DefaultTaskQConfig("taskq"),
},
}
}

// WithNewRelic will enable the NewRelic wrapper
func WithNewRelic() ClientOps {
return func(c *options) {
Expand Down
12 changes: 9 additions & 3 deletions taskmanager/taskmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,18 @@ type (
)

// NewTaskManager creates a new client for all TaskManager functionality
//
// If no options are given, it will use the defaultClientOptions()
// If no options are given, it will use local memory for the queue.
// ctx may contain a NewRelic txn (or one will be created)
func NewTaskManager(ctx context.Context, opts ...ClientOps) (Tasker, error) {
// Create a new tm with defaults
tm := &TaskManager{options: defaultClientOptions()}
tm := &TaskManager{options: &options{
debug: false,
newRelicEnabled: false,
taskq: &taskqOptions{
tasks: make(map[string]*taskq.Task),
config: DefaultTaskQConfig("taskq"),
},
}}

// Overwrite defaults with any set by user
for _, opt := range opts {
Expand Down
1 change: 0 additions & 1 deletion taskmanager/taskmanager_test.go

This file was deleted.

0 comments on commit 0a04ed1

Please sign in to comment.