From 0a04ed1a7704de0163c75030a1bf62a84638bdad Mon Sep 17 00:00:00 2001 From: Krzysztof Tomecki <152964795+chris-4chain@users.noreply.github.com> Date: Fri, 15 Dec 2023 16:10:01 +0100 Subject: [PATCH] refactor(BUX-411): defaultOptions moved right into NewTaskManager --- taskmanager/options.go | 15 --------------- taskmanager/taskmanager.go | 12 +++++++++--- taskmanager/taskmanager_test.go | 1 - 3 files changed, 9 insertions(+), 19 deletions(-) delete mode 100644 taskmanager/taskmanager_test.go diff --git a/taskmanager/options.go b/taskmanager/options.go index 5a8aff63..d6c1cdf9 100644 --- a/taskmanager/options.go +++ b/taskmanager/options.go @@ -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) { diff --git a/taskmanager/taskmanager.go b/taskmanager/taskmanager.go index 3eed8340..52d0602a 100644 --- a/taskmanager/taskmanager.go +++ b/taskmanager/taskmanager.go @@ -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 { diff --git a/taskmanager/taskmanager_test.go b/taskmanager/taskmanager_test.go deleted file mode 100644 index 1bbb8907..00000000 --- a/taskmanager/taskmanager_test.go +++ /dev/null @@ -1 +0,0 @@ -package taskmanager