Skip to content

Commit

Permalink
Update worker config name
Browse files Browse the repository at this point in the history
  • Loading branch information
tengattack committed Jan 10, 2019
1 parent f46ba7a commit 4895252
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions cmd/gogstash.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func gogstash(
return err
}

// use worker mode when user need more than one workers
if conf.Workers > 1 && !workerMode {
return startWorkers(ctx, conf.Workers)
// use worker mode when user need more than one worker
if conf.Worker > 1 && !workerMode {
return startWorkers(ctx, conf.Worker)
}

if err = conf.Start(ctx); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/worker_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func waitWorkers(ctx context.Context, pids []int, args []string, attr *syscall.P
}
}

func startWorkers(ctx context.Context, workers int) error {
func startWorkers(ctx context.Context, workerNum int) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()

Expand All @@ -59,8 +59,8 @@ func startWorkers(ctx context.Context, workers int) error {
}
args := append([]string{os.Args[0], WorkerModule.Use}, os.Args[1:]...)

pids := make([]int, workers)
for i := 0; i < workers; i++ {
pids := make([]int, workerNum)
for i := 0; i < workerNum; i++ {
pid, err := startWorker(args, attr)
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions cmd/worker_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func waitWorkers(ctx context.Context, pids []int, handles []uintptr, args []stri
}
}

func startWorkers(ctx context.Context, workers int) error {
func startWorkers(ctx context.Context, workerNum int) error {
ctx, cancel := context.WithCancel(ctx)
defer cancel()

Expand All @@ -63,9 +63,9 @@ func startWorkers(ctx context.Context, workers int) error {
}
args := append([]string{os.Args[0], WorkerModule.Use}, os.Args[1:]...)

pids := make([]int, workers)
handles := make([]uintptr, workers)
for i := 0; i < workers; i++ {
pids := make([]int, workerNum)
handles := make([]uintptr, workerNum)
for i := 0; i < workerNum; i++ {
pid, handle, err := startWorker(args, attr)
if err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/tsaikd/gogstash/config/goglog"
"github.com/tsaikd/gogstash/config/logevent"
"golang.org/x/sync/errgroup"
"gopkg.in/yaml.v2"
yaml "gopkg.in/yaml.v2"
)

// errors
Expand All @@ -34,8 +34,8 @@ type Config struct {
// channel size: chInFilter, chFilterOut, chOutDebug
ChannelSize int `json:"chsize,omitempty" yaml:"chsize"`

// workers number, defaults to 1
Workers int `json:"workers,omitempty" yaml:"workers"`
// worker number, defaults to 1
Worker int `json:"worker,omitempty" yaml:"worker"`

// enable debug channel, used for testing
DebugChannel bool `json:"debugch,omitempty" yaml:"debugch"`
Expand All @@ -49,7 +49,7 @@ type Config struct {

var defaultConfig = Config{
ChannelSize: 100,
Workers: 1,
Worker: 1,
}

// MsgChan message channel type
Expand Down Expand Up @@ -101,8 +101,8 @@ func initConfig(config *Config) {
if config.ChannelSize < 1 {
config.ChannelSize = defaultConfig.ChannelSize
}
if config.Workers < 1 {
config.Workers = defaultConfig.Workers
if config.Worker < 1 {
config.Worker = defaultConfig.Worker
}

config.chInFilter = make(MsgChan, config.ChannelSize)
Expand Down

0 comments on commit 4895252

Please sign in to comment.