inmemory

package
v0.55.0 Latest Latest
Warning

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

Go to latest
Published: Sep 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

func LogHistoryOnFailure added in v0.41.0

func LogHistoryOnFailure(tb testingTB, el EventViewer)

Types

type Event added in v0.36.0

type Event = interface{}

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) Append added in v0.36.0

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

func (*EventLog) Atomic added in v0.36.0

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

func (*EventLog) BeginTx added in v0.36.0

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

func (*EventLog) CommitTx added in v0.36.0

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

func (*EventLog) Compress added in v0.41.0

func (el *EventLog) Compress()

func (*EventLog) Events added in v0.36.0

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

func (*EventLog) LookupMeta added in v0.43.1

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

func (*EventLog) LookupTx added in v0.36.0

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

func (*EventLog) Rewrite added in v0.36.0

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

func (*EventLog) RollbackTx added in v0.36.0

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

func (*EventLog) SetMeta added in v0.43.1

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

func (*EventLog) Subscribe added in v0.41.0

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

type EventLogEvent added in v0.41.0

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

func (EventLogEvent) GetTrace added in v0.41.0

func (et EventLogEvent) GetTrace() []Stack

func (EventLogEvent) SetTrace added in v0.41.0

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

func (EventLogEvent) String added in v0.41.0

func (et EventLogEvent) String() string

type EventLogStorage added in v0.41.0

type EventLogStorage struct {
	T        interface{}
	EventLog *EventLog
	NewID    func(ctx context.Context) (interface{}, 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.41.0

func NewEventLogStorage(T interface{}, m *EventLog) *EventLogStorage

func NewEventLogStorageWithNamespace added in v0.43.0

func NewEventLogStorageWithNamespace(T interface{}, m *EventLog, ns string) *EventLogStorage

func (*EventLogStorage) BeginTx added in v0.41.0

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

func (*EventLogStorage) CommitTx added in v0.41.0

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

func (*EventLogStorage) Compress added in v0.41.0

func (s *EventLogStorage) Compress()

func (*EventLogStorage) Create added in v0.41.0

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

func (*EventLogStorage) DeleteAll added in v0.41.0

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

func (*EventLogStorage) DeleteByID added in v0.41.0

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

func (*EventLogStorage) FindAll added in v0.41.0

func (*EventLogStorage) FindByID added in v0.41.0

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

func (*EventLogStorage) FindByIDs added in v0.41.0

func (s *EventLogStorage) FindByIDs(ctx context.Context, ids ...interface{}) frameless.Iterator

func (*EventLogStorage) GetNamespace added in v0.43.0

func (s *EventLogStorage) GetNamespace() string

func (*EventLogStorage) LookupTx added in v0.41.0

func (s *EventLogStorage) LookupTx(ctx context.Context) (*EventLogTx, bool)

func (*EventLogStorage) RollbackTx added in v0.41.0

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

func (*EventLogStorage) SubscribeToCreate added in v0.41.0

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

func (*EventLogStorage) SubscribeToCreatorEvents added in v0.54.0

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

func (*EventLogStorage) SubscribeToDeleteAll added in v0.41.0

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

func (*EventLogStorage) SubscribeToDeleteByID added in v0.41.0

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

func (*EventLogStorage) SubscribeToDeleterEvents added in v0.54.0

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

func (*EventLogStorage) SubscribeToUpdate added in v0.41.0

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

func (*EventLogStorage) SubscribeToUpdaterEvents added in v0.54.0

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

func (*EventLogStorage) Update added in v0.41.0

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

func (*EventLogStorage) Upsert added in v0.41.0

func (s *EventLogStorage) Upsert(ctx context.Context, ptrs ...interface{}) (rErr error)

func (*EventLogStorage) View added in v0.41.0

type EventLogStorageEvent added in v0.41.0

type EventLogStorageEvent struct {
	Namespace string
	T         interface{}
	Name      string
	Value     interface{}
	Trace     []Stack
}

func (EventLogStorageEvent) GetTrace added in v0.41.0

func (e EventLogStorageEvent) GetTrace() []Stack

func (EventLogStorageEvent) SetTrace added in v0.41.0

func (e EventLogStorageEvent) SetTrace(trace []Stack)

func (EventLogStorageEvent) String added in v0.41.0

func (e EventLogStorageEvent) String() string

type EventLogSubscriber added in v0.54.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.41.0

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

func (*EventLogTx) Append added in v0.41.0

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

func (*EventLogTx) Events added in v0.41.0

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

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 Memory added in v0.41.0

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

func NewMemory added in v0.41.0

func NewMemory() *Memory

func (*Memory) All added in v0.41.0

func (m *Memory) All(T frameless.T, ctx context.Context, namespace string) frameless.Iterator

func (*Memory) BeginTx added in v0.41.0

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

func (*Memory) CommitTx added in v0.41.0

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

func (*Memory) Del added in v0.41.0

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

func (*Memory) Get added in v0.41.0

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

func (*Memory) LookupMeta added in v0.43.1

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

func (*Memory) LookupTx added in v0.41.0

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

func (*Memory) RollbackTx added in v0.41.0

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

func (*Memory) Set added in v0.41.0

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

func (*Memory) SetMeta added in v0.43.1

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

type MemoryNamespace added in v0.41.0

type MemoryNamespace map[string]interface{}

type MemoryTx added in v0.41.0

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

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         frameless.T
	Memory    *Memory
	NewID     func(context.Context) (interface{}, error)
	Namespace string
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage(T frameless.T, m *Memory) *Storage

func NewStorageWithNamespace added in v0.43.0

func NewStorageWithNamespace(T frameless.T, m *Memory, ns string) *Storage

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, id interface{}) (found bool, err error)

func (*Storage) FindByIDs added in v0.41.0

func (s *Storage) FindByIDs(ctx context.Context, ids ...interface{}) frameless.Iterator

func (*Storage) GetNamespace added in v0.43.0

func (s *Storage) GetNamespace() string

func (*Storage) IDToMemoryKey added in v0.41.0

func (s *Storage) IDToMemoryKey(id frameless.T) string

func (*Storage) Update

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

func (*Storage) Upsert added in v0.41.0

func (s *Storage) Upsert(ctx context.Context, ptrs ...interface{}) error

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 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 Traceable added in v0.41.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