This document describes how to build and test new component.
cd $GOPATH/src
# Clone dapr
mkdir -p github.com/dapr/dapr
git clone https://github.com/dapr/dapr.git github.com/dapr/dapr
# Clone component-contrib
mkdir -p github.com/dapr/components-contrib
git clone https://github.com/dapr/components-contrib.git github.com/dapr/components-contrib
- Create your component directory in the right component directory
- Copy component files from the refernece component to your component directory
- Add go unit-test for your component
Type | Directory | Reference | Docs |
---|---|---|---|
State | components-contrib/state | Redis | concept, howto, api spec |
Pubsub | components-contrib/pubsub | Redis | concept, howto, api spec |
Bindings | components-contrib/bindings | Kafka | concept, input howto, output howto, api spec |
Secret Store | components-contrib/secretstore | Kubernetes, Azure Keyvault | concept, howto |
Middleware | components-contrib/middleware | Oauth2 | concept, howto |
Exporter | components-contrib/exporters | Zipkin | concept, howto |
Service Discovery | components-contrib/servicediscovery | mdns | howto |
make test
make lint
- Make sure you clone dapr and component-contrib repos under $GOPATH/src/github.com/dapr
- Replace github.com/dapr/components-contrib reference to the local component-contrib
go mod edit -replace github.com/dapr/components-contrib=../components-contrib
- Import your component to dapr main.go
- Register your component in dapr main.go(e.g. binding)
- Build debuggable dapr binary
make DEBUG=1 build
- Replace the installed daprd with the test binary (then dapr cli will use the test binary)
# Back up the current daprd
mv /usr/local/bin/daprd /usr/local/bin/daprd.bak
cp ./dist/darwin_amd64/debug/daprd /usr/local/bin
Linux Debuggable Binary: ./dist/linux_amd64/debug/daprd Windows Debuggable Binary: .\dist\windows_amd64\debug\daprd
- Prepare your test app (e.g. kafka sample app: https://github.com/dapr/samples/blob/master/5.bindings/nodeapp/)
- Create yaml for bindings in './components' under app’s directory (e.g. kafka example : https://github.com/dapr/samples/blob/master/5.bindings/deploy/kafka_bindings.yaml)
- Run your test app using dapr cli
- Make sure your component is loaded successfully in daprd log
- Create a pullrequest to add your component in component-contrib repo
- Get the approval from maintainers
- Fetch the latest dapr/dapr repo
- Update component-contrib go mod and ensure that component-contrib is updated to the latest version
go get -u github.com/dapr/components-contrib