inmemory

package
v0.39.3 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateEvent     = `Create`
	UpdateEvent     = `Update`
	DeleteAllEvent  = `DeleteAll`
	DeleteByIDEvent = `DeleteByID`
)

Name Types

Variables

This section is empty.

Functions

This section is empty.

Types

type Event added in v0.36.0

type Event struct {
	Type  interface{}
	Value interface{}
	Trace []Stack
}

type EventLog added in v0.36.0

type EventLog struct {
	Options struct {
		DisableAsyncSubscriptionHandling bool
	}
	// contains filtered or unexported fields
}

EventLog is an event source principles based development in memory memory, that allows easy debugging and tracing during development for fast and descriptive feedback loops.

func NewEventLog added in v0.36.0

func NewEventLog() *EventLog

func (*EventLog) AddSubscription added in v0.36.0

func (s *EventLog) AddSubscription(ctx context.Context, subscriber Subscriber) (frameless.Subscription, error)

func (*EventLog) Append added in v0.36.0

func (s *EventLog) Append(ctx context.Context, event Event) error

func (*EventLog) Atomic added in v0.36.0

func (s *EventLog) Atomic(ctx context.Context, fn func(tx *Tx) error) error

func (*EventLog) BeginTx added in v0.36.0

func (s *EventLog) BeginTx(ctx context.Context) (context.Context, error)

func (*EventLog) CommitTx added in v0.36.0

func (s *EventLog) CommitTx(ctx context.Context) error

func (*EventLog) Events added in v0.36.0

func (s *EventLog) Events() []Event

func (*EventLog) LookupTx added in v0.36.0

func (s *EventLog) LookupTx(ctx context.Context) (*Tx, bool)

func (*EventLog) Rewrite added in v0.36.0

func (s *EventLog) Rewrite(mapper func(es []Event) []Event)

func (*EventLog) RollbackTx added in v0.36.0

func (s *EventLog) RollbackTx(ctx context.Context) error

type EventManager added in v0.36.0

type EventManager interface {
	Append(context.Context, Event) error
	EventViewer
}

type EventViewer added in v0.36.0

type EventViewer interface {
	Events() []Event
}

type Stack added in v0.36.0

type Stack struct {
	Path string
	Line int
}

func NewTrace added in v0.36.0

func NewTrace(offset int) []Stack

func (Stack) RelPath added in v0.36.0

func (te Stack) RelPath() string

type Storage

type Storage struct {
	T        interface{}
	EventLog *EventLog
	NewID    func(ctx context.Context) (interface{}, error)

	Options struct {
		DisableEventLogging bool
	}
	// contains filtered or unexported fields
}

Storage is an EventLog based development in memory storage, that allows easy debugging and tracing during development for fast and descriptive feedback loops.

func NewStorage

func NewStorage(T interface{}, m *EventLog) *Storage

func (*Storage) BeginTx

func (s *Storage) BeginTx(ctx context.Context) (context.Context, error)

func (*Storage) CommitTx

func (s *Storage) CommitTx(ctx context.Context) error

func (*Storage) CompressEvents added in v0.36.0

func (s *Storage) CompressEvents()

func (*Storage) Create

func (s *Storage) Create(ctx context.Context, ptr interface{}) error

func (*Storage) DeleteAll

func (s *Storage) DeleteAll(ctx context.Context) error

func (*Storage) DeleteByID

func (s *Storage) DeleteByID(ctx context.Context, id interface{}) error

func (*Storage) FindAll

func (s *Storage) FindAll(ctx context.Context) frameless.Iterator

func (*Storage) FindByID

func (s *Storage) FindByID(ctx context.Context, ptr interface{}, id interface{}) (_found bool, _err error)

func (*Storage) LookupTx

func (s *Storage) LookupTx(ctx context.Context) (*Tx, bool)

func (*Storage) RollbackTx

func (s *Storage) RollbackTx(ctx context.Context) error

func (*Storage) SubscribeToCreate

func (s *Storage) SubscribeToCreate(ctx context.Context, subscriber frameless.Subscriber) (frameless.Subscription, error)

func (*Storage) SubscribeToDeleteAll

func (s *Storage) SubscribeToDeleteAll(ctx context.Context, subscriber frameless.Subscriber) (frameless.Subscription, error)

func (*Storage) SubscribeToDeleteByID

func (s *Storage) SubscribeToDeleteByID(ctx context.Context, subscriber frameless.Subscriber) (frameless.Subscription, error)

func (*Storage) SubscribeToUpdate

func (s *Storage) SubscribeToUpdate(ctx context.Context, subscriber frameless.Subscriber) (frameless.Subscription, error)

func (*Storage) Update

func (s *Storage) Update(ctx context.Context, ptr interface{}) error

func (*Storage) View added in v0.36.0

func (s *Storage) View(ctx context.Context) StorageView

type StorageEventType added in v0.36.0

type StorageEventType struct{ T interface{} }

type StorageEventValue added in v0.36.0

type StorageEventValue struct {
	Name  string
	Value interface{}
}

type StorageView added in v0.36.0

type StorageView map[string]interface{}

func (StorageView) FindByID added in v0.36.0

func (v StorageView) FindByID(id interface{}) (interface{}, bool)

type StubSubscriber added in v0.36.0

type StubSubscriber struct {
	HandleFunc func(ctx context.Context, event Event) error
	ErrorFunc  func(ctx context.Context, err error) error
}

func (StubSubscriber) Error added in v0.36.0

func (m StubSubscriber) Error(ctx context.Context, err error) error

func (StubSubscriber) Handle added in v0.36.0

func (m StubSubscriber) Handle(ctx context.Context, event Event) error

type Subscriber added in v0.36.0

type Subscriber interface {
	Handle(ctx context.Context, event Event) error
	Error(ctx context.Context, err error) error
}

type Subscription added in v0.36.0

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

func (*Subscription) Close added in v0.36.0

func (s *Subscription) Close() (rErr error)

type Tx added in v0.36.0

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

func (*Tx) Append added in v0.36.0

func (tx *Tx) Append(ctx context.Context, event Event) error

func (*Tx) Events added in v0.36.0

func (tx *Tx) Events() []Event

Jump to

Keyboard shortcuts

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