-
Notifications
You must be signed in to change notification settings - Fork 795
/
flush.go
36 lines (29 loc) · 1.05 KB
/
flush.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
package ring
import (
"context"
"errors"
)
// ErrTransferDisabled is the error returned by TransferOut when the transfers are disabled.
var ErrTransferDisabled = errors.New("transfers disabled")
// FlushTransferer controls the shutdown of an instance in the ring.
// Methods on this interface are called when lifecycler is stopping.
// At that point, it no longer runs the "actor loop", but it keeps updating heartbeat in the ring.
// Ring entry is in LEAVING state.
// After calling TransferOut and then Flush, lifecycler stops.
type FlushTransferer interface {
Flush()
TransferOut(ctx context.Context) error
}
// NoopFlushTransferer is a FlushTransferer which does nothing and can
// be used in cases we don't need one
type NoopFlushTransferer struct{}
// NewNoopFlushTransferer makes a new NoopFlushTransferer
func NewNoopFlushTransferer() *NoopFlushTransferer {
return &NoopFlushTransferer{}
}
// Flush is a noop
func (t *NoopFlushTransferer) Flush() {}
// TransferOut is a noop
func (t *NoopFlushTransferer) TransferOut(ctx context.Context) error {
return nil
}