causalordersync

package
v0.1.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2023 License: Apache-2.0, BSD-2-Clause Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithReferenceValidator

func WithReferenceValidator[ID slot.IndexedID, Entity OrderedEntity[ID]](referenceValidator func(entity Entity, parent Entity) (err error)) options.Option[CausalOrder[ID, Entity]]

WithReferenceValidator is an option that sets the ReferenceValidator of the CausalOrder.

Types

type CausalOrder

type CausalOrder[ID slot.IndexedID, Entity OrderedEntity[ID]] struct {
	// contains filtered or unexported fields
}

CausalOrder represents an order where an Entity is ordered after its causal dependencies (parents) have been ordered.

func New

func New[ID slot.IndexedID, Entity OrderedEntity[ID]](
	workerPool *workerpool.WorkerPool,
	entityProvider func(id ID) (entity Entity, exists bool),
	isOrdered func(entity Entity) (isOrdered bool),
	orderedCallback func(entity Entity) (err error),
	evictionCallback func(entity Entity, reason error),
	parentsCallback func(entity Entity) []ID,
	opts ...options.Option[CausalOrder[ID, Entity]],
) (newCausalOrder *CausalOrder[ID, Entity])

New returns a new CausalOrderer instance with the given parameters.

func (*CausalOrder[ID, Entity]) EvictUntil

func (c *CausalOrder[ID, Entity]) EvictUntil(index slot.Index)

EvictUntil removes all Entities that are older than the given slot from the CausalOrder.

func (*CausalOrder[ID, Entity]) Queue

func (c *CausalOrder[ID, Entity]) Queue(entity Entity)

Queue adds the given Entity to the CausalOrderer and triggers it when it's ready.

type OrderedEntity

type OrderedEntity[ID slot.IndexedID] interface {
	// ID returns the ID of the Entity.
	ID() ID

	// comparable embeds the comparable interface.
	comparable
}

OrderedEntity is an interface that represents an Entity that can be causally ordered.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL