diff options
author | Valery Piashchynski <[email protected]> | 2021-07-10 16:14:37 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-07-10 16:14:37 +0300 |
commit | cb2665d93ad7abe1ab30508ff0e2bd4d0bc379ea (patch) | |
tree | d434861d00919985e9335c79336695cd3085bdcb /pkg/pool | |
parent | 453eb10b436925ef91b1206e795e581e6293d132 (diff) |
Move interfaces to its consumers
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'pkg/pool')
-rw-r--r-- | pkg/pool/interface.go | 24 | ||||
-rwxr-xr-x | pkg/pool/static_pool.go | 2 |
2 files changed, 25 insertions, 1 deletions
diff --git a/pkg/pool/interface.go b/pkg/pool/interface.go index c22fbbd3..bbf7653e 100644 --- a/pkg/pool/interface.go +++ b/pkg/pool/interface.go @@ -27,3 +27,27 @@ type Pool interface { // ExecWithContext executes task with context which is used with timeout execWithTTL(ctx context.Context, rqs payload.Payload) (payload.Payload, error) } + +// Watcher is an interface for the Sync workers lifecycle +type Watcher interface { + // Watch used to add workers to the container + Watch(workers []worker.BaseProcess) error + + // Get provide first free worker + Get(ctx context.Context) (worker.BaseProcess, error) + + // Push enqueues worker back + Push(w worker.BaseProcess) + + // Allocate - allocates new worker and put it into the WorkerWatcher + Allocate() error + + // Destroy destroys the underlying container + Destroy(ctx context.Context) + + // List return all container w/o removing it from internal storage + List() []worker.BaseProcess + + // Remove will remove worker from the container + Remove(wb worker.BaseProcess) +} diff --git a/pkg/pool/static_pool.go b/pkg/pool/static_pool.go index 1c149c51..f2f19795 100755 --- a/pkg/pool/static_pool.go +++ b/pkg/pool/static_pool.go @@ -41,7 +41,7 @@ type StaticPool struct { listeners []events.Listener // manages worker states and TTLs - ww workerWatcher.Watcher + ww Watcher // allocate new worker allocator worker.Allocator |