-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
interface.go
43 lines (33 loc) 路 1.27 KB
/
interface.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
package jobs
import (
"context"
"github.com/roadrunner-server/sdk/v3/plugins/jobs/pipeline"
priorityqueue "github.com/roadrunner-server/sdk/v3/priority_queue"
)
// Consumer represents a single jobs driver interface
type Consumer interface {
Push(ctx context.Context, job *Job) error
Register(ctx context.Context, pipeline *pipeline.Pipeline) error
Run(ctx context.Context, pipeline *pipeline.Pipeline) error
Stop(ctx context.Context) error
Pause(ctx context.Context, pipeline string)
Resume(ctx context.Context, pipeline string)
// State provide information about driver state
State(ctx context.Context) (*State, error)
}
// Acknowledger provides queue specific item management
type Acknowledger interface {
// Ack - acknowledge the Item after processing
Ack() error
// Nack - discard the Item
Nack() error
// Requeue - put the message back to the queue with the optional delay
Requeue(headers map[string][]string, delay int64) error
// Respond to the queue
Respond(payload []byte, queue string) error
}
// Constructor constructs Consumer interface. Endure abstraction.
type Constructor interface {
ConsumerFromConfig(configKey string, queue priorityqueue.Queue) (Consumer, error)
ConsumerFromPipeline(pipe *pipeline.Pipeline, queue priorityqueue.Queue) (Consumer, error)
}