monsterax

package
v0.0.0-...-272483c Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 18 Imported by: 11

Documentation

Index

Constants

View Source
const (
	OK                = ErrorCode_OK
	InvalidArgument   = ErrorCode_INVALID_ARGUMENT
	DeadlineExceeded  = ErrorCode_DEADLINE_EXCEEDED
	NotFound          = ErrorCode_NOT_FOUND
	AlreadyExists     = ErrorCode_ALREADY_EXISTS
	ResourceExhausted = ErrorCode_RESOURCE_EXHAUSTED
	Unimplemented     = ErrorCode_UNIMPLEMENTED
	Internal          = ErrorCode_INTERNAL
)

Variables

View Source
var (
	ErrorCode_name = map[int32]string{
		0: "INVALID",
		1: "OK",
		2: "INVALID_ARGUMENT",
		3: "DEADLINE_EXCEEDED",
		4: "NOT_FOUND",
		5: "ALREADY_EXISTS",
		6: "RESOURCE_EXHAUSTED",
		7: "UNIMPLEMENTED",
		8: "INTERNAL",
	}
	ErrorCode_value = map[string]int32{
		"INVALID":            0,
		"OK":                 1,
		"INVALID_ARGUMENT":   2,
		"DEADLINE_EXCEEDED":  3,
		"NOT_FOUND":          4,
		"ALREADY_EXISTS":     5,
		"RESOURCE_EXHAUSTED": 6,
		"UNIMPLEMENTED":      7,
		"INTERNAL":           8,
	}
)

Enum value maps for ErrorCode.

View Source
var File_x_response_proto protoreflect.FileDescriptor

Functions

func ErrorToGRPC

func ErrorToGRPC(err error) error

func MeasureSince

func MeasureSince(o prometheus.Observer, t1 time.Time)

func ReadProtoMessageFromStream

func ReadProtoMessageFromStream[T ptr[U], U any](r io.Reader) (T, error)

func ReadUint32FromStream

func ReadUint32FromStream(r io.Reader) (uint32, error)

func Restore

func Restore(s *store.BadgerStore, ranges []KeyRange, reader io.ReadCloser) error

func WriteProtoMessageIntoStream

func WriteProtoMessageIntoStream(w io.Writer, msg encoding.BinaryMarshaler) error

func WriteUint32IntoStream

func WriteUint32IntoStream(w io.Writer, i uint32) error

Types

type BadgerStoreSnapshot

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

func Snapshot

func Snapshot(s *store.BadgerStore, ranges []KeyRange) BadgerStoreSnapshot

func (BadgerStoreSnapshot) Release

func (s BadgerStoreSnapshot) Release()

func (BadgerStoreSnapshot) Write

func (s BadgerStoreSnapshot) Write(w io.Writer) error

type BinaryTable

type BinaryTable[T ptr[U], U any] struct {
	// contains filtered or unexported fields
}

BinaryTable is table with a composite key: primary key PK and secondary key SK and generic values (of encoding.BinaryMarshaler type). Get, Set, Delete operations use PK+SK to refer records. List operation uses PK as a prefix.

func NewBinaryTable

func NewBinaryTable[T ptr[U], U any](tableId []byte, keyLowerBound []byte, keyUpperBound []byte) *BinaryTable[T, U]

func (*BinaryTable[T, U]) Delete

func (t *BinaryTable[T, U]) Delete(txn *store.Txn, key []byte) error

func (*BinaryTable[T, U]) Get

func (t *BinaryTable[T, U]) Get(txn *store.Txn, key []byte) (T, error)

func (*BinaryTable) GetTableKeyRange

func (t *BinaryTable) GetTableKeyRange() KeyRange

func (*BinaryTable[T, U]) ListAll

func (t *BinaryTable[T, U]) ListAll(txn *store.Txn, prefix []byte) ([]T, error)

func (*BinaryTable[T, U]) ListInRange

func (t *BinaryTable[T, U]) ListInRange(txn *store.Txn, lowerBound []byte, upperBound []byte, reverse bool, fn func(message T) (bool, error)) error

func (*BinaryTable[T, U]) ListPaginated

func (t *BinaryTable[T, U]) ListPaginated(txn *store.Txn, prefix []byte, paginationToken *PaginationToken, limit int) (*ListPaginatedProtobufResult[T, U], error)

func (*BinaryTable[T, U]) Set

func (t *BinaryTable[T, U]) Set(txn *store.Txn, key []byte, message T) error

type Error

type Error struct {
	Code    ErrorCode       `protobuf:"varint,1,opt,name=code,proto3,enum=com.evrblk.monstera.monsterax.ErrorCode" json:"code,omitempty"`
	Message string          `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	Context []*ErrorContext `protobuf:"bytes,3,rep,name=context,proto3" json:"context,omitempty"`
	// contains filtered or unexported fields
}

func NewError

func NewError(code ErrorCode, message string) *Error

func NewErrorWithContext

func NewErrorWithContext(code ErrorCode, message string, context map[string]string) *Error

func WrapError

func WrapError(err error) *Error

func (*Error) Descriptor deprecated

func (*Error) Descriptor() ([]byte, []int)

Deprecated: Use Error.ProtoReflect.Descriptor instead.

func (*Error) Error

func (e *Error) Error() string

func (*Error) GetCode

func (x *Error) GetCode() ErrorCode

func (*Error) GetContext

func (x *Error) GetContext() []*ErrorContext

func (*Error) GetMessage

func (x *Error) GetMessage() string

func (*Error) MarshalToSizedBufferVT

func (m *Error) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Error) MarshalToVT

func (m *Error) MarshalToVT(dAtA []byte) (int, error)

func (*Error) MarshalVT

func (m *Error) MarshalVT() (dAtA []byte, err error)

func (*Error) ProtoMessage

func (*Error) ProtoMessage()

func (*Error) ProtoReflect

func (x *Error) ProtoReflect() protoreflect.Message

func (*Error) Reset

func (x *Error) Reset()

func (*Error) SizeVT

func (m *Error) SizeVT() (n int)

func (*Error) String

func (x *Error) String() string

func (*Error) UnmarshalVT

func (m *Error) UnmarshalVT(dAtA []byte) error

type ErrorCode

type ErrorCode int32
const (
	ErrorCode_INVALID            ErrorCode = 0
	ErrorCode_OK                 ErrorCode = 1
	ErrorCode_INVALID_ARGUMENT   ErrorCode = 2
	ErrorCode_DEADLINE_EXCEEDED  ErrorCode = 3
	ErrorCode_NOT_FOUND          ErrorCode = 4
	ErrorCode_ALREADY_EXISTS     ErrorCode = 5
	ErrorCode_RESOURCE_EXHAUSTED ErrorCode = 6
	ErrorCode_UNIMPLEMENTED      ErrorCode = 7
	ErrorCode_INTERNAL           ErrorCode = 8
)

func (ErrorCode) Descriptor

func (ErrorCode) Descriptor() protoreflect.EnumDescriptor

func (ErrorCode) Enum

func (x ErrorCode) Enum() *ErrorCode

func (ErrorCode) EnumDescriptor deprecated

func (ErrorCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use ErrorCode.Descriptor instead.

func (ErrorCode) Number

func (x ErrorCode) Number() protoreflect.EnumNumber

func (ErrorCode) String

func (x ErrorCode) String() string

func (ErrorCode) Type

type ErrorContext

type ErrorContext struct {
	Key   string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
	Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
	// contains filtered or unexported fields
}

func (*ErrorContext) Descriptor deprecated

func (*ErrorContext) Descriptor() ([]byte, []int)

Deprecated: Use ErrorContext.ProtoReflect.Descriptor instead.

func (*ErrorContext) GetKey

func (x *ErrorContext) GetKey() string

func (*ErrorContext) GetValue

func (x *ErrorContext) GetValue() string

func (*ErrorContext) MarshalToSizedBufferVT

func (m *ErrorContext) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*ErrorContext) MarshalToVT

func (m *ErrorContext) MarshalToVT(dAtA []byte) (int, error)

func (*ErrorContext) MarshalVT

func (m *ErrorContext) MarshalVT() (dAtA []byte, err error)

func (*ErrorContext) ProtoMessage

func (*ErrorContext) ProtoMessage()

func (*ErrorContext) ProtoReflect

func (x *ErrorContext) ProtoReflect() protoreflect.Message

func (*ErrorContext) Reset

func (x *ErrorContext) Reset()

func (*ErrorContext) SizeVT

func (m *ErrorContext) SizeVT() (n int)

func (*ErrorContext) String

func (x *ErrorContext) String() string

func (*ErrorContext) UnmarshalVT

func (m *ErrorContext) UnmarshalVT(dAtA []byte) error

type KeyRange

type KeyRange struct {
	Lower []byte
	Upper []byte
}

type ListPaginatedProtobufResult

type ListPaginatedProtobufResult[T ptr[U], U any] struct {
	Items                   []T
	NextPaginationToken     *PaginationToken
	PreviousPaginationToken *PaginationToken
}

type ListPaginatedStringResult

type ListPaginatedStringResult struct {
	Items                   []string
	NextPaginationToken     *PaginationToken
	PreviousPaginationToken *PaginationToken
}

type ListPaginatedUint32Result

type ListPaginatedUint32Result struct {
	Items                   []uint32
	NextPaginationToken     *PaginationToken
	PreviousPaginationToken *PaginationToken
}

type ListPaginatedUint64Result

type ListPaginatedUint64Result struct {
	Items                   []uint64
	NextPaginationToken     *PaginationToken
	PreviousPaginationToken *PaginationToken
}

type OneToManySortedIndex

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

OneToManySortedIndex stores multiple items (arbitrary []byte) per single key PK (arbitrary []byte).

func NewOneToManySortedIndex

func NewOneToManySortedIndex(tableId []byte, keyLowerBound []byte, keyUpperBound []byte) *OneToManySortedIndex

func (*OneToManySortedIndex) Add

func (i *OneToManySortedIndex) Add(txn *store.Txn, pk []byte, item []byte) error

func (*OneToManySortedIndex) Delete

func (i *OneToManySortedIndex) Delete(txn *store.Txn, pk []byte, item []byte) error

func (*OneToManySortedIndex) GetTableKeyRange

func (t *OneToManySortedIndex) GetTableKeyRange() KeyRange

func (*OneToManySortedIndex) ListAll

func (i *OneToManySortedIndex) ListAll(txn *store.Txn, pk []byte, fn func(item []byte) (bool, error)) error

func (*OneToManySortedIndex) ListInRange

func (i *OneToManySortedIndex) ListInRange(txn *store.Txn, pk []byte, lowerBound []byte, upperBound []byte, fn func(item []byte) (bool, error)) error

type OneToManyUint64Index

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

OneToManyUint64Index stores multiple items (uint64) per single key PK (arbitrary []byte).

func NewOneToManyUint64Index

func NewOneToManyUint64Index(tableId []byte, keyLowerBound []byte, keyUpperBound []byte) *OneToManyUint64Index

func (*OneToManyUint64Index) Add

func (i *OneToManyUint64Index) Add(txn *store.Txn, pk []byte, item uint64) error

func (*OneToManyUint64Index) Delete

func (i *OneToManyUint64Index) Delete(txn *store.Txn, pk []byte, item uint64) error

func (*OneToManyUint64Index) GetTableKeyRange

func (t *OneToManyUint64Index) GetTableKeyRange() KeyRange

func (*OneToManyUint64Index) List

func (i *OneToManyUint64Index) List(txn *store.Txn, pk []byte, fn func(item uint64) (bool, error)) error

func (*OneToManyUint64Index) NotEmpty

func (i *OneToManyUint64Index) NotEmpty(txn *store.Txn, pk []byte) (bool, error)

type PaginationToken

type PaginationToken struct {
	Key     []byte
	Reverse bool
}

type Response

type Response struct {
	Data  []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
	Error *Error `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"`
	// contains filtered or unexported fields
}

func (*Response) Descriptor deprecated

func (*Response) Descriptor() ([]byte, []int)

Deprecated: Use Response.ProtoReflect.Descriptor instead.

func (*Response) GetData

func (x *Response) GetData() []byte

func (*Response) GetError

func (x *Response) GetError() *Error

func (*Response) MarshalToSizedBufferVT

func (m *Response) MarshalToSizedBufferVT(dAtA []byte) (int, error)

func (*Response) MarshalToVT

func (m *Response) MarshalToVT(dAtA []byte) (int, error)

func (*Response) MarshalVT

func (m *Response) MarshalVT() (dAtA []byte, err error)

func (*Response) ProtoMessage

func (*Response) ProtoMessage()

func (*Response) ProtoReflect

func (x *Response) ProtoReflect() protoreflect.Message

func (*Response) Reset

func (x *Response) Reset()

func (*Response) SizeVT

func (m *Response) SizeVT() (n int)

func (*Response) String

func (x *Response) String() string

func (*Response) UnmarshalVT

func (m *Response) UnmarshalVT(dAtA []byte) error

type SortedIndex

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

SortedIndex stores multiple sorted items (arbitrary []byte) without any PK (global index)

func NewSortedIndex

func NewSortedIndex(tableId []byte, keyLowerBound []byte, keyUpperBound []byte) *SortedIndex

func (*SortedIndex) Add

func (i *SortedIndex) Add(txn *store.Txn, item []byte) error

func (*SortedIndex) Delete

func (i *SortedIndex) Delete(txn *store.Txn, item []byte) error

func (*SortedIndex) GetTableKeyRange

func (i *SortedIndex) GetTableKeyRange() KeyRange

func (*SortedIndex) ListInRange

func (i *SortedIndex) ListInRange(txn *store.Txn, lowerBound []byte, upperBound []byte, fn func(item []byte) (bool, error)) error

type StringTable

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

StringTable is table with a composite key: primary key PK and secondary key SK and string values. Get, Set, Delete operations use PK+SK to refer records. List operation uses PK as a prefix.

func NewStringTable

func NewStringTable(tableId []byte, keyLowerBound []byte, keyUpperBound []byte) *StringTable

func (*StringTable) Delete

func (t *StringTable) Delete(txn *store.Txn, key []byte) error

func (*StringTable) Get

func (t *StringTable) Get(txn *store.Txn, key []byte) (string, error)

func (*StringTable) GetTableKeyRange

func (t *StringTable) GetTableKeyRange() KeyRange

func (*StringTable) ListAll

func (t *StringTable) ListAll(txn *store.Txn, prefix []byte) ([]string, error)

func (*StringTable) ListInRange

func (t *StringTable) ListInRange(txn *store.Txn, lowerBound []byte, upperBound []byte, reverse bool, fn func(value string) (bool, error)) error

func (*StringTable) ListPaginated

func (t *StringTable) ListPaginated(txn *store.Txn, prefix []byte, paginationToken *PaginationToken, limit int) (*ListPaginatedStringResult, error)

func (*StringTable) Set

func (t *StringTable) Set(txn *store.Txn, key []byte, value string) error

type Uint32Table

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

Uint32Table is table with a composite key: primary key PK and secondary key SK and uint32 values. Get, Set, Delete operations use PK+SK to refer records. List operation uses PK as a prefix.

func NewUint32Table

func NewUint32Table(tableId []byte, keyLowerBound []byte, keyUpperBound []byte) *Uint32Table

func (*Uint32Table) Delete

func (t *Uint32Table) Delete(txn *store.Txn, key []byte) error

func (*Uint32Table) Get

func (t *Uint32Table) Get(txn *store.Txn, key []byte) (uint32, error)

func (*Uint32Table) GetTableKeyRange

func (t *Uint32Table) GetTableKeyRange() KeyRange

func (*Uint32Table) ListAll

func (t *Uint32Table) ListAll(txn *store.Txn, prefix []byte) ([]uint32, error)

func (*Uint32Table) ListPaginated

func (t *Uint32Table) ListPaginated(txn *store.Txn, prefix []byte, paginationToken *PaginationToken, limit int) (*ListPaginatedUint32Result, error)

func (*Uint32Table) Set

func (t *Uint32Table) Set(txn *store.Txn, key []byte, value uint32) error

type Uint64Table

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

Uint64Table is table with a composite key: primary key PK and secondary key SK and uint64 values. Get, Set, Delete operations use PK+SK to refer records. List operation uses PK as a prefix.

func NewUint64Table

func NewUint64Table(tableId []byte, keyLowerBound []byte, keyUpperBound []byte) *Uint64Table

func (*Uint64Table) Delete

func (t *Uint64Table) Delete(txn *store.Txn, key []byte) error

func (*Uint64Table) Get

func (t *Uint64Table) Get(txn *store.Txn, key []byte) (uint64, error)

func (*Uint64Table) GetTableKeyRange

func (t *Uint64Table) GetTableKeyRange() KeyRange

func (*Uint64Table) ListAll

func (t *Uint64Table) ListAll(txn *store.Txn, prefix []byte) ([]uint64, error)

func (*Uint64Table) ListPaginated

func (t *Uint64Table) ListPaginated(txn *store.Txn, prefix []byte, paginationToken *PaginationToken, limit int) (*ListPaginatedUint64Result, error)

func (*Uint64Table) Set

func (t *Uint64Table) Set(txn *store.Txn, key []byte, value uint64) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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