forked from roadrunner-server/jobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interfaces.go
52 lines (44 loc) · 1.48 KB
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package jobs
import (
"context"
"github.com/roadrunner-server/sdk/v4/payload"
"github.com/roadrunner-server/sdk/v4/pool"
staticPool "github.com/roadrunner-server/sdk/v4/pool/static_pool"
"github.com/roadrunner-server/sdk/v4/state/process"
"github.com/roadrunner-server/sdk/v4/worker"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
"go.uber.org/zap"
)
type Logger interface {
NamedLogger(name string) *zap.Logger
}
type Informer interface {
Workers() []*process.State
}
type Tracer interface {
Tracer() *sdktrace.TracerProvider
}
type Pool interface {
// Workers returns worker list associated with the pool.
Workers() (workers []*worker.Process)
// Exec payload
Exec(ctx context.Context, p *payload.Payload, stopCh chan struct{}) (chan *staticPool.PExec, error)
// RemoveWorker removes worker from the pool.
RemoveWorker(ctx context.Context) error
// AddWorker adds worker to the pool.
AddWorker() error
// Reset kill all workers inside the watcher and replaces with new
Reset(ctx context.Context) error
// Destroy all underlying stack (but let them complete the task).
Destroy(ctx context.Context)
}
type Configurer interface {
// UnmarshalKey takes a single key and unmarshal it into a Struct.
UnmarshalKey(name string, out any) error
// Has checks if config section exists.
Has(name string) bool
}
// Server creates workers for the application.
type Server interface {
NewPool(ctx context.Context, cfg *pool.Config, env map[string]string, _ *zap.Logger) (*staticPool.Pool, error)
}