arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Key:Value Datastore

Store and Retrieve data from a Key:Value datastore

The Key:Value Store capability provides WASM function developers the ability to store and retrieve data from Key:Value datastores. At the moment, Tarmac supports multiple Key:Value stores which can be enabled/disabled in the host configuration settings.

hashtag
Get

The Get function provides users with the ability to fetch data using the specified key. To avoid conflicts, the data key within the response, JSON, will be base64 encoded.

hashtag
Interface Details

Namespace
Capability
Function
Input
Output

hashtag
Example JSON

This callback uses JSON messages as input and output to facilitate communications between WASM functions and the Tarmac host.

hashtag
KVStoreGet

hashtag
KVStoreGetResponse

The Status structure within the response JSON denotes the success of the database call. The status code value follows the HTTP status code standards, with anything higher than 399 is an error.

hashtag
Set

The Set function provides users with the ability to store data within the Key:Value datastore. The data key within the request JSON must be base64 encoded.

hashtag
Interface Details

Namespace
Capability
Function
Input
Output

hashtag
Example JSON

This callback uses JSON messages as input and output to facilitate communications between WASM functions and the Tarmac host.

hashtag
KVStoreSet

hashtag
KVStoreSetResponse

The Status structure within the response JSON denotes the success of the database call. The status code value follows the HTTP status code standards, with anything higher than 399 is an error.

hashtag
Delete

The Delete function provides users with the ability to delete data stored within the Key:Value datastore.

hashtag
Interface Details

Namespace
Capability
Function
Input
Output

hashtag
Example JSON

This callback uses JSON messages as input and output to facilitate communications between WASM functions and the Tarmac host.

hashtag
KVStoreDelete

hashtag
KVStoreDeleteResponse

The Status structure within the response JSON denotes the success of the database call. The status code value follows the HTTP status code standards, with anything higher than 399 is an error.

hashtag
Keys

The Keys function provides users with the ability to fetch a list of all keys available within the Key:Value datastore.

Note: This callback requires no input JSON. However, the callback function will require users to provide a byte slice.

hashtag
Interface Details

Namespace
Capability
Function
Input
Output

hashtag
Example JSON

This callback uses JSON messages as input and output to facilitate communications between WASM functions and the Tarmac host.

hashtag
KVStoreKeysResponse

The Status structure within the response JSON denotes the success of the database call. The status code value follows the HTTP status code standards, with anything higher than 399 is an error.

_, err := wapc.HostCall("tarmac", "kvstore", "get", KVStoreGetJSON)

tarmac

kvstore

get

KVStoreGet

KVStoreGetResponse

tarmac

kvstore

set

KVStoreSet

KVStoreSetResponse

tarmac

kvstore

delete

KVStoreDelete

KVStoreDeleteResponse

tarmac

kvstore

keys

EmptyByteSlice

KVStoreKeysResponse

{
	"key": "myKey"
}
{
	"data": "VHdlZXQgYWJvdXQgVGFybWFjIGlmIHlvdSB0aGluayBpdCdzIGF3ZXNvbWUu",
	"status": {
		"code": 200,
		"status": "OK"
	}
}
_, err := wapc.HostCall("tarmac", "kvstore", "set", KVStoreSetJSON)
{
  "data": "VHdlZXQgYWJvdXQgVGFybWFjIGlmIHlvdSB0aGluayBpdCdzIGF3ZXNvbWUu",
  "key": "myKey"
}
{
  "status": {
    "code": 200,
    "status": "OK"
  }
}
_, err := wapc.HostCall("tarmac", "kvstore", "delete", KVStoreDeleteJSON)
{
  "key": "myKey"
}
{
  "status": {
    "code": 200,
    "status": "OK"
  }
}
_, err := wapc.HostCall("tarmac", "kvstore", "keys", []byte())
{
	"keys": ["key1", "key2"],
	"status": {
		"code": 200,
		"status": "OK"
	}
}