inmemory

package
v0.33.2 Latest Latest
Warning

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

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

Documentation

Index

Examples

Constants

View Source
const (
	BeginTxEvent    = `BeginTx`
	CommitTxEvent   = `CommitTx`
	RollbackTxEvent = `RollbackTx`
	CreateEvent     = `Create`
	UpdateEvent     = `Update`
	DeleteAllEvent  = `DeleteAll`
	DeleteByIDEvent = `DeleteByID`
)

Variables

This section is empty.

Functions

This section is empty.

Types

type IDGenerator

type IDGenerator map[string]func() (interface{}, error)

func (*IDGenerator) Register

func (g *IDGenerator) Register(T frameless.T, genFunc func() (interface{}, error))

type MemoryEvent

type MemoryEvent struct {
	T              interface{}
	EntityTypeName string
	Event          string
	ID             interface{}
	Entity         interface{}
	Trace          []TraceElem
}

type MemoryEventManager

type MemoryEventManager interface {
	AddEvent(MemoryEvent)
	MemoryEventViewer
}

type MemoryEventViewer

type MemoryEventViewer interface {
	Events() []MemoryEvent
}

type MemoryTableView

type MemoryTableView map[string]interface{} // id => entity <T>

func (MemoryTableView) FindByID

func (v MemoryTableView) FindByID(id interface{}) interface{}

type MemoryTransaction

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

func (*MemoryTransaction) AddEvent

func (tx *MemoryTransaction) AddEvent(event MemoryEvent)

func (*MemoryTransaction) Events

func (tx *MemoryTransaction) Events() []MemoryEvent

func (*MemoryTransaction) View

func (tx *MemoryTransaction) View() MemoryView

func (*MemoryTransaction) ViewFor

func (tx *MemoryTransaction) ViewFor(T interface{}) MemoryTableView

type MemoryView

type MemoryView map[string]MemoryTableView // entity type name => table view

type Storage

type Storage struct {
	T       interface{}
	Options struct {
		DisableEventLogging                  bool
		DisableAsyncSubscriptionHandling     bool
		DisableRelativePathResolvingForTrace bool
	}
	// contains filtered or unexported fields
}

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

Example
inmemory2.NewStorage(Entity{})
Output:

func NewStorage

func NewStorage(T interface{}) *Storage

func (*Storage) AddEvent

func (s *Storage) AddEvent(event MemoryEvent)

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) 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) EntityTypeNameFor

func (s *Storage) EntityTypeNameFor(T interface{}) string

func (*Storage) Events

func (s *Storage) Events() []MemoryEvent

func (*Storage) FindAll

func (s *Storage) FindAll(ctx context.Context) iterators.Interface

func (*Storage) FindByID

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

func (*Storage) IDGenerator

func (s *Storage) IDGenerator() *IDGenerator

func (*Storage) InTx

func (s *Storage) InTx(ctx context.Context, fn func(tx *MemoryTransaction) error) error

func (*Storage) LogContextHistory

func (s *Storage) LogContextHistory(l logger, ctx context.Context)

func (*Storage) LogHistory

func (s *Storage) LogHistory(l logger)

func (*Storage) LookupTx

func (s *Storage) LookupTx(ctx context.Context) (*MemoryTransaction, 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

type TraceElem

type TraceElem struct {
	Path string
	Line int
}

Jump to

Keyboard shortcuts

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