Documentation
¶
Index ¶
- Variables
- func All[D x.Document](desc bool, filters ...x.Filter) mo.Result[[]D]
- func Auth(authKey string) error
- func Connect(respAddr, authKey string) error
- func ConnectEmbedded() error
- func CountByIndex[D x.Document](idxName string, scopedKR x.KeyRange, filter x.Filter) mo.Result[int]
- func CountByKey[D x.Document](scopedKR x.KeyRange, filter x.Filter) mo.Result[int]
- func Delete[D x.Document](d D) (bool, error)
- func Get[D x.Document](key string) (D, error)
- func IsAuthFailed(err error) bool
- func IsNoAuth(err error) bool
- func IsNoPrivilege(err error) bool
- func IsNotConnected(err error) bool
- func IsNotFound(err error) bool
- func Keys[D x.Document](keyPattern string) mo.Result[[]string]
- func Publish(topic, msg string) bool
- func RegisterSchema[T x.Document](defs ...x.IndexDef) error
- func RemoveHook(id HookID)
- func SearchIndex[D x.Document](idxName string, scopedKR x.KeyRange, filter x.Filter, desc bool) mo.Result[[]D]
- func SearchKey[D x.Document](scopedKR x.KeyRange, filter x.Filter, desc bool) mo.Result[[]D]
- func Set[D x.Document](d D) error
- func SetHookTimeout(d time.Duration)
- func SetNX[D x.Document](d D) (bool, error)
- func SetNXWithTTL[D x.Document](d D, ttl time.Duration) (bool, error)
- func SetWithTTL[D x.Document](d D, ttl time.Duration) error
- func Subscribe(topic string) mo.Result[<-chan *ReceivedMessage]
- func Update[D x.Document](scopedKR x.KeyRange, filter x.Filter, values ...x.Mutation) mo.Result[[]string]
- type HookID
- func AddAbortHook(h func(key string, value []byte) error) HookID
- func AddObserverAfterHook(h func(key string, value []byte, committed bool, writeErr error)) HookID
- func AddObserverHook(h func(key string, value []byte)) HookID
- func AddTransformHook(h func(key string, value []byte) ([]byte, error)) HookID
- type ReceivedMessage
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = clienterrs.ErrNotFound ErrNotConnected = clienterrs.ErrNotConnected ErrAuthFailed = clienterrs.ErrAuthFailed ErrNoAuth = clienterrs.ErrNoAuth ErrNoPrivilege = clienterrs.ErrNoPrivilege ErrNamespaceNotRegistered = clienterrs.ErrNamespaceNotRegistered ErrIndexNotFound = clienterrs.ErrIndexNotFound ErrAuthKeyEmpty = clienterrs.ErrAuthKeyEmpty ErrKeyRangeRequired = clienterrs.ErrKeyRangeRequired ErrIndexNameRequired = clienterrs.ErrIndexNameRequired ErrNoUpdateValues = clienterrs.ErrNoUpdateValues ErrTopicEmpty = clienterrs.ErrTopicEmpty ErrDuplicatedHandler = clienterrs.ErrDuplicatedHandler ErrSubscriptionStopped = clienterrs.ErrSubscriptionStopped ErrSubscribeAckTimeout = clienterrs.ErrSubscribeAckTimeout )
Functions ¶
func All ¶ added in v0.1.16
All returns every document currently stored in namespace D.
It is pure sugar over SearchKey with the key range set to "<storageNs>:*" — as a direct consequence, ordering is by the **primary storage key** (namespace:pk concatenation) in lexicographic order: ascending when desc=false, descending when desc=true. Any number of optional Filter arguments are AND-combined together; passing none matches every row.
func ConnectEmbedded ¶ added in v0.1.15
func ConnectEmbedded() error
ConnectEmbedded starts the bridge lifecycle against the in-process embedded server. It reads the ctrl-port address set by server.StartWith via internal.CtrlAddr() and authenticates with the shared per-process internal.AuthKey(). Callers that have not booted an in-process server (or that want to dial a remote cross-process server) should use Connect() with an explicit address and auth key.
func CountByIndex ¶ added in v0.1.24
func CountByIndex[D x.Document](idxName string, scopedKR x.KeyRange, filter x.Filter) mo.Result[int]
CountByIndex returns how many documents in namespace D match the given secondary-index query.
func CountByKey ¶ added in v0.1.24
CountByKey returns how many documents in namespace D match the given primary storage-key range query.
func IsAuthFailed ¶ added in v0.1.24
func IsNoPrivilege ¶ added in v0.1.24
func IsNotConnected ¶ added in v0.1.24
func IsNotFound ¶ added in v0.1.24
func RegisterSchema ¶ added in v0.1.15
RegisterSchema registers a typed-document schema (and, optionally, its inline secondary indexes) on the connected server immediately, mirroring x.RegisterSchema's shape:
client.RegisterSchema[Order](x.IndexOn("ordid", OrdIDAttr))
It is a plain command against the current connection (like Set), so it must be called while connected. The server applies it idempotently: an unchanged schema spec is a no-op and an already-existing index is not recreated, so calling it repeatedly is always safe. When and how often to (re)declare — including anything like re-declaring after a reconnect — is the caller's concern, not this function's.
func RemoveHook ¶ added in v0.1.12
func RemoveHook(id HookID)
RemoveHook unregisters the hook with the given id; unknown ids are ignored.
func SearchIndex ¶
func SearchIndex[D x.Document](idxName string, scopedKR x.KeyRange, filter x.Filter, desc bool) mo.Result[[]D]
SearchIndex queries documents in namespace D through a secondary index.
Ordering is by the **indexed field value** (ascending when desc=false, descending when desc=true); ties within a single index value are broken by the primary storage key lexicographically. The passed KeyRange scopes which owner-document primary keys participate in the index scan; pass x.KeysPattern with "<ns>:*" to scan the whole namespace through the index. nil or empty filter is treated as "match every scanned row".
func SearchKey ¶
SearchKey queries documents in namespace D by primary storage-key range.
Ordering is by the **primary storage key** (namespace:pk concatenation) in lexicographic order — ascending when desc=false, descending when desc=true. nil or empty filter is treated as "return every row in the key range". Use x.Between, x.Prefix, x.KeysPattern or x.Key to build the scoped KeyRange.
func SetHookTimeout ¶ added in v0.1.12
SetHookTimeout sets the per-hook wall-clock timeout. d <= 0 disables timeouts (panic isolation remains on). Default is 100ms.
func SetNXWithTTL ¶ added in v0.1.3
func Subscribe ¶
func Subscribe(topic string) mo.Result[<-chan *ReceivedMessage]
Subscribe registers one local delivery channel for a topic and blocks until the server acknowledges the SUBSCRIBE, then returns that read-only channel.
It records the topic -> channel mapping in deliveryChByTopic, which is the single authoritative registry of subscriptions, and then wakes the background consumer so it can sync the remote SUBSCRIBE state from that registry. The wake-up is a coalescible signal: it can never be lost in a way that leaves the registry and the remote side diverged.
Success means the server confirmed the subscription, so the channel is live. On failure the registration is rolled back, which leaves the topic free to be retried. Duplicate topic registration is rejected.
Types ¶
type HookID ¶ added in v0.1.12
HookID uniquely identifies a registered write hook. The zero value means "invalid" and is a no-op for RemoveHook.
func AddAbortHook ¶ added in v0.1.12
AddAbortHook registers a fail-closed hook that vetoes the write when it returns an error. Applies to every subsequent write through this client.
func AddObserverAfterHook ¶ added in v0.1.12
AddObserverAfterHook registers a fail-open hook that receives the write outcome (final value, committed flag, write error) after commit.
func AddObserverHook ¶ added in v0.1.12
AddObserverHook registers a fail-open hook that inspects the post-Transform value before the write; panics and timeouts are logged, never fail the write.
type ReceivedMessage ¶
ReceivedMessage is a transport-agnostic message exposed to callers.