store

package
v0.39.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OnPersist  = MetadataHookKind("persist")
	OnRetrieve = MetadataHookKind("retrieve")
)
View Source
const MetaColumnPrefix = "meta_"

Variables

View Source
var ErrResumeTokenNotFound = errors.New("resume token not found")

Functions

This section is empty.

Types

type AggregateMetadata added in v0.28.0

type AggregateMetadata[K eventsourcing.ID] struct {
	Type      eventsourcing.Kind
	ID        K
	Version   uint32
	UpdatedAt time.Time
}

type EventBus added in v0.28.0

type EventBus[K eventsourcing.ID] struct {
	// contains filtered or unexported fields
}

func New added in v0.28.0

func New[K eventsourcing.ID](mw ...EventBusMW[K]) *EventBus[K]

func (*EventBus[K]) Publish added in v0.29.0

func (m *EventBus[K]) Publish(ctx context.Context, events ...*eventsourcing.Event[K]) error

func (*EventBus[K]) Subscribe added in v0.29.0

func (m *EventBus[K]) Subscribe(filter string, handler Subscription[K], mw ...EventBusMW[K])

Subscribe register an handler subscription. The middlewares are executed in the reverse order

type EventBusMW added in v0.28.0

type EventBusMW[K eventsourcing.ID] func(Subscription[K]) Subscription[K]

type Filter

type Filter struct {
	AggregateKinds []eventsourcing.Kind
	// Metadata filters on top of metadata. Every key of the map is ANDed with every OR of the values
	// eg: [{"geo": "EU"}, {"geo": "USA"}, {"membership": "prime"}] equals to:  geo IN ("EU", "USA") AND membership = "prime"
	Metadata MetadataFilter
	Splits   uint32
	SplitIDs []uint32
}

type FilterOption

type FilterOption func(*Filter)

func WithAggregateKinds added in v0.28.0

func WithAggregateKinds(at ...eventsourcing.Kind) FilterOption

func WithFilter

func WithFilter(filter Filter) FilterOption

func WithMetadata

func WithMetadata(metadata MetadataFilter) FilterOption

func WithMetadataFilter added in v0.36.0

func WithMetadataFilter(key, value string) FilterOption

func WithSplits added in v0.36.0

func WithSplits(partitions uint32, partitionIDs []uint32) FilterOption

type InTxHandler added in v0.34.0

type InTxHandler[K eventsourcing.ID] func(*InTxHandlerContext[K]) error

type InTxHandlerContext added in v0.39.0

type InTxHandlerContext[K eventsourcing.ID] struct {
	// contains filtered or unexported fields
}

func NewInTxHandlerContext added in v0.39.0

func NewInTxHandlerContext[K eventsourcing.ID](ctx context.Context, event *eventsourcing.Event[K]) *InTxHandlerContext[K]

func (*InTxHandlerContext[K]) Context added in v0.39.0

func (c *InTxHandlerContext[K]) Context() context.Context

func (*InTxHandlerContext[K]) Event added in v0.39.0

func (c *InTxHandlerContext[K]) Event() *eventsourcing.Event[K]

type KVRStore added in v0.34.0

type KVRStore interface {
	// Get retrieves the stored value for a key.
	// If the a resume key is not found it return ErrResumeTokenNotFound as an error
	Get(ctx context.Context, key string) (string, error)
}

type KVStore added in v0.34.0

type KVStore interface {
	KVRStore
	KVWStore
}

type KVWStore added in v0.34.0

type KVWStore interface {
	Put(ctx context.Context, key string, token string) error
}

type Metadata

type Metadata struct {
	Key   string
	Value string
}

type MetadataFilter added in v0.36.0

type MetadataFilter []*MetadataKVs

func (*MetadataFilter) Add added in v0.36.0

func (m *MetadataFilter) Add(key string, values ...string)

type MetadataHook added in v0.36.0

type MetadataHookContext added in v0.39.0

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

func NewMetadataHookContext added in v0.39.0

func NewMetadataHookContext(ctx context.Context, kind MetadataHookKind) *MetadataHookContext

func (*MetadataHookContext) Context added in v0.39.0

func (c *MetadataHookContext) Context() context.Context

func (*MetadataHookContext) Kind added in v0.39.0

type MetadataHookKind added in v0.39.0

type MetadataHookKind string

type MetadataKVs added in v0.36.0

type MetadataKVs struct {
	Key    string
	Values []string
}

type NilString added in v0.36.0

type NilString string

NilString converts nil to empty string

func (*NilString) Scan added in v0.36.0

func (ns *NilString) Scan(value interface{}) error

func (NilString) Value added in v0.36.0

func (ns NilString) Value() (driver.Value, error)

type Repository added in v0.39.0

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

func NewRepository added in v0.39.0

func NewRepository(db *sqlx.DB) Repository

func (*Repository) Session added in v0.39.0

func (r *Repository) Session(ctx context.Context) Session

Session will check if there is a transaction in context and use it, otherwise it will use the current pool

func (Repository) TxRunner added in v0.39.0

func (r Repository) TxRunner() Tx

func (*Repository) WithTx added in v0.39.0

func (r *Repository) WithTx(ctx context.Context, fn func(context.Context, Session) error) error

type Row added in v0.36.0

type Row map[string]interface{}

func (Row) AsBool added in v0.36.0

func (r Row) AsBool(colName string) bool

func (Row) AsBytes added in v0.36.0

func (r Row) AsBytes(colName string) []byte

func (Row) AsString added in v0.36.0

func (r Row) AsString(colName string) string

func (Row) AsTimeDate added in v0.36.0

func (r Row) AsTimeDate(colName string) time.Time

func (Row) AsUint32 added in v0.36.0

func (r Row) AsUint32(colName string) uint32

type Session added in v0.39.0

type Session interface {
	Rebind(query string) string
	GetContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	SelectContext(ctx context.Context, dest interface{}, query string, args ...interface{}) error
	QueryxContext(ctx context.Context, query string, args ...any) (*sqlx.Rows, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

func TxFromContext added in v0.39.0

func TxFromContext(ctx context.Context) Session

type Subscriber added in v0.28.0

type Subscriber[K eventsourcing.ID] interface {
	Subscribe(string, Subscription[K])
}

type Subscription added in v0.28.0

type Subscription[K eventsourcing.ID] func(context.Context, *eventsourcing.Event[K]) error

type Tx added in v0.39.0

type Tx func(ctx context.Context, fn func(context.Context) error) error

func TxRunner added in v0.39.0

func TxRunner(db *sqlx.DB) Tx

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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