Documentation
¶
Overview ¶
Package checkpoint lets state clients order their checkpoints after the resources they summarize.
Index ¶
- Variables
- func Deliver(ctx context.Context, res chan<- message.SyncMessage, msg message.SyncMessage) error
- func Drop(msg message.SyncMessage)
- func WithScope(ctx context.Context, scope Scope) context.Context
- type Barrier
- type Collapsing
- type Delivery
- func (s *Delivery) Abort()
- func (s *Delivery) Aborted() bool
- func (s *Delivery) Delivered() bool
- func (s *Delivery) Finish(ctx context.Context, res chan<- message.SyncMessage) error
- func (s *Delivery) MergeInto(into *Delivery)
- func (s *Delivery) MergedInto(into *Delivery) bool
- func (s *Delivery) NotifyAbort(flag *atomic.Bool)
- type Ordering
- type Scope
- type Tracked
Constants ¶
This section is empty.
Variables ¶
var ErrSyncAborted = errors.New("sync aborted before the checkpoint could be sent")
ErrSyncAborted is returned for checkpoints that were dropped because the sync was cancelled.
Functions ¶
func Deliver ¶
func Deliver(ctx context.Context, res chan<- message.SyncMessage, msg message.SyncMessage) error
Deliver sends msg on res. A *Barrier is marked as reached instead, and a *Tracked message is sent and marked as sent.
func Drop ¶
func Drop(msg message.SyncMessage)
Drop marks msg as never to be sent: a dropped *Tracked message, or the message a dropped *Barrier leads to, is aborted, and so are the checkpoints waiting for it.
Types ¶
type Barrier ¶
type Barrier struct {
// contains filtered or unexported fields
}
Barrier travels through scopes and sent checkpoints, and calls reached each time one of them gets to it.
func (*Barrier) IsSyncMessage ¶
type Collapsing ¶
type Collapsing interface {
// Collapsed returns the shared scope, or the scope itself.
Collapsed() Scope
}
Collapsing is implemented by scopes that can become equivalent to a scope they share with others, such as a table resolver's scope once the resolver ends.
type Delivery ¶
type Delivery struct {
// contains filtered or unexported fields
}
Delivery tracks whether a checkpoint was sent or aborted, so that later checkpoints of the same keys can wait for it.
func NewHeld ¶
NewHeld returns a Delivery for a checkpoint that holder merges other checkpoints into.
func Schedule ¶
func Schedule(ctx context.Context, res chan<- message.SyncMessage, scope Scope, after []*Delivery, msg message.SyncMessage) (*Delivery, error)
Schedule passes msg to Deliver once every one of scope's resources produced before the call is sent, and every checkpoint in after is sent, which may be after it returns. Without a scope or pending checkpoints to wait for, it sends msg on res. The returned Delivery tracks msg. If a checkpoint in after was aborted, Schedule returns ErrSyncAborted.
func (*Delivery) Abort ¶
func (s *Delivery) Abort()
Abort marks s as dropped, and aborts the checkpoints waiting for it.
func (*Delivery) MergeInto ¶
MergeInto marks s as sent once into is sent, and aborted if into is aborted. into must not be sent yet.
func (*Delivery) MergedInto ¶
MergedInto reports whether s is sent with into.
func (*Delivery) NotifyAbort ¶
NotifyAbort sets flag if the checkpoint is aborted, or now if it already was.
type Ordering ¶
type Ordering interface {
// SendsAfter reports whether a checkpoint passed to the scope now will be sent no earlier than delivery.
SendsAfter(delivery *Delivery) bool
}
Ordering is implemented by scopes that never send a checkpoint before an unsent one they already hold.
type Scope ¶
type Scope interface {
// Checkpoint passes msg to Deliver after every resource the scope produced before the call is sent, or to Drop if
// the sync is cancelled first. It may return before that.
Checkpoint(ctx context.Context, msg message.SyncMessage) error
}
Scope is the part of a sync that a table resolver drives: the resources it produces and their relations.
func Collapse ¶
Collapse returns the shared scope a Collapsing scope collapsed into, or scope itself.
func FromContext ¶
FromContext returns the scope ctx belongs to, or nil outside table resolvers.