1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-07 06:56:47 +00:00

singleton of worker is not used, so remove it

这个提交包含在:
zyx
2019-04-11 10:06:21 +08:00
父节点 96f11f57ed
当前提交 7eb119b892
共有 2 个文件被更改,包括 3 次插入9 次删除

查看文件

@@ -60,7 +60,7 @@ func startWorker(c *cli.Context) error {
os.Exit(1) os.Exit(1)
} }
w := worker.GetTUNASyncWorker(cfg) w := worker.NewTUNASyncWorker(cfg)
if w == nil { if w == nil {
logger.Errorf("Error intializing TUNA sync worker.") logger.Errorf("Error intializing TUNA sync worker.")
os.Exit(1) os.Exit(1)

查看文件

@@ -12,8 +12,6 @@ import (
. "github.com/tuna/tunasync/internal" . "github.com/tuna/tunasync/internal"
) )
var tunasyncWorker *Worker
// A Worker is a instance of tunasync worker // A Worker is a instance of tunasync worker
type Worker struct { type Worker struct {
L sync.Mutex L sync.Mutex
@@ -29,11 +27,8 @@ type Worker struct {
httpClient *http.Client httpClient *http.Client
} }
// GetTUNASyncWorker returns a singalton worker // NewTUNASyncWorker creates a worker
func GetTUNASyncWorker(cfg *Config) *Worker { func NewTUNASyncWorker(cfg *Config) *Worker {
if tunasyncWorker != nil {
return tunasyncWorker
}
w := &Worker{ w := &Worker{
cfg: cfg, cfg: cfg,
@@ -57,7 +52,6 @@ func GetTUNASyncWorker(cfg *Config) *Worker {
w.initJobs() w.initJobs()
w.makeHTTPServer() w.makeHTTPServer()
tunasyncWorker = w
return w return w
} }