future

package
v0.0.0-...-75be81d Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbstractFuture

type AbstractFuture interface {
	IsFilled() bool
	Encode(codec codec.Codec[any, []byte]) ([]byte, error)
	// contains filtered or unexported methods
}

AbstractFuture can hold a future without caring about it's type

type Future

type Future[T any] struct {
	// contains filtered or unexported fields
}

func Empty

func Empty[T any]() Future[T]

func FromValue

func FromValue[T any](val T) Future[T]

func (Future[T]) EmptyValue

func (f Future[T]) EmptyValue() T

func (Future[T]) Encode

func (f Future[T]) Encode(codec codec.Codec[any, []byte]) ([]byte, error)

func (*Future[T]) Initialize

func (f *Future[T]) Initialize()

func (Future[T]) IsFilled

func (f Future[T]) IsFilled() bool

func (Future[T]) ParseToNew

func (f Future[T]) ParseToNew(data []byte) (Future[T], error)

func (Future[T]) Value

func (f Future[T]) Value() T

type InitializeableFuture

type InitializeableFuture interface {
	Initialize()
}

type Storage

type Storage struct {
	// contains filtered or unexported fields
}

Storage manages future-resource_db mapping. It is not thread safe

func NewStorage

func NewStorage() Storage

func (*Storage) AddFuture

func (s *Storage) AddFuture(fut AbstractFuture)

func (*Storage) Allocate

func (s *Storage) Allocate(ctx context.Context, storage core.ResourceDB) error

Allocate ids for resources without them, empty resources are assigned to futures without them

func (*Storage) AssignResource

func (s *Storage) AssignResource(fut AbstractFuture, res *core.Resource, saved bool)

func (*Storage) Encode

func (s *Storage) Encode(codec codec.Codec[any, []byte]) error

Encode all filled futures. It will create resources, or fill Data field for existing ones. Not filled futures and resources with Data are skipped.

func (*Storage) GetResource

func (s *Storage) GetResource(fut AbstractFuture) *core.Resource

func (*Storage) HasFuture

func (s *Storage) HasFuture(fut AbstractFuture) bool

func (*Storage) Rollback

func (s *Storage) Rollback(ctx context.Context, storage core.ResourceDB) error

func (*Storage) Save

func (s *Storage) Save(ctx context.Context, storage core.ResourceDB) error

Save all resources that are not marked as saved and have data

Jump to

Keyboard shortcuts

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