This capability provider is a template for creating providers with custom capabilities. It uses the provider-sdk-go and implements the auto-generated Provider interface 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:
go generate ./...
go build .
Alternatively, you can generate, build and package this provider in one step:
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", "link_name": "default"}' | base64 | go 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
.
# Build the component
cd component
wash build
# Return to the provider directory
cd ..
# 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 provider.go as methods of your Handler
.import
s in provider.go to invoke linked components. Check out the Call()
function for an example for how to invoke a component using RPC.Have any questions? Please feel free to file an issue and/or join us on the wasmCloud slack!
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。