typed

package
v0.0.0-...-9753c4d Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithTypedTx

func WithTypedTx[T any, PT message[T]](ctx context.Context, db protodb.TxProvider, fn func(ctx context.Context, tx Tx[T, PT]) error, opts ...protodb.TxOption) error

func WithTypedTx2

func WithTypedTx2[T any, PT message[T], R any](ctx context.Context, db protodb.TxProvider, fn func(ctx context.Context, tx Tx[T, PT]) (R, error), opts ...protodb.TxOption) (R, error)

Types

type Event

type Event[T any, PT message[T]] interface {
	Type() protodb.EventType
	Old() PT
	New() PT
	Err() error
}

type Reader

type Reader[T any, PT message[T]] interface {
	Get(ctx context.Context, m PT, opts ...protodb.GetOption) ([]PT, *protodb.PagingInfo, error)
}

type Store

type Store[T any, PT message[T]] interface {
	Reader[T, PT]
	Writer[T, PT]
	Watcher[T, PT]
	TxProvider[T, PT]

	Register(ctx context.Context) error

	Raw() client.Client
}

func NewStore

func NewStore[T any, PT message[T]](c client.Client) Store[T, PT]

type Tx

type Tx[T any, PT message[T]] interface {
	protodb.Committer
	Reader[T, PT]
	Writer[T, PT]
	Raw() protodb.Tx
}

func NewTx

func NewTx[T any, PT message[T]](txn protodb.Tx) Tx[T, PT]

type TxProvider

type TxProvider[T any, PT message[T]] interface {
	Tx(ctx context.Context) (Tx[T, PT], error)
}

type Watcher

type Watcher[T any, PT message[T]] interface {
	Watch(ctx context.Context, m PT, opts ...protodb.GetOption) (<-chan Event[T, PT], error)
}

type Writer

type Writer[T any, PT message[T]] interface {
	Set(ctx context.Context, m PT, opts ...protodb.SetOption) (PT, error)
	Delete(ctx context.Context, m PT) error
}

Jump to

Keyboard shortcuts

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