Documentation ¶
Index ¶
- Constants
- func LogHistoryOnFailure(tb testingTB, el EventViewer)
- func RewriteEventLog[EventType any](el *EventLog, rewrite func(es []EventType) []EventType)
- type Event
- type EventLog
- func (el *EventLog) Append(ctx context.Context, event Event) error
- func (el *EventLog) Atomic(ctx context.Context, fn func(tx *EventLogTx) error) error
- func (el *EventLog) BeginTx(ctx context.Context) (context.Context, error)
- func (el *EventLog) CommitTx(ctx context.Context) error
- func (el *EventLog) Compress()
- func (el *EventLog) Events() []Event
- func (el *EventLog) EventsInContext(ctx context.Context) []Event
- func (el *EventLog) LookupMeta(ctx context.Context, key string, ptr interface{}) (_found bool, _err error)
- func (el *EventLog) LookupTx(ctx context.Context) (*EventLogTx, bool)
- func (el *EventLog) Rewrite(mapper func(es []Event) []Event)
- func (el *EventLog) RollbackTx(ctx context.Context) error
- func (el *EventLog) SetMeta(ctx context.Context, key string, value interface{}) (context.Context, error)
- func (el *EventLog) Subscribe(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
- type EventLogEvent
- type EventLogStorage
- func (s *EventLogStorage[Ent, ID]) BeginTx(ctx context.Context) (context.Context, error)
- func (s *EventLogStorage[Ent, ID]) CommitTx(ctx context.Context) error
- func (s *EventLogStorage[Ent, ID]) Compress()
- func (s *EventLogStorage[Ent, ID]) Create(ctx context.Context, ptr *Ent) error
- func (s *EventLogStorage[Ent, ID]) DeleteAll(ctx context.Context) error
- func (s *EventLogStorage[Ent, ID]) DeleteByID(ctx context.Context, id ID) error
- func (s *EventLogStorage[Ent, ID]) Events(ctx context.Context) []EventLogStorageEvent[Ent, ID]
- func (s *EventLogStorage[Ent, ID]) FindAll(ctx context.Context) iterators.Iterator[Ent]
- func (s *EventLogStorage[Ent, ID]) FindByID(ctx context.Context, id ID) (_ent Ent, _found bool, _err error)
- func (s *EventLogStorage[Ent, ID]) FindByIDs(ctx context.Context, ids ...ID) iterators.Iterator[Ent]
- func (s *EventLogStorage[Ent, ID]) GetNamespace() string
- func (s *EventLogStorage[Ent, ID]) LookupTx(ctx context.Context) (*EventLogTx, bool)
- func (s *EventLogStorage[Ent, ID]) RollbackTx(ctx context.Context) error
- func (s *EventLogStorage[Ent, ID]) SubscribeToCreate(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
- func (s *EventLogStorage[Ent, ID]) SubscribeToCreatorEvents(ctx context.Context, subscriber pubsub.CreatorSubscriber[Ent]) (pubsub.Subscription, error)
- func (s *EventLogStorage[Ent, ID]) SubscribeToDeleteAll(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
- func (s *EventLogStorage[Ent, ID]) SubscribeToDeleteByID(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
- func (s *EventLogStorage[Ent, ID]) SubscribeToDeleterEvents(ctx context.Context, subscriber pubsub.DeleterSubscriber[ID]) (pubsub.Subscription, error)
- func (s *EventLogStorage[Ent, ID]) SubscribeToUpdate(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
- func (s *EventLogStorage[Ent, ID]) SubscribeToUpdaterEvents(ctx context.Context, subscriber pubsub.UpdaterSubscriber[Ent]) (pubsub.Subscription, error)
- func (s *EventLogStorage[Ent, ID]) Update(ctx context.Context, ptr *Ent) error
- func (s *EventLogStorage[Ent, ID]) Upsert(ctx context.Context, ptrs ...*Ent) (rErr error)
- func (s *EventLogStorage[Ent, ID]) View(ctx context.Context) StorageView[Ent, ID]
- type EventLogStorageEvent
- type EventLogSubscriber
- type EventLogTx
- type EventManager
- type EventViewer
- type Memory
- func (m *Memory) All(T any, ctx context.Context, namespace string) (sliceOfT interface{})
- func (m *Memory) BeginTx(ctx context.Context) (context.Context, error)
- func (m *Memory) CommitTx(ctx context.Context) error
- func (m *Memory) Del(ctx context.Context, namespace string, key string) bool
- func (m *Memory) Get(ctx context.Context, namespace string, key string) (interface{}, bool)
- func (m *Memory) LookupMeta(ctx context.Context, key string, ptr interface{}) (_found bool, _err error)
- func (m *Memory) LookupTx(ctx context.Context) (*MemoryTx, bool)
- func (m *Memory) RollbackTx(ctx context.Context) error
- func (m *Memory) Set(ctx context.Context, namespace, key string, value interface{})
- func (m *Memory) SetMeta(ctx context.Context, key string, value interface{}) (context.Context, error)
- type MemoryNamespace
- type MemoryTx
- type Stack
- type Storage
- func (s *Storage[Ent, ID]) Create(ctx context.Context, ptr *Ent) error
- func (s *Storage[Ent, ID]) DeleteAll(ctx context.Context) error
- func (s *Storage[Ent, ID]) DeleteByID(ctx context.Context, id ID) error
- func (s *Storage[Ent, ID]) FindAll(ctx context.Context) iterators.Iterator[Ent]
- func (s *Storage[Ent, ID]) FindByID(ctx context.Context, id ID) (_ent Ent, _found bool, _err error)
- func (s *Storage[Ent, ID]) FindByIDs(ctx context.Context, ids ...ID) iterators.Iterator[Ent]
- func (s *Storage[Ent, ID]) GetNamespace() string
- func (s *Storage[Ent, ID]) IDToMemoryKey(id any) string
- func (s *Storage[Ent, ID]) MakeID(ctx context.Context) (ID, error)
- func (s *Storage[Ent, ID]) Update(ctx context.Context, ptr *Ent) error
- func (s *Storage[Ent, ID]) Upsert(ctx context.Context, ptrs ...*Ent) error
- type StorageView
- type Subscription
- type Traceable
Constants ¶
View Source
const ( CreateEvent = `Create` UpdateEvent = `Update` DeleteAllEvent = `DeleteAll` DeleteByIDEvent = `DeleteByID` )
Name Types
Variables ¶
This section is empty.
Functions ¶
func LogHistoryOnFailure ¶
func LogHistoryOnFailure(tb testingTB, el EventViewer)
func RewriteEventLog ¶
Types ¶
type EventLog ¶
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 ¶
func NewEventLog() *EventLog
func (*EventLog) LookupMeta ¶
func (*EventLog) Subscribe ¶
func (el *EventLog) Subscribe(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
type EventLogEvent ¶
func (EventLogEvent) GetTrace ¶
func (et EventLogEvent) GetTrace() []Stack
func (EventLogEvent) SetTrace ¶
func (et EventLogEvent) SetTrace(trace []Stack)
func (EventLogEvent) String ¶
func (et EventLogEvent) String() string
type EventLogStorage ¶
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 ¶
func NewEventLogStorage[Ent, ID any](m *EventLog) *EventLogStorage[Ent, ID]
func NewEventLogStorageWithNamespace ¶
func NewEventLogStorageWithNamespace[Ent, ID any](m *EventLog, ns string) *EventLogStorage[Ent, ID]
func (*EventLogStorage[Ent, ID]) CommitTx ¶
func (s *EventLogStorage[Ent, ID]) CommitTx(ctx context.Context) error
func (*EventLogStorage[Ent, ID]) Compress ¶
func (s *EventLogStorage[Ent, ID]) Compress()
func (*EventLogStorage[Ent, ID]) Create ¶
func (s *EventLogStorage[Ent, ID]) Create(ctx context.Context, ptr *Ent) error
func (*EventLogStorage[Ent, ID]) DeleteAll ¶
func (s *EventLogStorage[Ent, ID]) DeleteAll(ctx context.Context) error
func (*EventLogStorage[Ent, ID]) DeleteByID ¶
func (s *EventLogStorage[Ent, ID]) DeleteByID(ctx context.Context, id ID) error
func (*EventLogStorage[Ent, ID]) Events ¶
func (s *EventLogStorage[Ent, ID]) Events(ctx context.Context) []EventLogStorageEvent[Ent, ID]
func (*EventLogStorage[Ent, ID]) FindAll ¶
func (s *EventLogStorage[Ent, ID]) FindAll(ctx context.Context) iterators.Iterator[Ent]
func (*EventLogStorage[Ent, ID]) FindByID ¶
func (s *EventLogStorage[Ent, ID]) FindByID(ctx context.Context, id ID) (_ent Ent, _found bool, _err error)
func (*EventLogStorage[Ent, ID]) FindByIDs ¶
func (s *EventLogStorage[Ent, ID]) FindByIDs(ctx context.Context, ids ...ID) iterators.Iterator[Ent]
func (*EventLogStorage[Ent, ID]) GetNamespace ¶
func (s *EventLogStorage[Ent, ID]) GetNamespace() string
func (*EventLogStorage[Ent, ID]) LookupTx ¶
func (s *EventLogStorage[Ent, ID]) LookupTx(ctx context.Context) (*EventLogTx, bool)
func (*EventLogStorage[Ent, ID]) RollbackTx ¶
func (s *EventLogStorage[Ent, ID]) RollbackTx(ctx context.Context) error
func (*EventLogStorage[Ent, ID]) SubscribeToCreate ¶
func (s *EventLogStorage[Ent, ID]) SubscribeToCreate(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
func (*EventLogStorage[Ent, ID]) SubscribeToCreatorEvents ¶
func (s *EventLogStorage[Ent, ID]) SubscribeToCreatorEvents(ctx context.Context, subscriber pubsub.CreatorSubscriber[Ent]) (pubsub.Subscription, error)
func (*EventLogStorage[Ent, ID]) SubscribeToDeleteAll ¶
func (s *EventLogStorage[Ent, ID]) SubscribeToDeleteAll(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
func (*EventLogStorage[Ent, ID]) SubscribeToDeleteByID ¶
func (s *EventLogStorage[Ent, ID]) SubscribeToDeleteByID(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
func (*EventLogStorage[Ent, ID]) SubscribeToDeleterEvents ¶
func (s *EventLogStorage[Ent, ID]) SubscribeToDeleterEvents(ctx context.Context, subscriber pubsub.DeleterSubscriber[ID]) (pubsub.Subscription, error)
func (*EventLogStorage[Ent, ID]) SubscribeToUpdate ¶
func (s *EventLogStorage[Ent, ID]) SubscribeToUpdate(ctx context.Context, subscriber EventLogSubscriber) (pubsub.Subscription, error)
func (*EventLogStorage[Ent, ID]) SubscribeToUpdaterEvents ¶
func (s *EventLogStorage[Ent, ID]) SubscribeToUpdaterEvents(ctx context.Context, subscriber pubsub.UpdaterSubscriber[Ent]) (pubsub.Subscription, error)
func (*EventLogStorage[Ent, ID]) Update ¶
func (s *EventLogStorage[Ent, ID]) Update(ctx context.Context, ptr *Ent) error
func (*EventLogStorage[Ent, ID]) Upsert ¶
func (s *EventLogStorage[Ent, ID]) Upsert(ctx context.Context, ptrs ...*Ent) (rErr error)
func (*EventLogStorage[Ent, ID]) View ¶
func (s *EventLogStorage[Ent, ID]) View(ctx context.Context) StorageView[Ent, ID]
type EventLogStorageEvent ¶
type EventLogStorageEvent[Ent, ID any] struct { Namespace string Name string Value Ent Trace []Stack }
func (EventLogStorageEvent[Ent, ID]) GetTrace ¶
func (e EventLogStorageEvent[Ent, ID]) GetTrace() []Stack
func (EventLogStorageEvent[Ent, ID]) SetTrace ¶
func (e EventLogStorageEvent[Ent, ID]) SetTrace(trace []Stack)
func (EventLogStorageEvent[Ent, ID]) String ¶
func (e EventLogStorageEvent[Ent, ID]) String() string
type EventLogSubscriber ¶
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 ¶
type EventLogTx struct {
// contains filtered or unexported fields
}
func (*EventLogTx) Events ¶
func (tx *EventLogTx) Events() []Event
type EventManager ¶
type EventManager interface { Append(context.Context, Event) error EventViewer }
type EventViewer ¶
type EventViewer interface {
Events() []Event
}
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
func (*Memory) LookupMeta ¶
type MemoryNamespace ¶
type MemoryNamespace map[string]interface{}
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 NewStorageWithNamespace ¶
func (*Storage[Ent, ID]) DeleteByID ¶
func (*Storage[Ent, ID]) GetNamespace ¶
func (*Storage[Ent, ID]) IDToMemoryKey ¶
type StorageView ¶
func (StorageView[Ent, ID]) FindByID ¶
func (v StorageView[Ent, ID]) FindByID(id ID) (Ent, bool)
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
func (*Subscription) Close ¶
func (s *Subscription) Close() (rErr error)
Click to show internal directories.
Click to hide internal directories.