This capability provider is a template for creating providers with custom capabilities. It uses the wasmcloud-provider-sdk and implements the Provider trait with an example handler that will persist the links that target the provider (target links) and links where the provider is the source and targets a component (source links).
The purpose of this example is to provide comprehensive comments on the usage of our wasmCloud provider SDK, from serving RPC exports to invoking component imports. The code is informative to read through and provides a base for extending wasmCloud with custom capabilities.
Prerequisites:
You can build this capability provider by running wash build
. You can build the included test component with wash build -p ./component
.
Prerequisites:
You can run this capability provider as a binary by passing a simple base64 encoded HostData struct, in order to do basic testing. For example:
nats-server -js &
echo '{"lattice_rpc_url": "0.0.0.0:4222", "lattice_rpc_prefix": "default", "provider_key": "custom-template", "config": {"foo": "bar"}, "env_values": {}, "link_definitions": [], "otel_config": {"enable_observability": false}}' | base64 | cargo run
And in another terminal, you can request the health of the provider using the NATS CLI
nats req "wasmbus.rpc.default.custom-template.health" '{}'
Additionally, you can invoke the provider directly which will send test data to each linked component
wash call custom-template wasmcloud:example/system-info.call
You can deploy this provider, along with a component for testing, by deploying the wadm.yaml application. Make sure to build the component with wash build
.
# Launch wasmCloud in the background
wash up -d
# Deploy the application
wash app deploy ./wadm.yaml
Customizing this provider to meet your needs of a custom capability takes just a few steps.
export
s in src/provider.rs inside of the impl Handler {}
block.impl Provider {}
block to handle invoking components. For inspiration, take a look at our other capability providers that implement various capabilities like HTTP, Messaging, Key-Value in the crates/provider-* folder.Have any questions? Please feel free to file an issue and/or join us on the wasmCloud slack!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。