This is a capability provider for wasmCloud to provide Couchbase KV connectivity to Wasm applications via the wasmcloud-couchbase
interface.
This provider uses the RawJSONTranscoder for Couchbase, storing any new keys as binary data. The deserialization into a struct
or structured data must be done on the component side as the provider does not have information about the desired shape of data.
Prerequisites:
Build this capability provider with:
wash build
Build the example components with:
wash build -p components/rust
wash build -p components/golang
docker-compose up -d
Alternatively, you can use Quick Install guide with a bucket named test created.
WASMCLOUD_SECRETS_TOPIC=wasmcloud.secrets \
wash up -d
# Generate encryption keys and run the backend
export ENCRYPTION_XKEY_SEED=$(wash keys gen curve -o json | jq -r '.seed')
export TRANSIT_XKEY_SEED=$(wash keys gen curve -o json | jq -r '.seed')
secrets-nats-kv run &
# Put the password in the NATS KV secrets backend
provider_key=$(wash inspect ./build/wasmcloud-provider-couchbase.par.gz -o json | jq -r '.service')
secrets-nats-kv put couchbase_password --string password
secrets-nats-kv add-mapping $provider_key --secret couchbase_password
wash app deploy ./wadm.yaml
Then you can invoke either the Rust component or the Golang component on port 8080 and 8081, respectively. Both components implement the exact same functionality, which simply takes a payload and a path to roundtrip a JSON document in Couchbase.
curl -d '{"demo": true, "couchbase": "db", "wasmcloud": "application platform"}' \
localhost:8080/mykey
{"demo": true, "couchbase": "db", "wasmcloud": "application platform"}%
To test the WIT bindings, download wit-bindgen and run the following:
wit-deps && wit-bindgen rust --out-dir /tmp/wit wit/
This will attempt to generate Rust based bindings, in a folder under /tmp
(which will be cleaned up eventually), but in doing so, will check that the WIT definitions are valid (as they must be to complete binding generation).