kvstore

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package kvstore is a client package for WASM functions running within a Tarmac server.

This package provides a user-friendly Key:Value datastore interface that interacts with underlying datastores configured within Tarmac. Guest WASM functions running inside Tarmac can import and call this KV interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Namespace controls the function namespace to use for host callbacks. The default value is "default" which is the global namespace.
	// Users can provide an alternative namespace by specifying this field.
	Namespace string

	// HostCall is used internally for host callbacks. This is mainly here for testing.
	HostCall func(string, string, string, []byte) ([]byte, error)
}

Config provides users with the ability to specify namespaces, function handlers and other key information required to execute the function.

type KV

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

KV provides a simple interface for Tarmac Functions to store key:value data using supported KV datastores.

func New

func New(cfg Config) (*KV, error)

New creates a new KV with the provided configuration.

func (*KV) Delete

func (kv *KV) Delete(key string) error

Delete will delete the data and key defined at key.

func (*KV) Get

func (kv *KV) Get(key string) ([]byte, error)

Get will fetch the data stored under the supplied key.

func (*KV) Keys

func (kv *KV) Keys() ([]string, error)

Keys will return a list of keys available within the KV datastore.

func (*KV) Set

func (kv *KV) Set(key string, data []byte) error

Set will store the supplied data under the provided key.

Jump to

Keyboard shortcuts

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