-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontract.go
More file actions
39 lines (33 loc) · 1.12 KB
/
contract.go
File metadata and controls
39 lines (33 loc) · 1.12 KB
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
package rate_envelope_queue
import (
"context"
"errors"
"fmt"
)
var (
ErrStopEnvelope = errors.New(fmt.Sprintf("%s: stop envelope", service))
ErrEnvelopeQueueIsNotRunning = errors.New(fmt.Sprintf("%s: regect envelope, queue is not running or init", service))
ErrQueueIsTerminated = errors.New(fmt.Sprintf("%s: regect envelope, queue is terminated", service))
ErrAdditionEnvelopeToQueueBadFields = errors.New(fmt.Sprintf("%s: addition envelope to queue has bad fields", service))
ErrAdditionEnvelopeToQueueBadIntervals = errors.New(fmt.Sprintf("%s: addition envelope to queue has bad intervals", service))
ErrAllowedQueueCapacityExceeded = errors.New(fmt.Sprintf("%s: allowed queue capacity exceeded", service))
)
type (
StopMode string
Invoker func(ctx context.Context, envelope *Envelope) error
Stamp func(next Invoker) Invoker
)
const (
Drain StopMode = "drain"
Stop StopMode = "stop"
service = "[rate-envelope-queue]"
)
type (
SingleQueuePool interface {
Send(envelopes ...*Envelope) error
Start()
Stop()
Terminate()
CurrentState() QueueState
}
)