-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinterfaces.go
69 lines (60 loc) · 2.42 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package common
import (
"context"
"time"
"github.com/roadrunner-server/pool/payload"
"github.com/roadrunner-server/pool/pool"
"github.com/roadrunner-server/pool/state/process"
"github.com/roadrunner-server/pool/worker"
"github.com/temporalio/roadrunner-temporal/v5/internal"
"go.temporal.io/sdk/interceptor"
"go.uber.org/zap"
staticPool "github.com/roadrunner-server/pool/pool/static_pool"
)
type Interceptor interface {
WorkerInterceptor() interceptor.WorkerInterceptor
Name() string
}
type Pool interface {
// Workers return a worker list associated with the pool.
Workers() (workers []*worker.Process)
// RemoveWorker removes worker from the pool.
RemoveWorker(ctx context.Context) error
// AddWorker adds worker to the pool.
AddWorker() error
// QueueSize can be implemented on the pool to provide the request queue information
QueueSize() uint64
// Reset kill all workers inside the watcher and replaces with new
Reset(ctx context.Context) error
// Exec payload
Exec(ctx context.Context, p *payload.Payload, stopCh chan struct{}) (chan *staticPool.PExec, error)
}
type Codec interface {
// Encode encodes messages and context to the payload for the worker
Encode(ctx *internal.Context, p *payload.Payload, msg ...*internal.Message) error
// Decode decodes payload from the worker to the proto-message
Decode(pld *payload.Payload, msg *[]*internal.Message) error
// DecodeWorkerInfo decode a call to get a worker info ID=0 (initial)
DecodeWorkerInfo(p *payload.Payload, wi *[]*internal.WorkerInfo) error
}
// Informer used to get workers from a particular plugin or set of plugins
type Informer interface {
Workers() []*process.State
}
type Configurer interface {
// UnmarshalKey takes a single key and unmarshal it into a Struct.
UnmarshalKey(name string, out any) error
// Has checks if a config section exists.
Has(name string) bool
// GracefulTimeout represents timeout for all servers registered in the endure
GracefulTimeout() time.Duration
// RRVersion returns running RR version
RRVersion() string
// Experimental returns true if the plugin is experimental
Experimental() 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)
NewPoolWithOptions(ctx context.Context, cfg *pool.Config, env map[string]string, _ *zap.Logger, options ...staticPool.Options) (*staticPool.Pool, error)
}