Skip to content

Commit

Permalink
singleton of worker is not used, so remove it
Browse files Browse the repository at this point in the history
  • Loading branch information
z4yx committed Apr 11, 2019
1 parent 96f11f5 commit 7eb119b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cmd/tunasync/tunasync.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func startWorker(c *cli.Context) error {
os.Exit(1)
}

w := worker.GetTUNASyncWorker(cfg)
w := worker.NewTUNASyncWorker(cfg)
if w == nil {
logger.Errorf("Error intializing TUNA sync worker.")
os.Exit(1)
Expand Down
10 changes: 2 additions & 8 deletions worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
. "github.com/tuna/tunasync/internal"
)

var tunasyncWorker *Worker

// A Worker is a instance of tunasync worker
type Worker struct {
L sync.Mutex
Expand All @@ -29,11 +27,8 @@ type Worker struct {
httpClient *http.Client
}

// GetTUNASyncWorker returns a singalton worker
func GetTUNASyncWorker(cfg *Config) *Worker {
if tunasyncWorker != nil {
return tunasyncWorker
}
// NewTUNASyncWorker creates a worker
func NewTUNASyncWorker(cfg *Config) *Worker {

w := &Worker{
cfg: cfg,
Expand All @@ -57,7 +52,6 @@ func GetTUNASyncWorker(cfg *Config) *Worker {

w.initJobs()
w.makeHTTPServer()
tunasyncWorker = w
return w
}

Expand Down

0 comments on commit 7eb119b

Please sign in to comment.