protodb

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: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Data        = "_data"
	Index       = "_index"
	Descriptors = "_schema"
	Internal    = "_internal"
)
View Source
const (
	EventTypeUnknown = pb.WatchEventUnknown
	EventTypeEnter   = pb.WatchEventEnter
	EventTypeLeave   = pb.WatchEventLeave
	EventTypeUpdate  = pb.WatchEventUpdate
)

Variables

View Source
var (
	ErrNotLeader    = errors.New("current node is not leader")
	ErrNoLeaderConn = errors.New("no leader connection")
)

Functions

func DataPrefix

func DataPrefix(m proto.Message) (key []byte, field string, value string, err error)

func DescriptorPrefix

func DescriptorPrefix(d *descriptorpb.FileDescriptorProto) []byte

func KeyFor

func KeyFor(m proto.Message) (key string, field string, err error)

func KeyFromOpts

func KeyFromOpts(m proto.Message) (key string, field string, ok bool)

Types

type Committer

type Committer interface {
	Commit(ctx context.Context) error
	Close()
}

type Event

type Event interface {
	Type() EventType
	Old() proto.Message
	New() proto.Message
	Err() error
}

type EventType

type EventType = pb.WatchEventType

type Filter

type Filter = filters.FieldFilterer

type FilterExpr

type FilterExpr = filters.Expression

type GetOption

type GetOption func(o *GetOpts)

func WithFilter

func WithFilter(filter Filter) GetOption

func WithPaging

func WithPaging(paging *Paging) GetOption

func WithReadFieldMask

func WithReadFieldMask(fieldMask *fieldmaskpb.FieldMask) GetOption

func WithReadFieldMaskPaths

func WithReadFieldMaskPaths(paths ...string) GetOption

func WithReverse

func WithReverse() GetOption

type GetOpts

type GetOpts struct {
	Paging    *Paging
	Filter    Filter
	FieldMask *fieldmaskpb.FieldMask
	Reverse   bool
}

type Leader

type Leader interface {
	IsLeader() bool
	Leader() string
	LeaderChanges() <-chan string
}

type Logger

type Logger interface {
	Errorf(string, ...interface{})
	Warningf(string, ...interface{})
	Infof(string, ...interface{})
	Debugf(string, ...interface{})
	Tracef(string, ...interface{})
}

type Paging

type Paging = pb.Paging

type PagingInfo

type PagingInfo = pb.PagingInfo

type Reader

type Reader interface {
	Get(ctx context.Context, m proto.Message, opts ...GetOption) ([]proto.Message, *PagingInfo, error)
}

type Registerer

type Registerer interface {
	RegisterProto(ctx context.Context, file *descriptorpb.FileDescriptorProto) error
	Register(ctx context.Context, file protoreflect.FileDescriptor) error
	Descriptors(ctx context.Context) ([]*descriptorpb.DescriptorProto, error)
	FileDescriptors(ctx context.Context) ([]*descriptorpb.FileDescriptorProto, error)
}

type Resolverer

type Resolverer interface {
	Resolver() protodesc.Resolver
}

type SetOption

type SetOption func(o *SetOpts)

func WithTTL

func WithTTL(d time.Duration) SetOption

func WithWriteFieldMask

func WithWriteFieldMask(fieldMask *fieldmaskpb.FieldMask) SetOption

func WithWriteFieldMaskPaths

func WithWriteFieldMaskPaths(paths ...string) SetOption

type SetOpts

type SetOpts struct {
	TTL       time.Duration
	FieldMask *fieldmaskpb.FieldMask
}

type Tx

type Tx interface {
	Reader
	Writer
	Committer
}

type TxOption

type TxOption func(o *TxOpts)

func WithReadOnly

func WithReadOnly() TxOption

type TxOpts

type TxOpts struct {
	ReadOnly bool
}

type TxProvider

type TxProvider interface {
	Tx(ctx context.Context, opts ...TxOption) (Tx, error)
}

type Watcher

type Watcher interface {
	Watch(ctx context.Context, m proto.Message, opts ...GetOption) (<-chan Event, error)
}

type Writer

type Writer interface {
	Set(ctx context.Context, m proto.Message, opts ...SetOption) (proto.Message, error)
	Delete(ctx context.Context, m proto.Message) error
}

Jump to

Keyboard shortcuts

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