inmemory

package
v0.63.1 Latest Latest
Warning

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

Go to latest
Published: May 15, 2022 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

func LogHistoryOnFailure added in v0.63.0

func LogHistoryOnFailure(tb testingTB, el EventViewer)

func RewriteEventLog added in v0.63.0

func RewriteEventLog[EventType any](el *EventLog, rewrite func(es []EventType) []EventType)

Types

type Event added in v0.63.0

type Event = interface{}

type EventLog added in v0.63.0

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

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

func NewEventLog added in v0.63.0

func NewEventLog() *EventLog

func (*EventLog) Append added in v0.63.0

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

func (*EventLog) Atomic added in v0.63.0

func (el *EventLog) Atomic(ctx context.Context, fn func(tx *EventLogTx) error) error

func (*EventLog) BeginTx added in v0.63.0

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

func (*EventLog) CommitTx added in v0.63.0

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

func (*EventLog) Compress added in v0.63.0

func (el *EventLog) Compress()

func (*EventLog) Events added in v0.63.0

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

func (*EventLog) EventsInContext added in v0.63.0

func (el *EventLog) EventsInContext(ctx context.Context) []Event

func (*EventLog) LookupMeta added in v0.63.0

func (el *EventLog) LookupMeta(ctx context.Context, key string, ptr interface{}) (_found bool, _err error)

func (*EventLog) LookupTx added in v0.63.0

func (el *EventLog) LookupTx(ctx context.Context) (*EventLogTx, bool)

func (*EventLog) Rewrite added in v0.63.0

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

func (*EventLog) RollbackTx added in v0.63.0

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

func (*EventLog) SetMeta added in v0.63.0

func (el *EventLog) SetMeta(ctx context.Context, key string, value interface{}) (context.Context, error)

func (*EventLog) Subscribe added in v0.63.0

func (el *EventLog) Subscribe(ctx context.Context, subscriber EventLogSubscriber) (frameless.Subscription, error)

type EventLogEvent added in v0.63.0

type EventLogEvent struct {
	Type  string
	Name  string
	Trace []Stack
}

func (EventLogEvent) GetTrace added in v0.63.0

func (et EventLogEvent) GetTrace() []Stack

func (EventLogEvent) SetTrace added in v0.63.0

func (et EventLogEvent) SetTrace(trace []Stack)

func (EventLogEvent) String added in v0.63.0

func (et EventLogEvent) String() string

type EventLogStorage added in v0.63.0

type EventLogStorage[Ent, ID any] struct {
	EventLog *EventLog
	MakeID   func(ctx context.Context) (ID, error)

	// Namespace separates different storage events in the event log.
	// By default same entities reside under the same Namespace through their fully qualified name used as namespace ID.
	// If you want create multiple EventLogStorage that works with the same entity but act as separate storages,
	// you need to assign a unique Namespace for each of these EventLogStorage.
	Namespace string

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

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

func NewEventLogStorage added in v0.63.0

func NewEventLogStorage[Ent, ID any](m *EventLog) *EventLogStorage[Ent, ID]

func NewEventLogStorageWithNamespace added in v0.63.0

func NewEventLogStorageWithNamespace[Ent, ID any](m *EventLog, ns string) *EventLogStorage[Ent, ID]

func (*EventLogStorage[Ent, ID]) BeginTx added in v0.63.0

func (s *EventLogStorage[Ent, ID]) BeginTx(ctx context.Context) (context.Context, error)

func (*EventLogStorage[Ent, ID]) CommitTx added in v0.63.0

func (s *EventLogStorage[Ent, ID]) CommitTx(ctx context.Context) error

func (*EventLogStorage[Ent, ID]) Compress added in v0.63.0

func (s *EventLogStorage[Ent, ID]) Compress()

func (*EventLogStorage[Ent, ID]) Create added in v0.63.0

func (s *EventLogStorage[Ent, ID]) Create(ctx context.Context, ptr *Ent) error

func (*EventLogStorage[Ent, ID]) DeleteAll added in v0.63.0

func (s *EventLogStorage[Ent, ID]) DeleteAll(ctx context.Context) error

func (*EventLogStorage[Ent, ID]) DeleteByID added in v0.63.0

func (s *EventLogStorage[Ent, ID]) DeleteByID(ctx context.Context, id ID) error

func (*EventLogStorage[Ent, ID]) Events added in v0.63.0

func (s *EventLogStorage[Ent, ID]) Events(ctx context.Context) []EventLogStorageEvent[Ent, ID]

func (*EventLogStorage[Ent, ID]) FindAll added in v0.63.0

func (s *EventLogStorage[Ent, ID]) FindAll(ctx context.Context) frameless.Iterator[Ent]

func (*EventLogStorage[Ent, ID]) FindByID added in v0.63.0

func (s *EventLogStorage[Ent, ID]) FindByID(ctx context.Context, ptr *Ent, id ID) (_found bool, _err error)

func (*EventLogStorage[Ent, ID]) FindByIDs added in v0.63.0

func (s *EventLogStorage[Ent, ID]) FindByIDs(ctx context.Context, ids ...ID) frameless.Iterator[Ent]

func (*EventLogStorage[Ent, ID]) GetNamespace added in v0.63.0

func (s *EventLogStorage[Ent, ID]) GetNamespace() string

func (*EventLogStorage[Ent, ID]) LookupTx added in v0.63.0

func (s *EventLogStorage[Ent, ID]) LookupTx(ctx context.Context) (*EventLogTx, bool)

func (*EventLogStorage[Ent, ID]) RollbackTx added in v0.63.0

func (s *EventLogStorage[Ent, ID]) RollbackTx(ctx context.Context) error

func (*EventLogStorage[Ent, ID]) SubscribeToCreate added in v0.63.0

func (s *EventLogStorage[Ent, ID]) SubscribeToCreate(ctx context.Context, subscriber EventLogSubscriber) (frameless.Subscription, error)

func (*EventLogStorage[Ent, ID]) SubscribeToCreatorEvents added in v0.63.0

func (s *EventLogStorage[Ent, ID]) SubscribeToCreatorEvents(ctx context.Context, subscriber frameless.CreatorSubscriber[Ent]) (frameless.Subscription, error)

func (*EventLogStorage[Ent, ID]) SubscribeToDeleteAll added in v0.63.0

func (s *EventLogStorage[Ent, ID]) SubscribeToDeleteAll(ctx context.Context, subscriber EventLogSubscriber) (frameless.Subscription, error)

func (*EventLogStorage[Ent, ID]) SubscribeToDeleteByID added in v0.63.0

func (s *EventLogStorage[Ent, ID]) SubscribeToDeleteByID(ctx context.Context, subscriber EventLogSubscriber) (frameless.Subscription, error)

func (*EventLogStorage[Ent, ID]) SubscribeToDeleterEvents added in v0.63.0

func (s *EventLogStorage[Ent, ID]) SubscribeToDeleterEvents(ctx context.Context, subscriber frameless.DeleterSubscriber[ID]) (frameless.Subscription, error)

func (*EventLogStorage[Ent, ID]) SubscribeToUpdate added in v0.63.0

func (s *EventLogStorage[Ent, ID]) SubscribeToUpdate(ctx context.Context, subscriber EventLogSubscriber) (frameless.Subscription, error)

func (*EventLogStorage[Ent, ID]) SubscribeToUpdaterEvents added in v0.63.0

func (s *EventLogStorage[Ent, ID]) SubscribeToUpdaterEvents(ctx context.Context, subscriber frameless.UpdaterSubscriber[Ent]) (frameless.Subscription, error)

func (*EventLogStorage[Ent, ID]) Update added in v0.63.0

func (s *EventLogStorage[Ent, ID]) Update(ctx context.Context, ptr *Ent) error

func (*EventLogStorage[Ent, ID]) Upsert added in v0.63.0

func (s *EventLogStorage[Ent, ID]) Upsert(ctx context.Context, ptrs ...*Ent) (rErr error)

func (*EventLogStorage[Ent, ID]) View added in v0.63.0

func (s *EventLogStorage[Ent, ID]) View(ctx context.Context) StorageView[Ent, ID]

type EventLogStorageEvent added in v0.63.0

type EventLogStorageEvent[Ent, ID any] struct {
	Namespace string
	Name      string
	Value     Ent
	Trace     []Stack
}

func (EventLogStorageEvent[Ent, ID]) GetTrace added in v0.63.0

func (e EventLogStorageEvent[Ent, ID]) GetTrace() []Stack

func (EventLogStorageEvent[Ent, ID]) SetTrace added in v0.63.0

func (e EventLogStorageEvent[Ent, ID]) SetTrace(trace []Stack)

func (EventLogStorageEvent[Ent, ID]) String added in v0.63.0

func (e EventLogStorageEvent[Ent, ID]) String() string

type EventLogSubscriber added in v0.63.0

type EventLogSubscriber interface {
	// Handle handles the the subscribed event.
	// Context may or may not have meta information about the received event.
	// To ensure expectations, define a resource specification <contract> about what must be included in the context.
	Handle(ctx context.Context, event interface{}) error
	// Error allow the subscription implementation to be notified about unexpected situations
	// that needs to be handled by the subscriber.
	// For e.g. the connection is lost and the subscriber might have cached values
	// that must be invalidated on the next successful Handle call
	HandleError(ctx context.Context, err error) error
}

type EventLogTx added in v0.63.0

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

func (*EventLogTx) Append added in v0.63.0

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

func (*EventLogTx) Events added in v0.63.0

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

type EventManager added in v0.63.0

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

type EventViewer added in v0.63.0

type EventViewer interface {
	Events() []Event
}

type Memory added in v0.63.0

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

func NewMemory added in v0.63.0

func NewMemory() *Memory

func (*Memory) All added in v0.63.0

func (m *Memory) All(T frameless.T, ctx context.Context, namespace string) (sliceOfT interface{})

func (*Memory) BeginTx added in v0.63.0

func (m *Memory) BeginTx(ctx context.Context) (context.Context, error)

func (*Memory) CommitTx added in v0.63.0

func (m *Memory) CommitTx(ctx context.Context) error

func (*Memory) Del added in v0.63.0

func (m *Memory) Del(ctx context.Context, namespace string, key string) bool

func (*Memory) Get added in v0.63.0

func (m *Memory) Get(ctx context.Context, namespace string, key string) (interface{}, bool)

func (*Memory) LookupMeta added in v0.63.0

func (m *Memory) LookupMeta(ctx context.Context, key string, ptr interface{}) (_found bool, _err error)

func (*Memory) LookupTx added in v0.63.0

func (m *Memory) LookupTx(ctx context.Context) (*MemoryTx, bool)

func (*Memory) RollbackTx added in v0.63.0

func (m *Memory) RollbackTx(ctx context.Context) error

func (*Memory) Set added in v0.63.0

func (m *Memory) Set(ctx context.Context, namespace, key string, value interface{})

func (*Memory) SetMeta added in v0.63.0

func (m *Memory) SetMeta(ctx context.Context, key string, value interface{}) (context.Context, error)

type MemoryNamespace added in v0.63.0

type MemoryNamespace map[string]interface{}

type MemoryTx added in v0.63.0

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

type Stack added in v0.63.0

type Stack struct {
	Path string
	Line int
}

func NewTrace added in v0.63.0

func NewTrace(offset int) []Stack

func (Stack) RelPath added in v0.63.0

func (te Stack) RelPath() string

type Storage

type Storage[Ent, ID any] struct {
	Memory    *Memory
	NewID     func(context.Context) (ID, error)
	Namespace string
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage[Ent, ID any](m *Memory) *Storage[Ent, ID]

func NewStorageWithNamespace added in v0.63.0

func NewStorageWithNamespace[Ent, ID any](m *Memory, ns string) *Storage[Ent, ID]

func (*Storage[Ent, ID]) Create

func (s *Storage[Ent, ID]) Create(ctx context.Context, ptr *Ent) error

func (*Storage[Ent, ID]) DeleteAll

func (s *Storage[Ent, ID]) DeleteAll(ctx context.Context) error

func (*Storage[Ent, ID]) DeleteByID

func (s *Storage[Ent, ID]) DeleteByID(ctx context.Context, id ID) error

func (*Storage[Ent, ID]) FindAll

func (s *Storage[Ent, ID]) FindAll(ctx context.Context) frameless.Iterator[Ent]

func (*Storage[Ent, ID]) FindByID

func (s *Storage[Ent, ID]) FindByID(ctx context.Context, ptr *Ent, id ID) (found bool, err error)

func (*Storage[Ent, ID]) FindByIDs added in v0.63.0

func (s *Storage[Ent, ID]) FindByIDs(ctx context.Context, ids ...ID) frameless.Iterator[Ent]

func (*Storage[Ent, ID]) GetNamespace added in v0.63.0

func (s *Storage[Ent, ID]) GetNamespace() string

func (*Storage[Ent, ID]) IDToMemoryKey added in v0.63.0

func (s *Storage[Ent, ID]) IDToMemoryKey(id frameless.T) string

func (*Storage[Ent, ID]) MakeID added in v0.63.0

func (s *Storage[Ent, ID]) MakeID(ctx context.Context) (ID, error)

func (*Storage[Ent, ID]) Update

func (s *Storage[Ent, ID]) Update(ctx context.Context, ptr *Ent) error

func (*Storage[Ent, ID]) Upsert added in v0.63.0

func (s *Storage[Ent, ID]) Upsert(ctx context.Context, ptrs ...*Ent) error

type StorageView added in v0.63.0

type StorageView[Ent, ID any] map[string]Ent

func (StorageView[Ent, ID]) FindByID added in v0.63.0

func (v StorageView[Ent, ID]) FindByID(id ID) (Ent, bool)

type Subscription added in v0.63.0

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

func (*Subscription) Close added in v0.63.0

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

type Traceable added in v0.63.0

type Traceable interface {
	GetTrace() []Stack
	SetTrace([]Stack)
}

Jump to

Keyboard shortcuts

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