cache

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.Mutex
	sync.Cond
	// contains filtered or unexported fields
}

Cache stores operations fetched from the WAL that need to be transformed and synced to SpiceDB. It is safe to use from multiple threads.

func NewCache

func NewCache(ctx context.Context) *Cache

NewCache returns a new cache tied to the lifetime of the context. The cache can be closed by cancelling the context. Calling NewCache spawns a goroutine to handle cancellation.

func (*Cache) Delete

func (c *Cache) Delete(rel *v1.Relationship)

Delete puts a new delete event in the cache for the relationship

func (*Cache) Next

func (c *Cache) Next() *Operation

Next returns the next relationship in the queue it blocks until an item is added if the queue is empty and returns nil only when stopped via the context

func (*Cache) Requeue

func (c *Cache) Requeue(op OperationType, rel *v1.Relationship)

Requeue re-adds a key that failed to apply It is handled differently from normal additions to the queue. A delete added to a cache with a touch would normally cancel both out, but a requeued delete may still need to delete the relationship in the backing spicedb.

func (*Cache) Touch

func (c *Cache) Touch(rel *v1.Relationship)

Touch puts a new touch event in the cache for the relationship

type Operation

type Operation struct {
	OpType OperationType
	Rel    *v1.Relationship
}

Operation is an OpType + the Relationship that was generated

type OperationType

type OperationType int

OperationType stores what needs to happen to the relationships in the cache

const (
	OperationTypeTouch OperationType = iota
	OperationTypeDelete
)

Currently supported types are Touch and Delete

func (OperationType) RelationshipUpdateOpType

func (t OperationType) RelationshipUpdateOpType() v1.RelationshipUpdate_Operation

RelationshipUpdateOpType transforms the cache's OpType to a v1 relationship operation.

func (OperationType) String

func (t OperationType) String() string

Jump to

Keyboard shortcuts

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