Documentation
¶
Overview ¶
Package natsjskv is a go-micro store plugin for NATS JetStream Key-Value store.
Index ¶
- Variables
- func DefaultDescription(text string) store.Option
- func DefaultMemory() store.Option
- func DefaultTTL(ttl time.Duration) store.Option
- func DeleteBucket() store.DeleteOption
- func EncodeKeys() store.Option
- func JetStreamOptions(opts ...nats.JSOpt) store.Option
- func KeyValueOptions(cfg ...*nats.KeyValueConfig) store.Option
- func NatsOptions(opts nats.Options) store.Option
- func NewStore(opts ...store.Option) store.Store
- type Key
- type KeyValueEnvelope
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBucketNotFound is returned when the requested bucket does not exist. ErrBucketNotFound = errors.New("Bucket (database) not found") )
Functions ¶
func DefaultDescription ¶
DefaultDescription sets the default description to use when creating new
buckets. The default is "Store managed by go-micro"
func DefaultMemory ¶
DefaultMemory sets the default storage type to memory only.
The default is file storage, persisting storage between service restarts.
Be aware that the default storage location of NATS the /tmp dir is, and thus
won't persist reboots.
func DefaultTTL ¶
DefaultTTL sets the default TTL to use for new buckets
By default no TTL is set.
TTL ON INDIVIDUAL WRITE CALLS IS NOT SUPPORTED, only bucket wide TTL. Either set a default TTL with this option or provide bucket specific options
with ObjectStoreOptions
func DeleteBucket ¶
func DeleteBucket() store.DeleteOption
DeleteBucket will use the key passed to Delete as a bucket (database) name,
and delete the bucket.
This option should not be combined with the store.DeleteFrom option, as
that will overwrite the delete action.
func EncodeKeys ¶
EncodeKeys will "base32" encode the keys. This is to work around limited characters usable as keys for the natsjs kv store. See details here: https://docs.nats.io/nats-concepts/subjects#characters-allowed-for-subject-names
func JetStreamOptions ¶
JetStreamOptions accepts multiple nats.JSOpt.
func KeyValueOptions ¶
KeyValueOptions accepts multiple nats.KeyValueConfig This will create buckets with the provided configs at initialization.
func NatsOptions ¶
NatsOptions accepts nats.Options.
Types ¶
type Key ¶
type Key struct { // Plain is the plain key as requested by the go-micro interface. Plain string // Full is the full key including the table prefix. Full string // Encoded is the base64 encoded key as used by the nats kv store. Encoded string }
Key represents a key in the store. They are used to convert nats keys (base32 encoded) to micro keys (plain text - no table prefix) and vice versa.
type KeyValueEnvelope ¶
type KeyValueEnvelope struct { Key string `json:"key"` Data []byte `json:"data"` Metadata map[string]interface{} `json:"metadata"` }
KeyValueEnvelope is the data structure stored in the key value store.