diff options
author | Valery Piashchynski <[email protected]> | 2021-10-27 22:50:03 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-10-27 22:50:03 +0300 |
commit | c8c3f9f113eae13aa37cf92043b288bb0c68a622 (patch) | |
tree | 42f8ab386735d5f8b002907d07249e94b4c10a12 /pool/supervisor_pool.go | |
parent | 1f62e21020cc3014e9eb2dc33c154de6dd5b22d5 (diff) | |
parent | ab591e7f122e28857cef00c905a8125992ea3cdf (diff) |
[#838]: feat(events): events package deep refactoringv2.6.0-alpha.1
[#838]: feat(events): events package deep refactoring
Diffstat (limited to 'pool/supervisor_pool.go')
-rwxr-xr-x | pool/supervisor_pool.go | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/pool/supervisor_pool.go b/pool/supervisor_pool.go index 99af168c..1a94f6a0 100755 --- a/pool/supervisor_pool.go +++ b/pool/supervisor_pool.go @@ -2,6 +2,7 @@ package pool import ( "context" + "fmt" "sync" "time" @@ -12,7 +13,10 @@ import ( "github.com/spiral/roadrunner/v2/worker" ) -const MB = 1024 * 1024 +const ( + MB = 1024 * 1024 + supervisorName string = "supervisor" +) // NSEC_IN_SEC nanoseconds in second const NSEC_IN_SEC int64 = 1000000000 //nolint:stylecheck @@ -25,16 +29,16 @@ type Supervised interface { type supervised struct { cfg *SupervisorConfig - events events.Handler + events events.EventBus pool Pool stopCh chan struct{} mu *sync.RWMutex } -func supervisorWrapper(pool Pool, events events.Handler, cfg *SupervisorConfig) Supervised { +func supervisorWrapper(pool Pool, eb events.EventBus, cfg *SupervisorConfig) Supervised { sp := &supervised{ cfg: cfg, - events: events, + events: eb, pool: pool, mu: &sync.RWMutex{}, stopCh: make(chan struct{}), @@ -148,7 +152,7 @@ func (sp *supervised) control() { //nolint:gocognit } // just to double check workers[i].State().Set(worker.StateInvalid) - sp.events.Push(events.PoolEvent{Event: events.EventTTL, Payload: workers[i]}) + sp.events.Send(events.NewEvent(events.EventTTL, supervisorName, fmt.Sprintf("worker's pid: %d", workers[i].Pid()))) continue } @@ -168,7 +172,7 @@ func (sp *supervised) control() { //nolint:gocognit } // just to double check workers[i].State().Set(worker.StateInvalid) - sp.events.Push(events.PoolEvent{Event: events.EventMaxMemory, Payload: workers[i]}) + sp.events.Send(events.NewEvent(events.EventMaxMemory, supervisorName, fmt.Sprintf("worker's pid: %d", workers[i].Pid()))) continue } @@ -223,7 +227,7 @@ func (sp *supervised) control() { //nolint:gocognit } // just to double-check workers[i].State().Set(worker.StateInvalid) - sp.events.Push(events.PoolEvent{Event: events.EventIdleTTL, Payload: workers[i]}) + sp.events.Send(events.NewEvent(events.EventIdleTTL, supervisorName, fmt.Sprintf("worker's pid: %d", workers[i].Pid()))) } } } |