├── .codecov.yaml
├── CODEOWNERS
├── .github
├── dependabot.yml
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ ├── test-on-push.yaml
│ └── release-on-tag.yaml
├── example
├── serving
│ ├── grpc
│ │ ├── config
│ │ │ ├── cron.yaml
│ │ │ ├── pubsub.yaml
│ │ │ └── statestore.yaml
│ │ └── main.go
│ └── http
│ │ ├── config
│ │ ├── cron.yaml
│ │ ├── pubsub.yaml
│ │ └── statestore.yaml
│ │ └── main.go
├── client
│ ├── config
│ │ ├── pubsub.yaml
│ │ ├── binding.yaml
│ │ └── statestore.yaml
│ └── main.go
├── pubsub
│ ├── config
│ │ └── pubsub.yaml
│ ├── pub
│ │ └── pub.go
│ ├── sub
│ │ └── sub.go
│ └── README.md
└── Readme.md
├── service
├── http
│ ├── service_test.go
│ ├── topic_test.go
│ ├── binding_test.go
│ ├── service.go
│ ├── binding.go
│ ├── invoke.go
│ ├── invoke_test.go
│ ├── topic.go
│ └── Readme.md
├── grpc
│ ├── service_test.go
│ ├── topic_test.go
│ ├── invoke.go
│ ├── invoke_test.go
│ ├── binding.go
│ ├── binding_test.go
│ ├── service.go
│ ├── topic.go
│ └── Readme.md
├── common
│ ├── service.go
│ └── type.go
└── Readme.md
├── .gitignore
├── client
├── secret_test.go
├── pubsub_test.go
├── pubsub.go
├── invoke_test.go
├── secret.go
├── binding_test.go
├── binding.go
├── invoke.go
├── client_test.go
├── client.go
├── state_test.go
└── state.go
├── go.mod
├── LICENSE
├── CONTRIBUTING.md
├── Makefile
├── Readme.md
├── go.sum
└── dapr
└── proto
├── common
└── v1
│ └── common.pb.go
└── runtime
└── v1
└── appcallback.pb.go
/.codecov.yaml:
--------------------------------------------------------------------------------
1 | ignore:
2 | - "dapr/proto/**"
3 | - "example/**"
4 |
5 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | # These owners are the maintainers and approvers of this repo
2 | * @maintainers-go-sdk @approvers-go-sdk
3 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "gomod"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 |
--------------------------------------------------------------------------------
/example/serving/grpc/config/cron.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: run
5 | spec:
6 | type: bindings.cron
7 | metadata:
8 | - name: schedule
9 | value: "@every 10s"
--------------------------------------------------------------------------------
/example/serving/http/config/cron.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: run
5 | spec:
6 | type: bindings.cron
7 | metadata:
8 | - name: schedule
9 | value: "@every 10s"
--------------------------------------------------------------------------------
/service/http/service_test.go:
--------------------------------------------------------------------------------
1 | package http
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/assert"
7 | )
8 |
9 | func TestStoppingUnstartedService(t *testing.T) {
10 | s := newServer("", nil)
11 | assert.NotNil(t, s)
12 | }
13 |
--------------------------------------------------------------------------------
/example/client/config/pubsub.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: messagebus
5 | spec:
6 | type: pubsub.redis
7 | metadata:
8 | - name: redisHost
9 | value: localhost:6379
10 | - name: redisPassword
11 | value: ""
12 |
--------------------------------------------------------------------------------
/example/pubsub/config/pubsub.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: messagebus
5 | spec:
6 | type: pubsub.redis
7 | metadata:
8 | - name: redisHost
9 | value: localhost:6379
10 | - name: redisPassword
11 | value: ""
12 |
--------------------------------------------------------------------------------
/example/serving/grpc/config/pubsub.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: messages
5 | spec:
6 | type: pubsub.redis
7 | metadata:
8 | - name: redisHost
9 | value: localhost:6379
10 | - name: redisPassword
11 | value: ""
12 |
--------------------------------------------------------------------------------
/example/serving/http/config/pubsub.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: messages
5 | spec:
6 | type: pubsub.redis
7 | metadata:
8 | - name: redisHost
9 | value: localhost:6379
10 | - name: redisPassword
11 | value: ""
12 |
--------------------------------------------------------------------------------
/example/client/config/binding.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: example-http-binding
5 | spec:
6 | type: bindings.http
7 | metadata:
8 | - name: url
9 | value: https://http2.pro/api/v1
10 | - name: method
11 | value: GET
12 |
13 |
--------------------------------------------------------------------------------
/example/client/config/statestore.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: statestore
5 | spec:
6 | type: state.redis
7 | metadata:
8 | - name: redisHost
9 | value: localhost:6379
10 | - name: redisPassword
11 | value: ""
12 | - name: actorStateStore
13 | value: "true"
14 |
--------------------------------------------------------------------------------
/example/serving/grpc/config/statestore.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: statestore
5 | spec:
6 | type: state.redis
7 | metadata:
8 | - name: redisHost
9 | value: localhost:6379
10 | - name: redisPassword
11 | value: ""
12 | - name: actorStateStore
13 | value: "true"
14 |
--------------------------------------------------------------------------------
/example/serving/http/config/statestore.yaml:
--------------------------------------------------------------------------------
1 | apiVersion: dapr.io/v1alpha1
2 | kind: Component
3 | metadata:
4 | name: statestore
5 | spec:
6 | type: state.redis
7 | metadata:
8 | - name: redisHost
9 | value: localhost:6379
10 | - name: redisPassword
11 | value: ""
12 | - name: actorStateStore
13 | value: "true"
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Binaries for programs and plugins
2 | *.exe
3 | *.exe~
4 | *.dll
5 | *.so
6 | *.dylib
7 |
8 | # Test binary, build with `go test -c`
9 | *.test
10 |
11 | # Output of the go coverage tool, specifically when used with LiteIDE
12 | *.out
13 | .DS_Store
14 |
15 | # vendor
16 | vendor
17 |
18 | # docs
19 | golang.org
20 | coverage.txt
21 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ''
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is
12 |
13 | **To Reproduce**
14 | Steps to reproduce the behavior
15 |
16 | **Expected behavior**
17 | A clear and concise description of what you expected to happen
18 |
--------------------------------------------------------------------------------
/example/pubsub/pub/pub.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "fmt"
6 | "os"
7 |
8 | dapr "github.com/dapr/go-sdk/client"
9 | )
10 |
11 | var (
12 | // set the environment as instructions.
13 | pubsubName = os.Getenv("DAPR_PUBSUB_NAME")
14 | topicName = "neworder"
15 | )
16 |
17 | func main() {
18 | ctx := context.Background()
19 | data := []byte("ping")
20 |
21 | client, err := dapr.NewClient()
22 | if err != nil {
23 | panic(err)
24 | }
25 | defer client.Close()
26 |
27 | if err := client.PublishEvent(ctx, pubsubName, topicName, data); err != nil {
28 | panic(err)
29 | }
30 | fmt.Println("data published")
31 |
32 | fmt.Println("Done (CTRL+C to Exit)")
33 | }
34 |
--------------------------------------------------------------------------------
/client/secret_test.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/assert"
8 | )
9 |
10 | // go test -timeout 30s ./client -count 1 -run ^TestGetSecret$
11 | func TestGetSecret(t *testing.T) {
12 | ctx := context.Background()
13 |
14 | t.Run("without meta", func(t *testing.T) {
15 | out, err := testClient.GetSecret(ctx, "store", "key1", nil)
16 | assert.Nil(t, err)
17 | assert.NotNil(t, out)
18 | })
19 |
20 | t.Run("with meta", func(t *testing.T) {
21 | in := map[string]string{"k1": "v1", "k2": "v2"}
22 | out, err := testClient.GetSecret(ctx, "store", "key1", in)
23 | assert.Nil(t, err)
24 | assert.NotNil(t, out)
25 | })
26 | }
27 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ''
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/service/grpc/service_test.go:
--------------------------------------------------------------------------------
1 | package grpc
2 |
3 | import (
4 | "testing"
5 |
6 | "github.com/stretchr/testify/assert"
7 | "google.golang.org/grpc/test/bufconn"
8 | )
9 |
10 | func TestServer(t *testing.T) {
11 | server := getTestServer()
12 | startTestServer(server)
13 | stopTestServer(t, server)
14 | }
15 |
16 | func getTestServer() *Server {
17 | return newService(bufconn.Listen(1024 * 1024))
18 | }
19 |
20 | func startTestServer(server *Server) {
21 | go func() {
22 | if err := server.Start(); err != nil && err.Error() != "closed" {
23 | panic(err)
24 | }
25 | }()
26 | }
27 |
28 | func stopTestServer(t *testing.T, server *Server) {
29 | assert.NotNil(t, server)
30 | err := server.Stop()
31 | assert.Nilf(t, err, "error stopping server")
32 | }
33 |
--------------------------------------------------------------------------------
/client/pubsub_test.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/assert"
8 | )
9 |
10 | // go test -timeout 30s ./client -count 1 -run ^TestPublishEvent$
11 | func TestPublishEvent(t *testing.T) {
12 | ctx := context.Background()
13 |
14 | t.Run("with data", func(t *testing.T) {
15 | err := testClient.PublishEvent(ctx, "messagebus", "test", []byte("ping"))
16 | assert.Nil(t, err)
17 | })
18 |
19 | t.Run("without data", func(t *testing.T) {
20 | err := testClient.PublishEvent(ctx, "messagebus", "test", nil)
21 | assert.Nil(t, err)
22 | })
23 |
24 | t.Run("with empty topic name", func(t *testing.T) {
25 | err := testClient.PublishEvent(ctx, "messagebus", "", []byte("ping"))
26 | assert.NotNil(t, err)
27 | })
28 | }
29 |
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/dapr/go-sdk
2 |
3 | go 1.15
4 |
5 | require (
6 | github.com/davecgh/go-spew v1.1.1 // indirect
7 | github.com/golang/protobuf v1.4.2
8 | github.com/kr/text v0.2.0 // indirect
9 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
10 | github.com/pkg/errors v0.9.1
11 | github.com/stretchr/testify v1.6.1
12 | golang.org/x/net v0.0.0-20200904194848-62affa334b73 // indirect
13 | golang.org/x/sys v0.0.0-20200917073148-efd3b9a0ff20 // indirect
14 | golang.org/x/text v0.3.3 // indirect
15 | google.golang.org/genproto v0.0.0-20200917134801-bb4cff56e0d0 // indirect
16 | google.golang.org/grpc v1.32.0
17 | google.golang.org/protobuf v1.25.0
18 | gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
19 | gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
20 | )
21 |
--------------------------------------------------------------------------------
/client/pubsub.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 |
6 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
7 | "github.com/pkg/errors"
8 | )
9 |
10 | // PublishEvent pubishes data onto specific pubsub topic.
11 | func (c *GRPCClient) PublishEvent(ctx context.Context, component, topic string, in []byte) error {
12 | if topic == "" {
13 | return errors.New("topic name required")
14 | }
15 | if component == "" {
16 | return errors.New("component name required")
17 | }
18 |
19 | envelop := &pb.PublishEventRequest{
20 | PubsubName: component,
21 | Topic: topic,
22 | Data: in,
23 | }
24 |
25 | _, err := c.protoClient.PublishEvent(c.withAuthToken(ctx), envelop)
26 | if err != nil {
27 | return errors.Wrapf(err, "error publishing event unto %s topic", topic)
28 | }
29 |
30 | return nil
31 | }
32 |
--------------------------------------------------------------------------------
/client/invoke_test.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/assert"
8 | )
9 |
10 | // go test -timeout 30s ./client -count 1 -run ^TestInvokeServiceWithContent$
11 |
12 | func TestInvokeServiceWithContent(t *testing.T) {
13 | ctx := context.Background()
14 | data := "ping"
15 |
16 | t.Run("with content", func(t *testing.T) {
17 | content := &DataContent{
18 | ContentType: "text/plain",
19 | Data: []byte(data),
20 | }
21 | resp, err := testClient.InvokeServiceWithContent(ctx, "test", "fn", content)
22 | assert.Nil(t, err)
23 | assert.NotNil(t, resp)
24 | assert.Equal(t, string(resp), data)
25 |
26 | })
27 |
28 | t.Run("without content", func(t *testing.T) {
29 | resp, err := testClient.InvokeService(ctx, "test", "fn")
30 | assert.Nil(t, err)
31 | assert.Nil(t, resp)
32 |
33 | })
34 | }
35 |
--------------------------------------------------------------------------------
/client/secret.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 |
6 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
7 | "github.com/pkg/errors"
8 | )
9 |
10 | // GetSecret retreaves preconfigred secret from specified store using key.
11 | func (c *GRPCClient) GetSecret(ctx context.Context, store, key string, meta map[string]string) (out map[string]string, err error) {
12 | if store == "" {
13 | return nil, errors.New("nil store")
14 | }
15 | if key == "" {
16 | return nil, errors.New("nil key")
17 | }
18 |
19 | req := &pb.GetSecretRequest{
20 | Key: key,
21 | StoreName: store,
22 | Metadata: meta,
23 | }
24 |
25 | resp, err := c.protoClient.GetSecret(c.withAuthToken(ctx), req)
26 | if err != nil {
27 | return nil, errors.Wrap(err, "error invoking service")
28 | }
29 |
30 | if resp != nil {
31 | out = resp.GetData()
32 | }
33 |
34 | return
35 | }
36 |
--------------------------------------------------------------------------------
/service/common/service.go:
--------------------------------------------------------------------------------
1 | package common
2 |
3 | import "context"
4 |
5 | // Service represents Dapr callback service
6 | type Service interface {
7 | // AddServiceInvocationHandler appends provided service invocation handler with its name to the service.
8 | AddServiceInvocationHandler(name string, fn func(ctx context.Context, in *InvocationEvent) (out *Content, err error)) error
9 | // AddTopicEventHandler appends provided event handler with its topic and optional metadata to the service.
10 | // Note, retries are only considered when there is an error. Lack of error is considered as a success
11 | AddTopicEventHandler(sub *Subscription, fn func(ctx context.Context, e *TopicEvent) (retry bool, err error)) error
12 | // AddBindingInvocationHandler appends provided binding invocation handler with its name to the service.
13 | AddBindingInvocationHandler(name string, fn func(ctx context.Context, in *BindingEvent) (out []byte, err error)) error
14 | // Start starts service.
15 | Start() error
16 | // Stop stops the previously started service.
17 | Stop() error
18 | }
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Dapr
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/.github/workflows/test-on-push.yaml:
--------------------------------------------------------------------------------
1 | name: Test
2 |
3 | on:
4 | push:
5 |
6 | jobs:
7 |
8 | build:
9 | name: Test and Lint on Push
10 | runs-on: ubuntu-latest
11 | steps:
12 |
13 | - name: Setup
14 | id: go
15 | uses: actions/setup-go@v2
16 | with:
17 | go-version: ^1.15
18 |
19 | - name: Checkout
20 | id: setup
21 | uses: actions/checkout@v2
22 |
23 | - name: Cache
24 | uses: actions/cache@preview
25 | with:
26 | path: ~/go/pkg/mod
27 | key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
28 | restore-keys: |
29 | ${{ runner.OS }}-build-${{ env.cache-name }}-
30 | ${{ runner.OS }}-build-
31 | ${{ runner.OS }}-
32 |
33 | - name: Tidy
34 | run: |
35 | go mod tidy
36 | go mod vendor
37 |
38 | - name: Test
39 | run: go test -v -count=1 -race -coverprofile=coverage.txt -covermode=atomic ./...
40 |
41 | - name: Cover
42 | uses: codecov/codecov-action@v1
43 |
44 | - name: Lint
45 | uses: golangci/golangci-lint-action@v1
46 | with:
47 | version: v1.30
48 |
49 |
50 |
--------------------------------------------------------------------------------
/example/pubsub/sub/sub.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "log"
6 | "net/http"
7 |
8 | "github.com/dapr/go-sdk/service/common"
9 | daprd "github.com/dapr/go-sdk/service/http"
10 | )
11 |
12 | // Subscription to tell the dapr what topic to subscribe.
13 | // - PubsubName: is the name of the component configured in the metadata of pubsub.yaml.
14 | // - Topic: is the name of the topic to subscribe.
15 | // - Route: tell dapr where to request the API to publish the message to the subscriber when get a message from topic.
16 | var sub = &common.Subscription{
17 | PubsubName: "messagebus",
18 | Topic: "neworder",
19 | Route: "/orders",
20 | }
21 |
22 | func main() {
23 | s := daprd.NewService(":8080")
24 |
25 | if err := s.AddTopicEventHandler(sub, eventHandler); err != nil {
26 | log.Fatalf("error adding topic subscription: %v", err)
27 | }
28 |
29 | if err := s.Start(); err != nil && err != http.ErrServerClosed {
30 | log.Fatalf("error listenning: %v", err)
31 | }
32 | }
33 |
34 | func eventHandler(ctx context.Context, e *common.TopicEvent) (retry bool, err error) {
35 | log.Printf("event - PubsubName: %s, Topic: %s, ID: %s, Data: %s", e.PubsubName, e.Topic, e.ID, e.Data)
36 | return false, nil
37 | }
38 |
--------------------------------------------------------------------------------
/client/binding_test.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 | "testing"
6 |
7 | "github.com/stretchr/testify/assert"
8 | )
9 |
10 | // go test -timeout 30s ./client -count 1 -run ^TestInvokeBinding$
11 |
12 | func TestInvokeBinding(t *testing.T) {
13 | ctx := context.Background()
14 | in := &BindingInvocation{
15 | Name: "test",
16 | Operation: "fn",
17 | }
18 |
19 | t.Run("output binding without data", func(t *testing.T) {
20 | err := testClient.InvokeOutputBinding(ctx, in)
21 | assert.Nil(t, err)
22 | })
23 |
24 | t.Run("output binding", func(t *testing.T) {
25 | in.Data = []byte("test")
26 | err := testClient.InvokeOutputBinding(ctx, in)
27 | assert.Nil(t, err)
28 | })
29 |
30 | t.Run("binding without data", func(t *testing.T) {
31 | in.Data = nil
32 | out, err := testClient.InvokeBinding(ctx, in)
33 | assert.Nil(t, err)
34 | assert.NotNil(t, out)
35 | })
36 |
37 | t.Run("binding with data and meta", func(t *testing.T) {
38 | in.Data = []byte("test")
39 | in.Metadata = map[string]string{"k1": "v1", "k2": "v2"}
40 | out, err := testClient.InvokeBinding(ctx, in)
41 | assert.Nil(t, err)
42 | assert.NotNil(t, out)
43 | assert.Equal(t, "test", string(out.Data))
44 | })
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/service/Readme.md:
--------------------------------------------------------------------------------
1 | # Dapr Service (Callback) SDK for Go
2 |
3 | In addition to this Dapr API client, Dapr go SDK also provides `service` package to bootstrap your Dapr callback services. These services can be developed in either gRPC or HTTP:
4 |
5 | * [HTTP Service](./http/Readme.md)
6 | * [gRPC Service](./grpc/Readme.md)
7 |
8 | ## Templates
9 |
10 | To accelerate your Dapr app development in go even further, we've craated a few GitHub templates which build on the above Dapr callback packages:
11 |
12 | * [Dapr gRPC Service in Go](https://github.com/dapr-templates/dapr-grpc-service-template) - Template project to jump start your Dapr event subscriber service with gRPC development
13 | * [Dapr HTTP Event Subscriber in Go](https://github.com/dapr-templates/dapr-http-event-subscriber-template) - Template project to jump start your Dapr event subscriber service with HTTP development
14 | * [Dapr gRPC Event Subscriber in Go](https://github.com/dapr-templates/dapr-grpc-event-subscriber-template) - Template project to jump start your Dapr event subscriber service with gRPC development
15 | * [Dapr HTTP cron Handler in Go](https://github.com/dapr-templates/dapr-http-cron-handler-template) - Template project to jump start your Dapr service development for scheduled workloads
16 |
17 | ## Contributing
18 |
19 | See the [Contribution Guide](../CONTRIBUTING.md) to get started with building and developing.
20 |
--------------------------------------------------------------------------------
/example/pubsub/README.md:
--------------------------------------------------------------------------------
1 | # Dapr PubSub Example with go-sdk
2 |
3 | This folder contains two go file that uses this go-SDK to invoke the Dapr PubSub API.
4 |
5 | ## Helpful
6 | 
7 |
8 | ## Step
9 |
10 | ### Prepare
11 | - Dapr installed
12 |
13 | ### Run Subscriber Server
14 | when use Dapr PubSub to subscribe, should have a http or gRPC server to receive the requests from Dapr.
15 |
16 | Please change directory to pubsub/sub and run the following command:
17 | ```bash
18 | dapr run --app-id sub \
19 | --app-protocol http \
20 | --app-port 8080 \
21 | --dapr-http-port 3500 \
22 | --log-level debug \
23 | --components-path ../config \
24 | go run sub.go
25 | ```
26 |
27 | ### Run Publisher
28 | Publish is more simply than subscribe. Just Publish the data to target pubsub component with its' name.
29 |
30 | After you start a server by above guide.
31 |
32 | Use the environment variable, Please set `DAPR_PUBSUB_NAME` as the name of the components: `messagebus` at first.
33 |
34 | Please change directory to pubsub/pub and run the following command:
35 | ```bash
36 | dapr run --app-id pub \
37 | --log-level debug \
38 | --components-path ../config \
39 | go run pub.go
40 | ```
41 |
42 | ## Result
43 | You would see log that in terminal which run the server(subscriber) code.
44 | ```bash
45 | == APP == 2020/08/23 13:21:58 event - PubsubName: messagebus, Topic: demo, ID: 11acaa82-23c4-4244-8969-7360dae52e5d, Data: ping
46 | ```
--------------------------------------------------------------------------------
/.github/workflows/release-on-tag.yaml:
--------------------------------------------------------------------------------
1 | name: Release
2 |
3 | on:
4 | push:
5 | tags:
6 | - 'v*' # v0.8.1
7 |
8 | jobs:
9 |
10 | build:
11 | name: Create Release on Tag
12 | runs-on: ubuntu-latest
13 | steps:
14 |
15 | - name: Setup
16 | id: go
17 | uses: actions/setup-go@v2
18 | with:
19 | go-version: ^1.15
20 |
21 | - name: Checkout
22 | id: setup
23 | uses: actions/checkout@v2
24 |
25 | - name: Cache
26 | uses: actions/cache@preview
27 | with:
28 | path: ~/go/pkg/mod
29 | key: ${{ runner.os }}-build-${{ hashFiles('**/go.sum') }}
30 | restore-keys: |
31 | ${{ runner.OS }}-build-${{ env.cache-name }}-
32 | ${{ runner.OS }}-build-
33 | ${{ runner.OS }}-
34 |
35 | - name: Tidy
36 | run: |
37 | go mod tidy
38 | go mod vendor
39 |
40 | - name: Test
41 | run: go test -v -count=1 -race ./...
42 |
43 | - name: Lint
44 | uses: golangci/golangci-lint-action@v1
45 | with:
46 | version: v1.30
47 |
48 | - name: Version
49 | id: get_version
50 | run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:10})
51 |
52 | - name: Release
53 | id: release-step
54 | uses: actions/create-release@v1
55 | env:
56 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57 | with:
58 | tag_name: ${{ github.ref }}
59 | release_name: Release ${{ github.ref }}
60 | body: Automatic go Dapr client release
61 | draft: false
62 | prerelease: false
--------------------------------------------------------------------------------
/service/http/topic_test.go:
--------------------------------------------------------------------------------
1 | package http
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "fmt"
7 | "net/http"
8 | "net/http/httptest"
9 | "strings"
10 | "testing"
11 |
12 | "github.com/dapr/go-sdk/service/common"
13 | "github.com/stretchr/testify/assert"
14 | )
15 |
16 | func TestEventHandler(t *testing.T) {
17 | data := `{
18 | "specversion" : "1.0",
19 | "type" : "com.github.pull.create",
20 | "source" : "https://github.com/cloudevents/spec/pull",
21 | "subject" : "123",
22 | "id" : "A234-1234-1234",
23 | "time" : "2018-04-05T17:31:00Z",
24 | "comexampleextension1" : "value",
25 | "comexampleothervalue" : 5,
26 | "datacontenttype" : "application/json",
27 | "data" : "eyJtZXNzYWdlIjoiaGVsbG8ifQ=="
28 | }`
29 |
30 | s := newServer("", nil)
31 |
32 | sub := &common.Subscription{
33 | PubsubName: "messages",
34 | Topic: "test",
35 | Route: "/",
36 | Metadata: map[string]string{},
37 | }
38 | err := s.AddTopicEventHandler(sub, func(ctx context.Context, e *common.TopicEvent) (retry bool, err error) {
39 | if e == nil {
40 | return false, errors.New("nil content")
41 | }
42 | if e.DataContentType != "application/json" {
43 | return false, fmt.Errorf("invalid content type: %s", e.DataContentType)
44 | }
45 | return false, nil
46 | })
47 | assert.NoErrorf(t, err, "error adding event handler")
48 |
49 | req, err := http.NewRequest(http.MethodPost, "/", strings.NewReader(data))
50 | assert.NoErrorf(t, err, "error creating request")
51 | req.Header.Set("Content-Type", "application/json")
52 |
53 | rr := httptest.NewRecorder()
54 | s.registerSubscribeHandler()
55 | s.mux.ServeHTTP(rr, req)
56 | assert.Equal(t, http.StatusOK, rr.Code)
57 | }
58 |
--------------------------------------------------------------------------------
/service/grpc/topic_test.go:
--------------------------------------------------------------------------------
1 | package grpc
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "testing"
7 |
8 | "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
9 | "github.com/dapr/go-sdk/service/common"
10 | "github.com/stretchr/testify/assert"
11 | )
12 |
13 | func eventHandler(ctx context.Context, event *common.TopicEvent) (retry bool, err error) {
14 | if event == nil {
15 | return true, errors.New("nil event")
16 | }
17 | return false, nil
18 | }
19 |
20 | // go test -timeout 30s ./service/grpc -count 1 -run ^TestTopic$
21 | func TestTopic(t *testing.T) {
22 | ctx := context.Background()
23 | sub := &common.Subscription{
24 | PubsubName: "messages",
25 | Topic: "test",
26 | }
27 | server := getTestServer()
28 |
29 | err := server.AddTopicEventHandler(sub, eventHandler)
30 | assert.Nil(t, err)
31 | startTestServer(server)
32 |
33 | t.Run("topic event without request", func(t *testing.T) {
34 | _, err := server.OnTopicEvent(ctx, nil)
35 | assert.Error(t, err)
36 | })
37 |
38 | t.Run("topic event for wrong topic", func(t *testing.T) {
39 | in := &runtime.TopicEventRequest{
40 | Topic: "invlid",
41 | }
42 | _, err := server.OnTopicEvent(ctx, in)
43 | assert.Error(t, err)
44 | })
45 |
46 | t.Run("topic event for valid topic", func(t *testing.T) {
47 | in := &runtime.TopicEventRequest{
48 | Id: "a123",
49 | Source: "test",
50 | Type: "test",
51 | SpecVersion: "v1.0",
52 | DataContentType: "text/plain",
53 | Data: []byte("test"),
54 | Topic: sub.Topic,
55 | PubsubName: sub.PubsubName,
56 | }
57 | _, err := server.OnTopicEvent(ctx, in)
58 | assert.NoError(t, err)
59 | })
60 |
61 | stopTestServer(t, server)
62 | }
63 |
--------------------------------------------------------------------------------
/service/grpc/invoke.go:
--------------------------------------------------------------------------------
1 | package grpc
2 |
3 | import (
4 | "context"
5 | "fmt"
6 |
7 | cpb "github.com/dapr/go-sdk/dapr/proto/common/v1"
8 | cc "github.com/dapr/go-sdk/service/common"
9 | "github.com/golang/protobuf/ptypes/any"
10 | "github.com/pkg/errors"
11 | )
12 |
13 | // AddServiceInvocationHandler appends provided service invocation handler with its method to the service
14 | func (s *Server) AddServiceInvocationHandler(method string, fn func(ctx context.Context, in *cc.InvocationEvent) (our *cc.Content, err error)) error {
15 | if method == "" {
16 | return fmt.Errorf("servie name required")
17 | }
18 | s.invokeHandlers[method] = fn
19 | return nil
20 | }
21 |
22 | // OnInvoke gets invoked when a remote service has called the app through Dapr
23 | func (s *Server) OnInvoke(ctx context.Context, in *cpb.InvokeRequest) (*cpb.InvokeResponse, error) {
24 | if in == nil {
25 | return nil, errors.New("nil invoke request")
26 | }
27 | if fn, ok := s.invokeHandlers[in.Method]; ok {
28 | e := &cc.InvocationEvent{}
29 | if in != nil {
30 | e.ContentType = in.ContentType
31 |
32 | if in.Data != nil {
33 | e.Data = in.Data.Value
34 | e.DataTypeURL = in.Data.TypeUrl
35 | }
36 |
37 | if in.HttpExtension != nil {
38 | e.Verb = in.HttpExtension.Verb.String()
39 | e.QueryString = in.HttpExtension.Querystring
40 | }
41 | }
42 |
43 | ct, er := fn(ctx, e)
44 | if er != nil {
45 | return nil, errors.Wrap(er, "error executing handler")
46 | }
47 |
48 | if ct == nil {
49 | return &cpb.InvokeResponse{}, nil
50 | }
51 |
52 | return &cpb.InvokeResponse{
53 | ContentType: ct.ContentType,
54 | Data: &any.Any{
55 | Value: ct.Data,
56 | TypeUrl: ct.DataTypeURL,
57 | },
58 | }, nil
59 | }
60 | return nil, fmt.Errorf("method not implemented: %s", in.Method)
61 | }
62 |
--------------------------------------------------------------------------------
/service/http/binding_test.go:
--------------------------------------------------------------------------------
1 | package http
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "net/http"
7 | "net/http/httptest"
8 | "strings"
9 | "testing"
10 |
11 | "github.com/dapr/go-sdk/service/common"
12 | "github.com/stretchr/testify/assert"
13 | )
14 |
15 | func TestBindingHandlerWithoutData(t *testing.T) {
16 | s := newServer("", nil)
17 | err := s.AddBindingInvocationHandler("/", func(ctx context.Context, in *common.BindingEvent) (out []byte, err error) {
18 | if in == nil {
19 | return nil, errors.New("nil input")
20 | }
21 | if in.Data != nil {
22 | return nil, errors.New("invalid input data")
23 | }
24 | return nil, nil
25 | })
26 | assert.NoErrorf(t, err, "error adding binding event handler")
27 |
28 | req, err := http.NewRequest(http.MethodPost, "/", nil)
29 | assert.NoErrorf(t, err, "error creating request")
30 | req.Header.Set("Content-Type", "application/json")
31 |
32 | resp := httptest.NewRecorder()
33 | s.mux.ServeHTTP(resp, req)
34 | assert.Equal(t, http.StatusOK, resp.Code)
35 | assert.Equal(t, "{}", resp.Body.String())
36 | }
37 |
38 | func TestBindingHandlerWithData(t *testing.T) {
39 | data := `{"name": "test"}`
40 | s := newServer("", nil)
41 | err := s.AddBindingInvocationHandler("/", func(ctx context.Context, in *common.BindingEvent) (out []byte, err error) {
42 | if in == nil {
43 | return nil, errors.New("nil input")
44 | }
45 | return []byte("test"), nil
46 | })
47 | assert.NoErrorf(t, err, "error adding binding event handler")
48 |
49 | req, err := http.NewRequest(http.MethodPost, "/", strings.NewReader(data))
50 | assert.NoErrorf(t, err, "error creating request")
51 | req.Header.Set("Content-Type", "application/json")
52 |
53 | resp := httptest.NewRecorder()
54 | s.mux.ServeHTTP(resp, req)
55 | assert.Equal(t, http.StatusOK, resp.Code)
56 | assert.Equal(t, "test", resp.Body.String())
57 | }
58 |
--------------------------------------------------------------------------------
/service/http/service.go:
--------------------------------------------------------------------------------
1 | package http
2 |
3 | import (
4 | "net/http"
5 |
6 | "github.com/dapr/go-sdk/service/common"
7 | )
8 |
9 | // NewService creates new Service
10 | func NewService(address string) common.Service {
11 | return newServer(address, nil)
12 | }
13 |
14 | // NewServiceWithMux creates new Service with existing http mux
15 | func NewServiceWithMux(address string, mux *http.ServeMux) common.Service {
16 | return newServer(address, mux)
17 | }
18 |
19 | func newServer(address string, mux *http.ServeMux) *Server {
20 | if mux == nil {
21 | mux = http.NewServeMux()
22 | }
23 | return &Server{
24 | address: address,
25 | mux: mux,
26 | topicSubscriptions: make([]*common.Subscription, 0),
27 | }
28 | }
29 |
30 | // Server is the HTTP server wrapping mux many Dapr helpers
31 | type Server struct {
32 | address string
33 | mux *http.ServeMux
34 | topicSubscriptions []*common.Subscription
35 | }
36 |
37 | // Start starts the HTTP handler. Blocks while serving
38 | func (s *Server) Start() error {
39 | s.registerSubscribeHandler()
40 | server := http.Server{
41 | Addr: s.address,
42 | Handler: s.mux,
43 | }
44 | return server.ListenAndServe()
45 | }
46 |
47 | // Stop stops previously started HTTP service
48 | func (s *Server) Stop() error {
49 | // TODO: implement service stop
50 | return nil
51 | }
52 |
53 | func optionsHandler(h http.Handler) http.HandlerFunc {
54 | return func(w http.ResponseWriter, r *http.Request) {
55 | if r.Method == http.MethodOptions {
56 | w.Header().Set("Access-Control-Allow-Origin", "*")
57 | w.Header().Set("Access-Control-Allow-Methods", "POST,OPTIONS")
58 | w.Header().Set("Access-Control-Allow-Headers", "authorization, origin, content-type, accept")
59 | w.Header().Set("Allow", "POST,OPTIONS")
60 | } else {
61 | h.ServeHTTP(w, r)
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/service/grpc/invoke_test.go:
--------------------------------------------------------------------------------
1 | package grpc
2 |
3 | import (
4 | "context"
5 | "testing"
6 |
7 | "github.com/dapr/go-sdk/dapr/proto/common/v1"
8 | cc "github.com/dapr/go-sdk/service/common"
9 | "github.com/stretchr/testify/assert"
10 | "google.golang.org/protobuf/types/known/anypb"
11 | )
12 |
13 | func testInvokeHandler(ctx context.Context, in *cc.InvocationEvent) (out *cc.Content, err error) {
14 | if in == nil {
15 | return
16 | }
17 | out = &cc.Content{
18 | ContentType: in.ContentType,
19 | Data: in.Data,
20 | }
21 | return
22 | }
23 |
24 | // go test -timeout 30s ./service/grpc -count 1 -run ^TestInvoke$
25 | func TestInvoke(t *testing.T) {
26 | methodName := "test"
27 | ctx := context.Background()
28 |
29 | server := getTestServer()
30 | err := server.AddServiceInvocationHandler(methodName, testInvokeHandler)
31 | assert.Nil(t, err)
32 | startTestServer(server)
33 |
34 | t.Run("invoke without request", func(t *testing.T) {
35 | _, err := server.OnInvoke(ctx, nil)
36 | assert.Error(t, err)
37 | })
38 |
39 | t.Run("invoke request with invalid method name", func(t *testing.T) {
40 | in := &common.InvokeRequest{Method: "invalid"}
41 | _, err := server.OnInvoke(ctx, in)
42 | assert.Error(t, err)
43 | })
44 |
45 | t.Run("invoke request without data", func(t *testing.T) {
46 | in := &common.InvokeRequest{Method: methodName}
47 | _, err := server.OnInvoke(ctx, in)
48 | assert.NoError(t, err)
49 | })
50 |
51 | t.Run("invoke request with data", func(t *testing.T) {
52 | data := "hello there"
53 | dataContentType := "text/plain"
54 | in := &common.InvokeRequest{Method: methodName}
55 | in.Data = &anypb.Any{Value: []byte(data)}
56 | in.ContentType = dataContentType
57 | out, err := server.OnInvoke(ctx, in)
58 | assert.NoError(t, err)
59 | assert.NotNil(t, out)
60 | assert.Equal(t, dataContentType, out.ContentType)
61 | assert.Equal(t, data, string(out.Data.Value))
62 | })
63 |
64 | stopTestServer(t, server)
65 | }
66 |
--------------------------------------------------------------------------------
/service/http/binding.go:
--------------------------------------------------------------------------------
1 | package http
2 |
3 | import (
4 | "context"
5 | "fmt"
6 | "io/ioutil"
7 | "net/http"
8 | "strings"
9 |
10 | "github.com/dapr/go-sdk/service/common"
11 | )
12 |
13 | // AddBindingInvocationHandler appends provided binding invocation handler with its route to the service
14 | func (s *Server) AddBindingInvocationHandler(route string, fn func(ctx context.Context, in *common.BindingEvent) (out []byte, err error)) error {
15 | if route == "" {
16 | return fmt.Errorf("binding route required")
17 | }
18 |
19 | if !strings.HasPrefix(route, "/") {
20 | route = fmt.Sprintf("/%s", route)
21 | }
22 |
23 | s.mux.Handle(route, optionsHandler(http.HandlerFunc(
24 | func(w http.ResponseWriter, r *http.Request) {
25 | var content []byte
26 | if r.ContentLength > 0 {
27 | body, err := ioutil.ReadAll(r.Body)
28 | if err != nil {
29 | http.Error(w, err.Error(), http.StatusBadRequest)
30 | return
31 | }
32 | content = body
33 | }
34 |
35 | // assuming Dapr doesn't pass multiple values for key
36 | meta := map[string]string{}
37 | for k, values := range r.Header {
38 | // TODO: Need to figure out how to parse out only the headers set in the binding + Traceparent
39 | // if k == "raceparent" || strings.HasPrefix(k, "dapr") {
40 | for _, v := range values {
41 | meta[k] = v
42 | }
43 | // }
44 | }
45 |
46 | // execute handler
47 | in := &common.BindingEvent{
48 | Data: content,
49 | Metadata: meta,
50 | }
51 | out, err := fn(r.Context(), in)
52 | if err != nil {
53 | http.Error(w, err.Error(), http.StatusInternalServerError)
54 | return
55 | }
56 |
57 | if out == nil {
58 | out = []byte("{}")
59 | }
60 |
61 | w.Header().Add("Content-Type", "application/json")
62 | if _, err := w.Write(out); err != nil {
63 | http.Error(w, err.Error(), http.StatusInternalServerError)
64 | return
65 | }
66 | })))
67 |
68 | return nil
69 | }
70 |
--------------------------------------------------------------------------------
/service/grpc/binding.go:
--------------------------------------------------------------------------------
1 | package grpc
2 |
3 | import (
4 | "context"
5 | "fmt"
6 |
7 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
8 | "github.com/dapr/go-sdk/service/common"
9 | "github.com/golang/protobuf/ptypes/empty"
10 | "github.com/pkg/errors"
11 | )
12 |
13 | // AddBindingInvocationHandler appends provided binding invocation handler with its name to the service
14 | func (s *Server) AddBindingInvocationHandler(name string, fn func(ctx context.Context, in *common.BindingEvent) (out []byte, err error)) error {
15 | if name == "" {
16 | return fmt.Errorf("binding name required")
17 | }
18 | s.bindingHandlers[name] = fn
19 | return nil
20 | }
21 |
22 | // ListInputBindings is called by Dapr to get the list of bindings the app will get invoked by. In this example, we are telling Dapr
23 | // To invoke our app with a binding named storage
24 | func (s *Server) ListInputBindings(ctx context.Context, in *empty.Empty) (*pb.ListInputBindingsResponse, error) {
25 | list := make([]string, 0)
26 | for k := range s.bindingHandlers {
27 | list = append(list, k)
28 | }
29 |
30 | return &pb.ListInputBindingsResponse{
31 | Bindings: list,
32 | }, nil
33 | }
34 |
35 | // OnBindingEvent gets invoked every time a new event is fired from a registered binding. The message carries the binding name, a payload and optional metadata
36 | func (s *Server) OnBindingEvent(ctx context.Context, in *pb.BindingEventRequest) (*pb.BindingEventResponse, error) {
37 | if in == nil {
38 | return nil, errors.New("nil binding event request")
39 | }
40 | if fn, ok := s.bindingHandlers[in.Name]; ok {
41 | e := &common.BindingEvent{
42 | Data: in.Data,
43 | Metadata: in.Metadata,
44 | }
45 | data, err := fn(ctx, e)
46 | if err != nil {
47 | return nil, errors.Wrapf(err, "error executing %s binding", in.Name)
48 | }
49 | return &pb.BindingEventResponse{
50 | Data: data,
51 | }, nil
52 | }
53 |
54 | return nil, fmt.Errorf("binding not implemented: %s", in.Name)
55 | }
56 |
--------------------------------------------------------------------------------
/service/http/invoke.go:
--------------------------------------------------------------------------------
1 | package http
2 |
3 | import (
4 | "context"
5 | "fmt"
6 | "io/ioutil"
7 | "net/http"
8 | "net/url"
9 | "strings"
10 |
11 | "github.com/dapr/go-sdk/service/common"
12 | )
13 |
14 | // AddServiceInvocationHandler appends provided service invocation handler with its route to the service
15 | func (s *Server) AddServiceInvocationHandler(route string, fn func(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error)) error {
16 | if route == "" {
17 | return fmt.Errorf("service route required")
18 | }
19 |
20 | if !strings.HasPrefix(route, "/") {
21 | route = fmt.Sprintf("/%s", route)
22 | }
23 |
24 | s.mux.Handle(route, optionsHandler(http.HandlerFunc(
25 | func(w http.ResponseWriter, r *http.Request) {
26 | // capture http args
27 | e := &common.InvocationEvent{
28 | Verb: r.Method,
29 | QueryString: valuesToMap(r.URL.Query()),
30 | ContentType: r.Header.Get("Content-type"),
31 | }
32 |
33 | // check for post with no data
34 | if r.ContentLength > 0 {
35 | content, err := ioutil.ReadAll(r.Body)
36 | if err != nil {
37 | http.Error(w, err.Error(), http.StatusBadRequest)
38 | return
39 | }
40 | e.Data = content
41 | }
42 |
43 | // execute handler
44 | o, err := fn(r.Context(), e)
45 | if err != nil {
46 | http.Error(w, err.Error(), http.StatusInternalServerError)
47 | return
48 | }
49 |
50 | // write to response if handler returned data
51 | if o != nil && o.Data != nil {
52 | if _, err := w.Write(o.Data); err != nil {
53 | http.Error(w, err.Error(), http.StatusInternalServerError)
54 | return
55 | }
56 | if o.ContentType != "" {
57 | w.Header().Set("Content-type", o.ContentType)
58 | }
59 | }
60 | })))
61 |
62 | return nil
63 | }
64 |
65 | func valuesToMap(in url.Values) map[string]string {
66 | out := map[string]string{}
67 | for k := range in {
68 | out[k] = in.Get(k)
69 | }
70 | return out
71 | }
72 |
--------------------------------------------------------------------------------
/example/serving/grpc/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "log"
7 |
8 | "github.com/dapr/go-sdk/service/common"
9 | daprd "github.com/dapr/go-sdk/service/grpc"
10 | )
11 |
12 | func main() {
13 | // create a Dapr service server
14 | s, err := daprd.NewService(":50001")
15 | if err != nil {
16 | log.Fatalf("failed to start the server: %v", err)
17 | }
18 |
19 | // add some topic subscriptions
20 | sub := &common.Subscription{
21 | PubsubName: "messages",
22 | Topic: "topic1",
23 | }
24 | if err := s.AddTopicEventHandler(sub, eventHandler); err != nil {
25 | log.Fatalf("error adding topic subscription: %v", err)
26 | }
27 |
28 | // add a service to service invocation handler
29 | if err := s.AddServiceInvocationHandler("echo", echoHandler); err != nil {
30 | log.Fatalf("error adding invocation handler: %v", err)
31 | }
32 |
33 | // add a binding invocation handler
34 | if err := s.AddBindingInvocationHandler("run", runHandler); err != nil {
35 | log.Fatalf("error adding binding handler: %v", err)
36 | }
37 |
38 | // start the server
39 | if err := s.Start(); err != nil {
40 | log.Fatalf("server error: %v", err)
41 | }
42 | }
43 |
44 | func eventHandler(ctx context.Context, e *common.TopicEvent) (retry bool, err error) {
45 | log.Printf("event - PubsubName:%s, Topic:%s, ID:%s, Data: %s", e.PubsubName, e.Topic, e.ID, e.Data)
46 | return false, nil
47 | }
48 |
49 | func echoHandler(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error) {
50 | if in == nil {
51 | err = errors.New("nil invocation parameter")
52 | return
53 | }
54 | log.Printf(
55 | "echo - ContentType:%s, Verb:%s, QueryString:%s, %s",
56 | in.ContentType, in.Verb, in.QueryString, in.Data,
57 | )
58 | out = &common.Content{
59 | Data: in.Data,
60 | ContentType: in.ContentType,
61 | DataTypeURL: in.DataTypeURL,
62 | }
63 | return
64 | }
65 |
66 | func runHandler(ctx context.Context, in *common.BindingEvent) (out []byte, err error) {
67 | log.Printf("binding - Data:%s, Meta:%v", in.Data, in.Metadata)
68 | return nil, nil
69 | }
70 |
--------------------------------------------------------------------------------
/service/grpc/binding_test.go:
--------------------------------------------------------------------------------
1 | package grpc
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "testing"
7 |
8 | "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
9 | "github.com/dapr/go-sdk/service/common"
10 | "github.com/stretchr/testify/assert"
11 | )
12 |
13 | func testBindingHandler(ctx context.Context, in *common.BindingEvent) (out []byte, err error) {
14 | if in == nil {
15 | return nil, errors.New("nil event")
16 | }
17 | return in.Data, nil
18 | }
19 |
20 | // go test -timeout 30s ./service/grpc -count 1 -run ^TestBinding$
21 | func TestBinding(t *testing.T) {
22 | ctx := context.Background()
23 | methodName := "test"
24 |
25 | server := getTestServer()
26 | err := server.AddBindingInvocationHandler(methodName, testBindingHandler)
27 | assert.Nil(t, err)
28 | startTestServer(server)
29 |
30 | t.Run("binding without event", func(t *testing.T) {
31 | _, err := server.OnBindingEvent(ctx, nil)
32 | assert.Error(t, err)
33 | })
34 |
35 | t.Run("binding event for wrong method", func(t *testing.T) {
36 | in := &runtime.BindingEventRequest{Name: "invalid"}
37 | _, err := server.OnBindingEvent(ctx, in)
38 | assert.Error(t, err)
39 | })
40 |
41 | t.Run("binding event without data", func(t *testing.T) {
42 | in := &runtime.BindingEventRequest{Name: methodName}
43 | out, err := server.OnBindingEvent(ctx, in)
44 | assert.NoError(t, err)
45 | assert.NotNil(t, out)
46 | })
47 |
48 | t.Run("binding event with data", func(t *testing.T) {
49 | data := "hello there"
50 | in := &runtime.BindingEventRequest{
51 | Name: methodName,
52 | Data: []byte(data),
53 | }
54 | out, err := server.OnBindingEvent(ctx, in)
55 | assert.NoError(t, err)
56 | assert.NotNil(t, out)
57 | assert.Equal(t, data, string(out.Data))
58 | })
59 |
60 | t.Run("binding event with metadata", func(t *testing.T) {
61 | in := &runtime.BindingEventRequest{
62 | Name: methodName,
63 | Metadata: map[string]string{"k1": "v1", "k2": "v2"},
64 | }
65 | out, err := server.OnBindingEvent(ctx, in)
66 | assert.NoError(t, err)
67 | assert.NotNil(t, out)
68 | })
69 |
70 | stopTestServer(t, server)
71 | }
72 |
--------------------------------------------------------------------------------
/example/serving/http/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "log"
7 | "net/http"
8 |
9 | "github.com/dapr/go-sdk/service/common"
10 | daprd "github.com/dapr/go-sdk/service/http"
11 | )
12 |
13 | func main() {
14 | // create a Dapr service (e.g. ":8080", "0.0.0.0:8080", "10.1.1.1:8080" )
15 | s := daprd.NewService(":8080")
16 |
17 | // add some topic subscriptions
18 | sub := &common.Subscription{
19 | PubsubName: "messages",
20 | Topic: "topic1",
21 | Route: "/events",
22 | }
23 | if err := s.AddTopicEventHandler(sub, eventHandler); err != nil {
24 | log.Fatalf("error adding topic subscription: %v", err)
25 | }
26 |
27 | // add a service to service invocation handler
28 | if err := s.AddServiceInvocationHandler("/echo", echoHandler); err != nil {
29 | log.Fatalf("error adding invocation handler: %v", err)
30 | }
31 |
32 | // add an input binding invocation handler
33 | if err := s.AddBindingInvocationHandler("/run", runHandler); err != nil {
34 | log.Fatalf("error adding binding handler: %v", err)
35 | }
36 |
37 | if err := s.Start(); err != nil && err != http.ErrServerClosed {
38 | log.Fatalf("error listenning: %v", err)
39 | }
40 | }
41 |
42 | func eventHandler(ctx context.Context, e *common.TopicEvent) (retry bool, err error) {
43 | log.Printf("event - PubsubName:%s, Topic:%s, ID:%s, Data: %s", e.PubsubName, e.Topic, e.ID, e.Data)
44 | return false, nil
45 | }
46 |
47 | func echoHandler(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error) {
48 | if in == nil {
49 | err = errors.New("invocation parameter required")
50 | return
51 | }
52 | log.Printf(
53 | "echo - ContentType:%s, Verb:%s, QueryString:%s, %s",
54 | in.ContentType, in.Verb, in.QueryString, in.Data,
55 | )
56 | out = &common.Content{
57 | Data: in.Data,
58 | ContentType: in.ContentType,
59 | DataTypeURL: in.DataTypeURL,
60 | }
61 | return
62 | }
63 |
64 | func runHandler(ctx context.Context, in *common.BindingEvent) (out []byte, err error) {
65 | log.Printf("binding - Data:%s, Meta:%v", in.Data, in.Metadata)
66 | return nil, nil
67 | }
68 |
--------------------------------------------------------------------------------
/service/grpc/service.go:
--------------------------------------------------------------------------------
1 | package grpc
2 |
3 | import (
4 | "context"
5 | "net"
6 |
7 | "github.com/pkg/errors"
8 |
9 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
10 | "github.com/dapr/go-sdk/service/common"
11 | "google.golang.org/grpc"
12 | )
13 |
14 | // NewService creates new Service.
15 | func NewService(address string) (s common.Service, err error) {
16 | if address == "" {
17 | return nil, errors.New("nil address")
18 | }
19 | lis, err := net.Listen("tcp", address)
20 | if err != nil {
21 | err = errors.Wrapf(err, "failed to TCP listen on: %s", address)
22 | return
23 | }
24 | s = newService(lis)
25 | return
26 | }
27 |
28 | // NewServiceWithListener creates new Service with specific listener.
29 | func NewServiceWithListener(lis net.Listener) common.Service {
30 | return newService(lis)
31 | }
32 |
33 | func newService(lis net.Listener) *Server {
34 | return &Server{
35 | listener: lis,
36 | invokeHandlers: make(map[string]func(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error)),
37 | topicSubscriptions: make(map[string]*topicEventHandler),
38 | bindingHandlers: make(map[string]func(ctx context.Context, in *common.BindingEvent) (out []byte, err error)),
39 | }
40 | }
41 |
42 | // Server is the gRPC service implementation for Dapr.
43 | type Server struct {
44 | listener net.Listener
45 | invokeHandlers map[string]func(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error)
46 | topicSubscriptions map[string]*topicEventHandler
47 | bindingHandlers map[string]func(ctx context.Context, in *common.BindingEvent) (out []byte, err error)
48 | }
49 |
50 | type topicEventHandler struct {
51 | component string
52 | topic string
53 | fn func(ctx context.Context, e *common.TopicEvent) (retry bool, err error)
54 | meta map[string]string
55 | }
56 |
57 | // Start registers the server and starts it.
58 | func (s *Server) Start() error {
59 | gs := grpc.NewServer()
60 | pb.RegisterAppCallbackServer(gs, s)
61 | return gs.Serve(s.listener)
62 | }
63 |
64 | // Stop stops the previously started service.
65 | func (s *Server) Stop() error {
66 | return s.listener.Close()
67 | }
68 |
--------------------------------------------------------------------------------
/client/binding.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 |
6 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
7 | "github.com/pkg/errors"
8 | )
9 |
10 | // BindingInvocation represents binding invocation request
11 | type BindingInvocation struct {
12 | // Name is name of binding to invoke.
13 | Name string
14 | // Operation is the name of the operation type for the binding to invoke
15 | Operation string
16 | // Data is the input bindings sent
17 | Data []byte
18 | // Metadata is the input binding metadata
19 | Metadata map[string]string
20 | }
21 |
22 | // BindingEvent represents the binding event handler input
23 | type BindingEvent struct {
24 | // Data is the input bindings sent
25 | Data []byte
26 | // Metadata is the input binding metadata
27 | Metadata map[string]string
28 | }
29 |
30 | // InvokeBinding invokes specific operation on the configured Dapr binding.
31 | // This method covers input, output, and bi-directional bindings.
32 | func (c *GRPCClient) InvokeBinding(ctx context.Context, in *BindingInvocation) (out *BindingEvent, err error) {
33 | if in == nil {
34 | return nil, errors.New("binding invocation required")
35 | }
36 | if in.Name == "" {
37 | return nil, errors.New("binding invocation name required")
38 | }
39 | if in.Operation == "" {
40 | return nil, errors.New("binding invocation operation required")
41 | }
42 |
43 | req := &pb.InvokeBindingRequest{
44 | Name: in.Name,
45 | Operation: in.Operation,
46 | Data: in.Data,
47 | Metadata: in.Metadata,
48 | }
49 |
50 | resp, err := c.protoClient.InvokeBinding(c.withAuthToken(ctx), req)
51 | if err != nil {
52 | return nil, errors.Wrapf(err, "error invoking binding %s/%s", in.Name, in.Operation)
53 | }
54 |
55 | out = &BindingEvent{}
56 |
57 | if resp != nil {
58 | out.Data = resp.Data
59 | out.Metadata = resp.Metadata
60 | }
61 |
62 | return
63 | }
64 |
65 | // InvokeOutputBinding invokes configured Dapr binding with data (allows nil).InvokeOutputBinding
66 | // This method differs from InvokeBinding in that it doesn't expect any content being returned from the invoked method.
67 | func (c *GRPCClient) InvokeOutputBinding(ctx context.Context, in *BindingInvocation) error {
68 | if _, err := c.InvokeBinding(ctx, in); err != nil {
69 | return errors.Wrap(err, "error invoking output binding")
70 | }
71 | return nil
72 | }
73 |
--------------------------------------------------------------------------------
/example/client/main.go:
--------------------------------------------------------------------------------
1 | package main
2 |
3 | import (
4 | "context"
5 | "fmt"
6 | "time"
7 |
8 | dapr "github.com/dapr/go-sdk/client"
9 | )
10 |
11 | func main() {
12 | // just for this demo
13 | ctx := context.Background()
14 | json := `{ "message": "hello" }`
15 | data := []byte(json)
16 | store := "statestore"
17 |
18 | // create the client
19 | client, err := dapr.NewClient()
20 | if err != nil {
21 | panic(err)
22 | }
23 | defer client.Close()
24 |
25 | // publish a message to the topic messagebus
26 | if err := client.PublishEvent(ctx, "messagebus", "demo", data); err != nil {
27 | panic(err)
28 | }
29 | fmt.Println("data published")
30 |
31 | // save state with the key key1
32 | fmt.Printf("saving data: %s\n", string(data))
33 | if err := client.SaveState(ctx, store, "key1", data); err != nil {
34 | panic(err)
35 | }
36 | fmt.Println("data saved")
37 |
38 | // get state for key key1
39 | item, err := client.GetState(ctx, store, "key1")
40 | if err != nil {
41 | panic(err)
42 | }
43 | fmt.Printf("data retrieved [key:%s etag:%s]: %s\n", item.Key, item.Etag, string(item.Value))
44 |
45 | // save state with options
46 | item2 := &dapr.SetStateItem{
47 | Etag: "2",
48 | Key: item.Key,
49 | Metadata: map[string]string{
50 | "created-on": time.Now().UTC().String(),
51 | },
52 | Value: item.Value,
53 | Options: &dapr.StateOptions{
54 | Concurrency: dapr.StateConcurrencyLastWrite,
55 | Consistency: dapr.StateConsistencyStrong,
56 | },
57 | }
58 | if err := client.SaveStateItems(ctx, store, item2); err != nil {
59 | panic(err)
60 | }
61 | fmt.Println("data item saved")
62 |
63 | // delete state for key key1
64 | if err := client.DeleteState(ctx, store, "key1"); err != nil {
65 | panic(err)
66 | }
67 | fmt.Println("data deleted")
68 |
69 | // invoke a method called EchoMethod on another dapr enabled service
70 | content := &dapr.DataContent{
71 | ContentType: "text/plain",
72 | Data: []byte("hellow"),
73 | }
74 | resp, err := client.InvokeServiceWithContent(ctx, "serving", "echo", content)
75 | if err != nil {
76 | panic(err)
77 | }
78 | fmt.Printf("service method invoked, response: %s", string(resp))
79 |
80 | in := &dapr.BindingInvocation{
81 | Name: "example-http-binding",
82 | Operation: "create",
83 | }
84 | if err := client.InvokeOutputBinding(ctx, in); err != nil {
85 | panic(err)
86 | }
87 | fmt.Println("output binding invoked")
88 | fmt.Println("DONE (CTRL+C to Exit)")
89 | }
90 |
--------------------------------------------------------------------------------
/client/invoke.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 |
6 | v1 "github.com/dapr/go-sdk/dapr/proto/common/v1"
7 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
8 | anypb "github.com/golang/protobuf/ptypes/any"
9 | "github.com/pkg/errors"
10 | )
11 |
12 | // DataContent the service invocation content
13 | type DataContent struct {
14 | // Data is the input data
15 | Data []byte
16 | // ContentType is the type of the data content
17 | ContentType string
18 | }
19 |
20 | func (c *GRPCClient) invokeServiceWithRequest(ctx context.Context, req *pb.InvokeServiceRequest) (out []byte, err error) {
21 | if req == nil {
22 | return nil, errors.New("nil request")
23 | }
24 |
25 | resp, err := c.protoClient.InvokeService(c.withAuthToken(ctx), req)
26 | if err != nil {
27 | return nil, errors.Wrap(err, "error invoking service")
28 | }
29 |
30 | // allow for service to not return any value
31 | if resp != nil && resp.GetData() != nil {
32 | out = resp.GetData().Value
33 | return
34 | }
35 |
36 | out = nil
37 | return
38 | }
39 |
40 | // InvokeService invokes service without raw data ([]byte).
41 | func (c *GRPCClient) InvokeService(ctx context.Context, serviceID, method string) (out []byte, err error) {
42 | if serviceID == "" {
43 | return nil, errors.New("nil serviceID")
44 | }
45 | if method == "" {
46 | return nil, errors.New("nil method")
47 | }
48 | req := &pb.InvokeServiceRequest{
49 | Id: serviceID,
50 | Message: &v1.InvokeRequest{
51 | Method: method,
52 | HttpExtension: &v1.HTTPExtension{
53 | Verb: v1.HTTPExtension_POST,
54 | },
55 | },
56 | }
57 | return c.invokeServiceWithRequest(ctx, req)
58 | }
59 |
60 | // InvokeServiceWithContent invokes service without content (data + content type).
61 | func (c *GRPCClient) InvokeServiceWithContent(ctx context.Context, serviceID, method string, content *DataContent) (out []byte, err error) {
62 | if serviceID == "" {
63 | return nil, errors.New("serviceID is required")
64 | }
65 | if method == "" {
66 | return nil, errors.New("method name is required")
67 | }
68 | if content == nil {
69 | return nil, errors.New("content required")
70 | }
71 |
72 | req := &pb.InvokeServiceRequest{
73 | Id: serviceID,
74 | Message: &v1.InvokeRequest{
75 | Method: method,
76 | Data: &anypb.Any{Value: content.Data},
77 | ContentType: content.ContentType,
78 | HttpExtension: &v1.HTTPExtension{
79 | Verb: v1.HTTPExtension_POST,
80 | },
81 | },
82 | }
83 |
84 | return c.invokeServiceWithRequest(ctx, req)
85 | }
86 |
--------------------------------------------------------------------------------
/service/http/invoke_test.go:
--------------------------------------------------------------------------------
1 | package http
2 |
3 | import (
4 | "context"
5 | "errors"
6 | "io/ioutil"
7 | "net/http"
8 | "net/http/httptest"
9 | "strings"
10 | "testing"
11 |
12 | "github.com/dapr/go-sdk/service/common"
13 | "github.com/stretchr/testify/assert"
14 | )
15 |
16 | func TestInvocationHandlerWithData(t *testing.T) {
17 | data := `{"name": "test", "data": hellow}`
18 | s := newServer("", nil)
19 | err := s.AddServiceInvocationHandler("/", func(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error) {
20 | if in == nil || in.Data == nil || in.ContentType == "" {
21 | err = errors.New("nil input")
22 | return
23 | }
24 | out = &common.Content{
25 | Data: in.Data,
26 | ContentType: in.ContentType,
27 | DataTypeURL: in.DataTypeURL,
28 | }
29 | return
30 | })
31 | assert.NoErrorf(t, err, "error adding event handler")
32 |
33 | req, err := http.NewRequest(http.MethodPost, "/", strings.NewReader(data))
34 | assert.NoErrorf(t, err, "error creating request")
35 | req.Header.Set("Content-Type", "application/json")
36 |
37 | resp := httptest.NewRecorder()
38 | s.mux.ServeHTTP(resp, req)
39 | assert.Equal(t, http.StatusOK, resp.Code)
40 |
41 | b, err := ioutil.ReadAll(resp.Body)
42 | assert.NoErrorf(t, err, "error reading response body")
43 | assert.Equal(t, data, string(b))
44 | }
45 |
46 | func TestInvocationHandlerWithoutInputData(t *testing.T) {
47 | s := newServer("", nil)
48 | err := s.AddServiceInvocationHandler("/", func(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error) {
49 | if in == nil || in.Data != nil {
50 | err = errors.New("nil input")
51 | return
52 | }
53 | return &common.Content{}, nil
54 | })
55 | assert.NoErrorf(t, err, "error adding event handler")
56 |
57 | req, err := http.NewRequest(http.MethodPost, "/", nil)
58 | assert.NoErrorf(t, err, "error creating request")
59 | req.Header.Set("Content-Type", "application/json")
60 |
61 | resp := httptest.NewRecorder()
62 | s.mux.ServeHTTP(resp, req)
63 | assert.Equal(t, http.StatusOK, resp.Code)
64 |
65 | b, err := ioutil.ReadAll(resp.Body)
66 | assert.NoErrorf(t, err, "error reading response body")
67 | assert.NotNil(t, b)
68 | assert.Equal(t, "", string(b))
69 | }
70 |
71 | func TestInvocationHandlerWithInvalidRoute(t *testing.T) {
72 | s := newServer("", nil)
73 | err := s.AddServiceInvocationHandler("/a", func(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error) {
74 | return nil, nil
75 | })
76 | assert.NoErrorf(t, err, "error adding event handler")
77 |
78 | req, err := http.NewRequest(http.MethodPost, "/b", nil)
79 | assert.NoErrorf(t, err, "error creating request")
80 |
81 | resp := httptest.NewRecorder()
82 | s.mux.ServeHTTP(resp, req)
83 | assert.Equal(t, http.StatusNotFound, resp.Code)
84 | }
85 |
--------------------------------------------------------------------------------
/service/common/type.go:
--------------------------------------------------------------------------------
1 | package common
2 |
3 | // TopicEvent is the content of the inbound topic message
4 | type TopicEvent struct {
5 | // ID identifies the event.
6 | ID string `json:"id"`
7 | // The version of the CloudEvents specification.
8 | SpecVersion string `json:"specversion"`
9 | // The type of event related to the originating occurrence.
10 | Type string `json:"type"`
11 | // Source identifies the context in which an event happened.
12 | Source string `json:"source"`
13 | // The content type of data value.
14 | DataContentType string `json:"datacontenttype"`
15 | // The content of the event.
16 | // Note, this is why the gRPC and HTTP implementations need separate structs for cloud events.
17 | Data interface{} `json:"data"`
18 | // Cloud event subject
19 | Subject string `json:"subject"`
20 | // The pubsub topic which publisher sent to.
21 | Topic string `json:"topic"`
22 | // PubsubName is name of the pub/sub this message came from
23 | PubsubName string `json:"pubsubname"`
24 | }
25 |
26 | // InvocationEvent represents the input and output of binding invocation
27 | type InvocationEvent struct {
28 | // Data is the payload that the input bindings sent.
29 | Data []byte `json:"data"`
30 | // ContentType of the Data
31 | ContentType string `json:"contentType"`
32 | // DataTypeURL is the resource URL that uniquely identifies the type of the serialized
33 | DataTypeURL string `json:"typeUrl,omitempty"`
34 | // Verb is the HTTP verb that was used to invoke this service.
35 | Verb string `json:"-"`
36 | // QueryString is the HTTP query string that was used to invoke this service.
37 | QueryString map[string]string `json:"-"`
38 | }
39 |
40 | // Content is a generic data content
41 | type Content struct {
42 | // Data is the payload that the input bindings sent.
43 | Data []byte `json:"data"`
44 | // ContentType of the Data
45 | ContentType string `json:"contentType"`
46 | // DataTypeURL is the resource URL that uniquely identifies the type of the serialized
47 | DataTypeURL string `json:"typeUrl,omitempty"`
48 | }
49 |
50 | // BindingEvent represents the binding event handler input
51 | type BindingEvent struct {
52 | // Data is the input bindings sent
53 | Data []byte `json:"data"`
54 | // Metadata is the input binding metadata
55 | Metadata map[string]string `json:"metadata,omitempty"`
56 | }
57 |
58 | // Subscription represents single topic subscription
59 | type Subscription struct {
60 | // PubsubName is name of the pub/sub this message came from
61 | PubsubName string `json:"pubsubname"`
62 | // Topic is the name of the topic
63 | Topic string `json:"topic"`
64 | // Route is the route of the handler where HTTP topic events should be published (not used in gRPC)
65 | Route string `json:"route"`
66 | // Metadata is the subscription metadata
67 | Metadata map[string]string `json:"metadata,omitempty"`
68 | }
69 |
--------------------------------------------------------------------------------
/example/Readme.md:
--------------------------------------------------------------------------------
1 | # Dapr go client example
2 |
3 | The `example` folder contains a Dapr enabled `serving` app and a `client` app that uses this SDK to invoke Dapr API for state and events, The `serving` app is available as HTTP or gRPC. The `client` app can target either one of these for service to service and binding invocations.
4 |
5 | To run this example, start by first launching the service in ether HTTP or gRPC:
6 |
7 | ### HTTP
8 |
9 | ```
10 | cd example/serving/http
11 | dapr run --app-id serving \
12 | --app-protocol http \
13 | --app-port 8080 \
14 | --dapr-http-port 3500 \
15 | --log-level debug \
16 | --components-path ./config \
17 | go run main.go
18 | ```
19 |
20 | ### gRPC
21 |
22 | ```
23 | cd example/serving/grpc
24 | dapr run --app-id serving \
25 | --app-protocol grpc \
26 | --app-port 50001 \
27 | --dapr-grpc-port 3500 \
28 | --log-level debug \
29 | --components-path ./config \
30 | go run main.go
31 | ```
32 |
33 | ## Client
34 |
35 | Once one of the above services is running is running, launch the client:
36 |
37 | ```
38 | cd example/client
39 | dapr run --app-id caller \
40 | --components-path ./config \
41 | --log-level debug \
42 | go run main.go
43 | ```
44 |
45 | ## API
46 |
47 | ### PubSub
48 |
49 | Publish JSON content
50 |
51 | ```shell
52 | curl -d '{ "from": "John", "to": "Lary", "message": "hi" }' \
53 | -H "Content-type: application/json" \
54 | "http://localhost:3500/v1.0/publish/messages"
55 | ```
56 |
57 | Publish XML content (read as text)
58 |
59 | ```shell
60 | curl -d 'JohnLary' \
61 | -H "Content-type: application/xml" \
62 | "http://localhost:3500/v1.0/publish/messages"
63 | ```
64 |
65 | Publish BIN content
66 |
67 | ```shell
68 | curl -d '0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40' \
69 | -H "Content-type: application/octet-stream" \
70 | "http://localhost:3500/v1.0/publish/messages"
71 | ```
72 |
73 | ### Service Invocation
74 |
75 | Invoke service with JSON payload
76 |
77 | ```shell
78 | curl -d '{ "from": "John", "to": "Lary", "message": "hi" }' \
79 | -H "Content-type: application/json" \
80 | "http://localhost:3500/v1.0/invoke/serving/method/echo"
81 | ```
82 |
83 | Invoke service with plain text message
84 |
85 | ```shell
86 | curl -d "ping" \
87 | -H "Content-type: text/plain;charset=UTF-8" \
88 | "http://localhost:3500/v1.0/invoke/serving/method/echo"
89 | ```
90 |
91 | Invoke service with no content
92 |
93 | ```shell
94 | curl -X DELETE \
95 | "http://localhost:3500/v1.0/invoke/serving/method/echo?k1=v1&k2=v2"
96 | ```
97 |
98 | ### Input Binding
99 |
100 | Uses the [config/cron.yaml](config/cron.yaml) component
--------------------------------------------------------------------------------
/service/http/topic.go:
--------------------------------------------------------------------------------
1 | package http
2 |
3 | import (
4 | "context"
5 | "encoding/json"
6 | "fmt"
7 | "net/http"
8 | "strings"
9 |
10 | "github.com/pkg/errors"
11 |
12 | "github.com/dapr/go-sdk/service/common"
13 | )
14 |
15 | const (
16 | // PubSubHandlerSuccessStatusCode is the successful ack code for pubsub event appcallback response
17 | PubSubHandlerSuccessStatusCode int = http.StatusOK
18 |
19 | // PubSubHandlerRetryStatusCode is the error response code (nack) pubsub event appcallback response
20 | PubSubHandlerRetryStatusCode int = http.StatusInternalServerError
21 |
22 | // PubSubHandlerDropStatusCode is the pubsub event appcallback response code indicating that Dapr should drop that message
23 | PubSubHandlerDropStatusCode int = http.StatusSeeOther
24 | )
25 |
26 | func (s *Server) registerSubscribeHandler() {
27 | f := func(w http.ResponseWriter, r *http.Request) {
28 | w.Header().Set("Content-Type", "application/json")
29 | if err := json.NewEncoder(w).Encode(s.topicSubscriptions); err != nil {
30 | http.Error(w, err.Error(), http.StatusInternalServerError)
31 | return
32 | }
33 | }
34 | s.mux.HandleFunc("/dapr/subscribe", f)
35 | }
36 |
37 | // AddTopicEventHandler appends provided event handler with it's name to the service
38 | func (s *Server) AddTopicEventHandler(sub *common.Subscription, fn func(ctx context.Context, e *common.TopicEvent) (retry bool, err error)) error {
39 | if sub == nil {
40 | return errors.New("subscription required")
41 | }
42 | if sub.Topic == "" {
43 | return errors.New("topic name required")
44 | }
45 | if sub.PubsubName == "" {
46 | return errors.New("pub/sub name required")
47 | }
48 | if sub.Route == "" {
49 | return errors.New("handler route name")
50 | }
51 |
52 | if !strings.HasPrefix(sub.Route, "/") {
53 | sub.Route = fmt.Sprintf("/%s", sub.Route)
54 | }
55 |
56 | s.topicSubscriptions = append(s.topicSubscriptions, sub)
57 |
58 | s.mux.Handle(sub.Route, optionsHandler(http.HandlerFunc(
59 | func(w http.ResponseWriter, r *http.Request) {
60 | // check for post with no data
61 | if r.ContentLength == 0 {
62 | http.Error(w, "nil content", PubSubHandlerDropStatusCode)
63 | return
64 | }
65 |
66 | // deserialize the event
67 | var in common.TopicEvent
68 | if err := json.NewDecoder(r.Body).Decode(&in); err != nil {
69 | fmt.Println(err.Error())
70 | http.Error(w, err.Error(), PubSubHandlerDropStatusCode)
71 | return
72 | }
73 |
74 | if in.Topic == "" {
75 | in.Topic = sub.Topic
76 | }
77 |
78 | retry, err := fn(r.Context(), &in)
79 | if err == nil {
80 | w.Header().Add("Content-Type", "application/json")
81 | w.WriteHeader(http.StatusOK)
82 | return
83 | }
84 |
85 | if retry {
86 | http.Error(w, err.Error(), PubSubHandlerRetryStatusCode)
87 | return
88 | }
89 |
90 | http.Error(w, err.Error(), PubSubHandlerDropStatusCode)
91 | })))
92 |
93 | return nil
94 | }
95 |
--------------------------------------------------------------------------------
/service/grpc/topic.go:
--------------------------------------------------------------------------------
1 | package grpc
2 |
3 | import (
4 | "context"
5 | "fmt"
6 |
7 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
8 | "github.com/dapr/go-sdk/service/common"
9 | "github.com/golang/protobuf/ptypes/empty"
10 | "github.com/pkg/errors"
11 | )
12 |
13 | // AddTopicEventHandler appends provided event handler with topic name to the service
14 | func (s *Server) AddTopicEventHandler(sub *common.Subscription, fn func(ctx context.Context, e *common.TopicEvent) (retry bool, err error)) error {
15 | if sub == nil {
16 | return errors.New("subscription required")
17 | }
18 | if sub.Topic == "" {
19 | return errors.New("topic name required")
20 | }
21 | if sub.PubsubName == "" {
22 | return errors.New("pub/sub name required")
23 | }
24 | key := fmt.Sprintf("%s-%s", sub.PubsubName, sub.Topic)
25 | s.topicSubscriptions[key] = &topicEventHandler{
26 | component: sub.PubsubName,
27 | topic: sub.Topic,
28 | fn: fn,
29 | meta: sub.Metadata,
30 | }
31 | return nil
32 | }
33 |
34 | // ListTopicSubscriptions is called by Dapr to get the list of topics in a pubsub component the app wants to subscribe to.
35 | func (s *Server) ListTopicSubscriptions(ctx context.Context, in *empty.Empty) (*pb.ListTopicSubscriptionsResponse, error) {
36 | subs := make([]*pb.TopicSubscription, 0)
37 | for _, v := range s.topicSubscriptions {
38 | sub := &pb.TopicSubscription{
39 | PubsubName: v.component,
40 | Topic: v.topic,
41 | Metadata: v.meta,
42 | }
43 | subs = append(subs, sub)
44 | }
45 |
46 | return &pb.ListTopicSubscriptionsResponse{
47 | Subscriptions: subs,
48 | }, nil
49 | }
50 |
51 | // OnTopicEvent fired whenever a message has been published to a topic that has been subscribed.
52 | // Dapr sends published messages in a CloudEvents v1.0 envelope.
53 | func (s *Server) OnTopicEvent(ctx context.Context, in *pb.TopicEventRequest) (*pb.TopicEventResponse, error) {
54 | if in == nil || in.Topic == "" || in.PubsubName == "" {
55 | // this is really Dapr issue more than the event request format.
56 | // since Dapr will not get updated until long after this event expires, just drop it
57 | return &pb.TopicEventResponse{Status: pb.TopicEventResponse_DROP}, errors.New("pub/sub and topic names required")
58 | }
59 | key := fmt.Sprintf("%s-%s", in.PubsubName, in.Topic)
60 | if h, ok := s.topicSubscriptions[key]; ok {
61 | e := &common.TopicEvent{
62 | ID: in.Id,
63 | Source: in.Source,
64 | Type: in.Type,
65 | SpecVersion: in.SpecVersion,
66 | DataContentType: in.DataContentType,
67 | Data: in.Data,
68 | Topic: in.Topic,
69 | PubsubName: in.PubsubName,
70 | }
71 | retry, err := h.fn(ctx, e)
72 | if err == nil {
73 | return &pb.TopicEventResponse{Status: pb.TopicEventResponse_SUCCESS}, nil
74 | }
75 | if retry {
76 | return &pb.TopicEventResponse{Status: pb.TopicEventResponse_RETRY}, err
77 | }
78 | return &pb.TopicEventResponse{Status: pb.TopicEventResponse_DROP}, err
79 | }
80 | return &pb.TopicEventResponse{Status: pb.TopicEventResponse_RETRY}, fmt.Errorf(
81 | "pub/sub and topic combination not configured: %s/%s",
82 | in.PubsubName, in.Topic,
83 | )
84 | }
85 |
--------------------------------------------------------------------------------
/service/http/Readme.md:
--------------------------------------------------------------------------------
1 | # Dapr HTTP Service SDK for Go
2 |
3 | Start by importing Dapr go `service/http` package:
4 |
5 | ```go
6 | daprd "github.com/dapr/go-sdk/service/http"
7 | ```
8 |
9 | ## Creating and Starting Service
10 |
11 | To create an HTTP Dapr service, first, create a Dapr callback instance with a specific address:
12 |
13 | ```go
14 | s := daprd.NewService(":8080")
15 | ```
16 |
17 | Or with address and an existing `http.ServeMux` in case you want to combine existing server implementations:
18 |
19 | ```go
20 | mux := http.NewServeMux()
21 | mux.HandleFunc("/", myOtherHandler)
22 | s := daprd.NewService(":8080", mux)
23 | ```
24 |
25 | Once you create a service instance, you can "attach" to that service any number of event, binding, and service invocation logic handlers as shown below. Onces the logic is defined, you are ready to start the service:
26 |
27 | ```go
28 | if err = s.Start(); err != nil && err != http.ErrServerClosed {
29 | log.Fatalf("error: %v", err)
30 | }
31 | ```
32 |
33 | ## Event Handling
34 |
35 | To handle events from specific topic you need to add at least one topic event handler before starting the service:
36 |
37 | ```go
38 | sub := &common.Subscription{
39 | PubsubName: "messages",
40 | Topic: "topic1",
41 | Route: "/events",
42 | }
43 | err := s.AddTopicEventHandler(sub, eventHandler)
44 | if err != nil {
45 | log.Fatalf("error adding topic subscription: %v", err)
46 | }
47 | ```
48 |
49 | The handler method itself can be any method with the expected signature:
50 |
51 | ```go
52 | func eventHandler(ctx context.Context, e *common.TopicEvent) error {
53 | log.Printf("event - PubsubName:%s, Topic:%s, ID:%s, Data: %v", e.PubsubName, e.Topic, e.ID, e.Data)
54 | // do something with the event
55 | return nil
56 | }
57 | ```
58 |
59 | ## Service Invocation Handler
60 |
61 | To handle service invocations you will need to add at least one service invocation handler before starting the service:
62 |
63 | ```go
64 | if err := s.AddServiceInvocationHandler("/echo", echoHandler); err != nil {
65 | log.Fatalf("error adding invocation handler: %v", err)
66 | }
67 | ```
68 |
69 | The handler method itself can be any method with the expected signature:
70 |
71 | ```go
72 | func echoHandler(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error) {
73 | log.Printf("echo - ContentType:%s, Verb:%s, QueryString:%s, %+v", in.ContentType, in.Verb, in.QueryString, string(in.Data))
74 | // do something with the invocation here
75 | out = &common.Content{
76 | Data: in.Data,
77 | ContentType: in.ContentType,
78 | DataTypeURL: in.DataTypeURL,
79 | }
80 | return
81 | }
82 | ```
83 |
84 | ## Binding Invocation Handler
85 |
86 | To handle binding invocations you will need to add at least one binding invocation handler before starting the service:
87 |
88 | ```go
89 | if err := s.AddBindingInvocationHandler("/run", runHandler); err != nil {
90 | log.Fatalf("error adding binding handler: %v", err)
91 | }
92 | ```
93 |
94 | The handler method itself can be any method with the expected signature:
95 |
96 | ```go
97 | func runHandler(ctx context.Context, in *common.BindingEvent) (out []byte, err error) {
98 | log.Printf("binding - Data:%v, Meta:%v", in.Data, in.Metadata)
99 | // do something with the invocation here
100 | return nil, nil
101 | }
102 | ```
103 |
104 | ## Templates
105 |
106 | To accelerate your HTTP Dapr app development in go even further you can use one of the GitHub templates integrating the HTTP Dapr callback package:
107 |
108 | * [Dapr HTTP Event Subscriber in Go](https://github.com/mchmarny/dapr-http-event-subscriber-template) - Template project to jump start your Dapr event subscriber service with HTTP development
109 | * [Dapr HTTP cron Handler in Go](https://github.com/mchmarny/dapr-http-cron-handler-template) - Template project to jump start your Dapr service development for scheduled workloads
110 |
111 |
112 | ## Contributing to Dapr go client
113 |
114 | See the [Contribution Guide](../../CONTRIBUTING.md) to get started with building and developing.
115 |
--------------------------------------------------------------------------------
/service/grpc/Readme.md:
--------------------------------------------------------------------------------
1 | # Dapr gRPC Service SDK for Go
2 |
3 | Start by importing Dapr go `service/grpc` package:
4 |
5 | ```go
6 | daprd "github.com/dapr/go-sdk/service/grpc"
7 | ```
8 |
9 | ## Creating and Starting Service
10 |
11 | To create a gRPC Dapr service, first, create a Dapr callback instance with a specific address:
12 |
13 | ```go
14 | s, err := daprd.NewService(":50001")
15 | if err != nil {
16 | log.Fatalf("failed to start the server: %v", err)
17 | }
18 | ```
19 |
20 | Or with address and an existing `net.Listener` in case you want to combine existing server listener:
21 |
22 | ```go
23 | list, err := net.Listen("tcp", "localhost:0")
24 | if err != nil {
25 | log.Fatalf("gRPC listener creation failed: %s", err)
26 | }
27 | s, err := daprd.NewService(list)
28 | if err != nil {
29 | log.Fatalf("failed to start the server: %v", err)
30 | }
31 | ```
32 |
33 | Once you create a service instance, you can "attach" to that service any number of event, binding, and service invocation logic handlers as shown below. Onces the logic is defined, you are ready to start the service:
34 |
35 | ```go
36 | if err := s.Start(); err != nil {
37 | log.Fatalf("server error: %v", err)
38 | }
39 | ```
40 |
41 |
42 | ## Event Handling
43 |
44 | To handle events from specific topic you need to add at least one topic event handler before starting the service:
45 |
46 | ```go
47 | if err := s.AddTopicEventHandler("messages", "topic1", eventHandler); err != nil {
48 | log.Fatalf("error adding topic subscription: %v", err)
49 | }
50 | ```
51 |
52 | The handler method itself can be any method with the expected signature:
53 |
54 | ```go
55 | func eventHandler(ctx context.Context, e *daprd.TopicEvent) error {
56 | log.Printf("event - PubsubName:%s, Topic:%s, ID:%s, Data: %v", e.PubsubName, e.Topic, e.ID, e.Data)
57 | // do something with the event
58 | return nil
59 | }
60 | ```
61 |
62 | ## Service Invocation Handler
63 |
64 | To handle service invocations you will need to add at least one service invocation handler before starting the service:
65 |
66 | ```go
67 | if err := s.AddServiceInvocationHandler("echo", echoHandler); err != nil {
68 | log.Fatalf("error adding invocation handler: %v", err)
69 | }
70 | ```
71 |
72 | The handler method itself can be any method with the expected signature:
73 |
74 | ```go
75 | func echoHandler(ctx context.Context, in *common.InvocationEvent) (out *common.Content, err error) {
76 | log.Printf("echo - ContentType:%s, Verb:%s, QueryString:%s, %+v", in.ContentType, in.Verb, in.QueryString, string(in.Data))
77 | // do something with the invocation here
78 | out = &common.Content{
79 | Data: in.Data,
80 | ContentType: in.ContentType,
81 | DataTypeURL: in.DataTypeURL,
82 | }
83 | return
84 | }
85 | ```
86 |
87 | ## Binding Invocation Handler
88 |
89 | To handle binding invocations you will need to add at least one binding invocation handler before starting the service:
90 |
91 | ```go
92 | if err := s.AddBindingInvocationHandler("run", runHandler); err != nil {
93 | log.Fatalf("error adding binding handler: %v", err)
94 | }
95 | ```
96 |
97 | The handler method itself can be any method with the expected signature:
98 |
99 | ```go
100 | func runHandler(ctx context.Context, in *common.BindingEvent) (out []byte, err error) {
101 | log.Printf("binding - Data:%v, Meta:%v", in.Data, in.Metadata)
102 | // do something with the invocation here
103 | return nil, nil
104 | }
105 | ```
106 |
107 | ## Templates
108 |
109 | To accelerate your gRPC Dapr app development in go even further you can use one of the GitHub templates integrating the gRPC Dapr callback package:
110 |
111 | * [Dapr gRPC Service in Go](https://github.com/mchmarny/dapr-grpc-service-template) - Template project to jump start your Dapr event subscriber service with gRPC development
112 | * [Dapr gRPC Event Subscriber in Go](https://github.com/mchmarny/dapr-grpc-event-subscriber-template) - Template project to jump start your Dapr event subscriber service with gRPC development
113 |
114 |
115 | ## Contributing to Dapr go client
116 |
117 | See the [Contribution Guide](../../CONTRIBUTING.md) to get started with building and developing.
118 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contribution Guidelines
2 |
3 | Thank you for your interest in Dapr go SDK!
4 |
5 | This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution.
6 |
7 | For details, visit https://cla.microsoft.com.
8 |
9 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
10 |
11 | This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
12 |
13 | Contributions come in many forms: submitting issues, writing code, participating in discussions and community calls.
14 |
15 | This document provides the guidelines for how to contribute to the Dapr go SDK project.
16 |
17 | ## Issues
18 |
19 | This section describes the guidelines for submitting issues
20 |
21 | ### Issue Types
22 |
23 | There are 4 types of issues:
24 |
25 | - Issue/Bug: You've found a bug with the code, and want to report it, or create an issue to track the bug.
26 | - Issue/Discussion: You have something on your mind, which requires input form others in a discussion, before it eventually manifests as a proposal.
27 | - Issue/Proposal: Used for items that propose a new idea or functionality. This allows feedback from others before code is written.
28 | - Issue/Question: Use this issue type, if you need help or have a question.
29 |
30 | ### Before You File
31 |
32 | Before you file an issue, make sure you've checked the following:
33 |
34 | 1. Check for existing issues
35 | - Before you create a new issue, please do a search in [open issues](https://github.com/dapr/go-sdk/issues) to see if the issue or feature request has already been filed.
36 | - If you find your issue already exists, make relevant comments and add your [reaction](https://github.com/blog/2119-add-reaction-to-pull-requests-issues-and-comments). Use a reaction:
37 | - 👍 up-vote
38 | - 👎 down-vote
39 | 1. For proposals
40 | - Some changes to the Dapr go SDK may require changes to the API. In that case, the best place to discuss the potential feature is the main [Dapr repo](https://github.com/dapr/dapr).
41 | - Other examples could include bindings, state stores or entirely new components.
42 |
43 | ## Contributing to Dapr go SDK
44 |
45 | This section describes the guidelines for contributing code/docs to Dapr go SDK.
46 |
47 | ### Pull Requests
48 |
49 | All contributions come through pull requests. To submit a proposed change, we recommend following this workflow:
50 |
51 | 1. Make sure there's an issue (bug or proposal) raised, which sets the expectations for the contribution you are about to make.
52 | 1. Fork the relevant repo and create a new branch
53 | 1. Create your change
54 | - Code changes require tests
55 | 1. Update relevant documentation for the change
56 | 1. Commit and open a PR
57 | 1. Wait for the CI process to finish and make sure all checks are green
58 | 1. A maintainer of the project will be assigned, and you can expect a review within a few days
59 |
60 | #### Use work-in-progress PRs for early feedback
61 |
62 | A good way to communicate before investing too much time is to create a "Work-in-progress" PR and share it with your reviewers. The standard way of doing this is to add a "[WIP]" prefix in your PR's title and assign the **do-not-merge** label. This will let people looking at your PR know that it is not well baked yet.
63 |
64 | ### Use of Third-party code
65 |
66 | - All third-party code must be placed in the `vendor/` folder.
67 | - `vendor/` folder is managed by go modules which stores the source code of third-party go dependencies. - The `vendor/` folder should not be modified manually.
68 | - Third-party code must include licenses.
69 |
70 | A non-exclusive list of code that must be places in `vendor/`:
71 |
72 | - Open source, free software, or commercially-licensed code.
73 | - Tools or libraries or protocols that are open source, free software, or commercially licensed.
74 |
75 | **Thank You!** - Your contributions to open source, large or small, make projects like this possible. Thank you for taking the time to contribute.
76 |
77 | ## Code of Conduct
78 |
79 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
80 |
--------------------------------------------------------------------------------
/Makefile:
--------------------------------------------------------------------------------
1 | RELEASE_VERSION =v0.11.0
2 | GDOC_PORT =8888
3 | PROTO_ROOT =https://raw.githubusercontent.com/dapr/dapr/master/dapr/proto/
4 |
5 | .PHONY: mod test cover service client lint protps tag docs clean help
6 | all: test
7 |
8 | tidy: ## Updates the go modules
9 | go mod tidy
10 |
11 | test: mod ## Tests the entire project
12 | go test -v \
13 | -count=1 \
14 | -race \
15 | -coverprofile=coverage.txt \
16 | -covermode=atomic \
17 | ./...
18 |
19 | cover: mod ## Displays test coverage in the client and service packages
20 | go test -coverprofile=cover-client.out ./client && go tool cover -html=cover-client.out
21 | go test -coverprofile=cover-grpc.out ./service/grpc && go tool cover -html=cover-grpc.out
22 | go test -coverprofile=cover-http.out ./service/http && go tool cover -html=cover-http.out
23 |
24 | service-http: mod ## Runs the uncompiled HTTP example service code
25 | dapr run --app-id serving \
26 | --app-protocol http \
27 | --app-port 8080 \
28 | --port 3500 \
29 | --log-level debug \
30 | --components-path example/serving/http/config \
31 | go run example/serving/http/main.go
32 |
33 | service-grpc: mod ## Runs the uncompiled gRPC example service code
34 | dapr run --app-id serving \
35 | --app-protocol grpc \
36 | --app-port 50001 \
37 | --port 3500 \
38 | --log-level debug \
39 | --components-path example/serving/grpc/config \
40 | go run example/serving/grpc/main.go
41 |
42 | client: mod ## Runs the uncompiled example client code
43 | dapr run --app-id caller \
44 | --components-path example/client/config \
45 | --log-level debug \
46 | go run example/client/main.go
47 |
48 | pubsub: ## Submits pub/sub events in different cotnent types
49 | curl -d '{ "from": "John", "to": "Lary", "message": "hi" }' \
50 | -H "Content-type: application/json" \
51 | "http://localhost:3500/v1.0/publish/messages/topic1"
52 | curl -d 'JohnLary' \
53 | -H "Content-type: application/xml" \
54 | "http://localhost:3500/v1.0/publish/messages/topic1"
55 | curl -d '0x18, 0x2d, 0x44, 0x54, 0xfb, 0x21, 0x09, 0x40' \
56 | -H "Content-type: application/octet-stream" \
57 | "http://localhost:3500/v1.0/publish/messages/topic1"
58 |
59 | invoke: ## Invokes service method with different operations
60 | curl -d '{ "from": "John", "to": "Lary", "message": "hi" }' \
61 | -H "Content-type: application/json" \
62 | "http://localhost:3500/v1.0/invoke/serving/method/echo"
63 | curl -d "ping" \
64 | -H "Content-type: text/plain;charset=UTF-8" \
65 | "http://localhost:3500/v1.0/invoke/serving/method/echo"
66 | curl -X DELETE \
67 | "http://localhost:3500/v1.0/invoke/serving/method/echo?k1=v1&k2=v2"
68 |
69 | lint: ## Lints the entire project
70 | golangci-lint run --timeout=3m
71 |
72 | docs: ## Runs godoc (in container due to mod support)
73 | docker run \
74 | --rm \
75 | -e "GOPATH=/tmp/go" \
76 | -p 127.0.0.1:$(GDOC_PORT):$(GDOC_PORT) \
77 | -v $(PWD):/tmp/go/src/ \
78 | --name godoc golang \
79 | bash -c "go get golang.org/x/tools/cmd/godoc && echo http://localhost:$(GDOC_PORT)/pkg/ && /tmp/go/bin/godoc -http=:$(GDOC_PORT)"
80 | open http://localhost:8888/pkg/client/
81 |
82 | tag: ## Creates release tag
83 | git tag $(RELEASE_VERSION)
84 | git push origin $(RELEASE_VERSION)
85 |
86 | clean: ## Cleans go and generated files in ./dapr/proto/
87 | go clean
88 | rm -fr ./dapr/proto/common/v1/*
89 | rm -fr ./dapr/proto/runtime/v1/*
90 |
91 | protos: ## Downloads proto files from dapr/dapr master and generats gRPC proto clients
92 | go install github.com/gogo/protobuf/gogoreplace
93 |
94 | wget -q $(PROTO_ROOT)/common/v1/common.proto -O ./dapr/proto/common/v1/common.proto
95 | gogoreplace 'option go_package = "github.com/dapr/dapr/pkg/proto/common/v1;common";' \
96 | 'option go_package = "github.com/dapr/go-sdk/dapr/proto/common/v1;common";' \
97 | ./dapr/proto/common/v1/common.proto
98 |
99 | wget -q $(PROTO_ROOT)/runtime/v1/appcallback.proto -O ./dapr/proto/runtime/v1/appcallback.proto
100 | gogoreplace 'option go_package = "github.com/dapr/dapr/pkg/proto/runtime/v1;runtime";' \
101 | 'option go_package = "github.com/dapr/go-sdk/dapr/proto/runtime/v1;runtime";' \
102 | ./dapr/proto/runtime/v1/appcallback.proto
103 |
104 | wget -q $(PROTO_ROOT)/runtime/v1/dapr.proto -O ./dapr/proto/runtime/v1/dapr.proto
105 | gogoreplace 'option go_package = "github.com/dapr/dapr/pkg/proto/runtime/v1;runtime";' \
106 | 'option go_package = "github.com/dapr/go-sdk/dapr/proto/runtime/v1;runtime";' \
107 | ./dapr/proto/runtime/v1/dapr.proto
108 |
109 | protoc -I . --go_out=plugins=grpc:. --go_opt=paths=source_relative ./dapr/proto/common/v1/*.proto
110 | protoc -I . --go_out=plugins=grpc:. --go_opt=paths=source_relative ./dapr/proto/runtime/v1/*.proto
111 |
112 | rm -f ./dapr/proto/common/v1/*.proto
113 | rm -f ./dapr/proto/runtime/v1/*.proto
114 |
115 | help: ## Display available commands
116 | @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk \
117 | 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
118 |
--------------------------------------------------------------------------------
/client/client_test.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 | "fmt"
6 | "net"
7 | "os"
8 | "testing"
9 |
10 | "github.com/golang/protobuf/ptypes/empty"
11 | "github.com/stretchr/testify/assert"
12 |
13 | "google.golang.org/grpc"
14 | "google.golang.org/grpc/test/bufconn"
15 | "google.golang.org/protobuf/types/known/anypb"
16 |
17 | commonv1pb "github.com/dapr/go-sdk/dapr/proto/common/v1"
18 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
19 | )
20 |
21 | const (
22 | testBufSize = 1024 * 1024
23 | )
24 |
25 | var (
26 | testClient Client
27 | )
28 |
29 | func TestMain(m *testing.M) {
30 | ctx := context.Background()
31 | c, f := getTestClient(ctx)
32 | testClient = c
33 | r := m.Run()
34 | f()
35 | os.Exit(r)
36 | }
37 |
38 | func TestNewClient(t *testing.T) {
39 | t.Run("no arg for with port", func(t *testing.T) {
40 | _, err := NewClientWithPort("")
41 | assert.Error(t, err)
42 | })
43 |
44 | t.Run("no arg for with address", func(t *testing.T) {
45 | _, err := NewClientWithAddress("")
46 | assert.Error(t, err)
47 | })
48 |
49 | t.Run("new client closed with empty token", func(t *testing.T) {
50 | c, err := NewClient()
51 | assert.NoError(t, err)
52 | c.WithAuthToken("")
53 | c.Close()
54 | })
55 | }
56 |
57 | func getTestClient(ctx context.Context) (client Client, closer func()) {
58 | s := grpc.NewServer()
59 | pb.RegisterDaprServer(s, &testDaprServer{
60 | state: make(map[string][]byte),
61 | })
62 |
63 | l := bufconn.Listen(testBufSize)
64 | go func() {
65 | if err := s.Serve(l); err != nil {
66 | logger.Fatalf("test server exited with error: %v", err)
67 | }
68 | }()
69 |
70 | d := grpc.WithContextDialer(func(context.Context, string) (net.Conn, error) {
71 | return l.Dial()
72 | })
73 |
74 | c, err := grpc.DialContext(ctx, "", d, grpc.WithInsecure())
75 | if err != nil {
76 | logger.Fatalf("failed to dial test context: %v", err)
77 | }
78 |
79 | closer = func() {
80 | l.Close()
81 | s.Stop()
82 | }
83 |
84 | client = NewClientWithConnection(c)
85 | return
86 | }
87 |
88 | type testDaprServer struct {
89 | state map[string][]byte
90 | }
91 |
92 | func (s *testDaprServer) InvokeService(ctx context.Context, req *pb.InvokeServiceRequest) (*commonv1pb.InvokeResponse, error) {
93 | if req.Message == nil {
94 | return &commonv1pb.InvokeResponse{
95 | ContentType: "text/plain",
96 | Data: &anypb.Any{
97 | Value: []byte("pong"),
98 | },
99 | }, nil
100 | }
101 | return &commonv1pb.InvokeResponse{
102 | ContentType: req.Message.ContentType,
103 | Data: req.Message.Data,
104 | }, nil
105 | }
106 |
107 | func (s *testDaprServer) GetState(ctx context.Context, req *pb.GetStateRequest) (*pb.GetStateResponse, error) {
108 | return &pb.GetStateResponse{
109 | Data: s.state[req.Key],
110 | Etag: "1",
111 | }, nil
112 | }
113 |
114 | func (s *testDaprServer) GetBulkState(ctx context.Context, in *pb.GetBulkStateRequest) (*pb.GetBulkStateResponse, error) {
115 | items := make([]*pb.BulkStateItem, 0)
116 | for _, k := range in.GetKeys() {
117 | if v, found := s.state[k]; found {
118 | item := &pb.BulkStateItem{
119 | Key: k,
120 | Etag: "1",
121 | Data: v,
122 | }
123 | items = append(items, item)
124 | }
125 | }
126 | return &pb.GetBulkStateResponse{
127 | Items: items,
128 | }, nil
129 | }
130 |
131 | func (s *testDaprServer) SaveState(ctx context.Context, req *pb.SaveStateRequest) (*empty.Empty, error) {
132 | for _, item := range req.States {
133 | s.state[item.Key] = item.Value
134 | }
135 | return &empty.Empty{}, nil
136 | }
137 |
138 | func (s *testDaprServer) DeleteState(ctx context.Context, req *pb.DeleteStateRequest) (*empty.Empty, error) {
139 | delete(s.state, req.Key)
140 | return &empty.Empty{}, nil
141 | }
142 |
143 | func (s *testDaprServer) ExecuteStateTransaction(ctx context.Context, in *pb.ExecuteStateTransactionRequest) (*empty.Empty, error) {
144 | for _, op := range in.GetOperations() {
145 | item := op.GetRequest()
146 | switch opType := op.GetOperationType(); opType {
147 | case "upsert":
148 | s.state[item.Key] = item.Value
149 | case "delete":
150 | delete(s.state, item.Key)
151 | default:
152 | return &empty.Empty{}, fmt.Errorf("invalid operation type: %s", opType)
153 | }
154 | }
155 | return &empty.Empty{}, nil
156 | }
157 |
158 | func (s *testDaprServer) PublishEvent(ctx context.Context, req *pb.PublishEventRequest) (*empty.Empty, error) {
159 | return &empty.Empty{}, nil
160 | }
161 |
162 | func (s *testDaprServer) InvokeBinding(ctx context.Context, req *pb.InvokeBindingRequest) (*pb.InvokeBindingResponse, error) {
163 | if req.Data == nil {
164 | return &pb.InvokeBindingResponse{
165 | Data: []byte("test"),
166 | Metadata: map[string]string{"k1": "v1", "k2": "v2"},
167 | }, nil
168 | }
169 | return &pb.InvokeBindingResponse{
170 | Data: req.Data,
171 | Metadata: req.Metadata,
172 | }, nil
173 | }
174 |
175 | func (s *testDaprServer) GetSecret(ctx context.Context, req *pb.GetSecretRequest) (*pb.GetSecretResponse, error) {
176 | d := make(map[string]string)
177 | d["test"] = "value"
178 | return &pb.GetSecretResponse{
179 | Data: d,
180 | }, nil
181 | }
182 |
--------------------------------------------------------------------------------
/client/client.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 | "log"
6 | "net"
7 | "os"
8 | "sync"
9 |
10 | "github.com/pkg/errors"
11 | "google.golang.org/grpc"
12 | "google.golang.org/grpc/metadata"
13 |
14 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
15 | )
16 |
17 | const (
18 | daprPortDefault = "50001"
19 | daprPortEnvVarName = "DAPR_GRPC_PORT"
20 | traceparentKey = "traceparent"
21 | apiTokenKey = "dapr-api-token"
22 | apiTokenEnvVarName = "DAPR_API_TOKEN"
23 | )
24 |
25 | var (
26 | logger = log.New(os.Stdout, "", 0)
27 | _ Client = (*GRPCClient)(nil)
28 | defaultClient Client
29 | doOnce sync.Once
30 | )
31 |
32 | // Client is the interface for Dapr client implementation.
33 | type Client interface {
34 | // InvokeBinding invokes specific operation on the configured Dapr binding.
35 | // This method covers input, output, and bi-directional bindings.
36 | InvokeBinding(ctx context.Context, in *BindingInvocation) (out *BindingEvent, err error)
37 |
38 | // InvokeOutputBinding invokes configured Dapr binding with data.InvokeOutputBinding
39 | // This method differs from InvokeBinding in that it doesn't expect any content being returned from the invoked method.
40 | InvokeOutputBinding(ctx context.Context, in *BindingInvocation) error
41 |
42 | // InvokeService invokes service without raw data
43 | InvokeService(ctx context.Context, serviceID, method string) (out []byte, err error)
44 |
45 | // InvokeServiceWithContent invokes service with content
46 | InvokeServiceWithContent(ctx context.Context, serviceID, method string, content *DataContent) (out []byte, err error)
47 |
48 | // PublishEvent pubishes data onto topic in specific pubsub component.
49 | PublishEvent(ctx context.Context, component, topic string, in []byte) error
50 |
51 | // GetSecret retreaves preconfigred secret from specified store using key.
52 | GetSecret(ctx context.Context, store, key string, meta map[string]string) (out map[string]string, err error)
53 |
54 | // SaveState saves the raw data into store using default state options.
55 | SaveState(ctx context.Context, store, key string, data []byte) error
56 |
57 | // SaveStateItems saves multiple state item to store with specified options.
58 | SaveStateItems(ctx context.Context, store string, items ...*SetStateItem) error
59 |
60 | // GetState retreaves state from specific store using default consistency option.
61 | GetState(ctx context.Context, store, key string) (item *StateItem, err error)
62 |
63 | // GetStateWithConsistency retreaves state from specific store using provided state consistency.
64 | GetStateWithConsistency(ctx context.Context, store, key string, meta map[string]string, sc StateConsistency) (item *StateItem, err error)
65 |
66 | // GetBulkItems retreaves state for multiple keys from specific store.
67 | GetBulkItems(ctx context.Context, store string, keys []string, parallelism int32) ([]*StateItem, error)
68 |
69 | // DeleteState deletes content from store using default state options.
70 | DeleteState(ctx context.Context, store, key string) error
71 |
72 | // DeleteStateWithETag deletes content from store using provided state options and etag.
73 | DeleteStateWithETag(ctx context.Context, store, key, etag string, meta map[string]string, opts *StateOptions) error
74 |
75 | // ExecuteStateTransaction provides way to execute multiple operations on a specified store.
76 | ExecuteStateTransaction(ctx context.Context, store string, meta map[string]string, ops []*StateOperation) error
77 |
78 | // WithTraceID adds existing trace ID to the outgoing context.
79 | WithTraceID(ctx context.Context, id string) context.Context
80 |
81 | // WithAuthToken sets Dapr API token on the instantiated client.
82 | WithAuthToken(token string)
83 |
84 | // Close cleans up all resources created by the client.
85 | Close()
86 | }
87 |
88 | // NewClient instantiates Dapr client using DAPR_GRPC_PORT environment variable as port.
89 | // Note, this default factory function creates Dapr client only once. All subsequent invocations
90 | // will return the already created instance. To create multiple instances of the Dapr client,
91 | // use one of the parameterized factory functions:
92 | // NewClientWithPort(port string) (client Client, err error)
93 | // NewClientWithAddress(address string) (client Client, err error)
94 | // NewClientWithConnection(conn *grpc.ClientConn) Client
95 | func NewClient() (client Client, err error) {
96 | port := os.Getenv(daprPortEnvVarName)
97 | if port == "" {
98 | port = daprPortDefault
99 | }
100 | var onceErr error
101 | doOnce.Do(func() {
102 | c, err := NewClientWithPort(port)
103 | onceErr = errors.Wrap(err, "error creating default client")
104 | defaultClient = c
105 | })
106 |
107 | return defaultClient, onceErr
108 | }
109 |
110 | // NewClientWithPort instantiates Dapr using specific port.
111 | func NewClientWithPort(port string) (client Client, err error) {
112 | if port == "" {
113 | return nil, errors.New("nil port")
114 | }
115 | return NewClientWithAddress(net.JoinHostPort("127.0.0.1", port))
116 | }
117 |
118 | // NewClientWithAddress instantiates Dapr using specific address (inclding port).
119 | func NewClientWithAddress(address string) (client Client, err error) {
120 | if address == "" {
121 | return nil, errors.New("nil address")
122 | }
123 | logger.Printf("dapr client initializing for: %s", address)
124 | conn, err := grpc.Dial(address, grpc.WithInsecure())
125 | if err != nil {
126 | return nil, errors.Wrapf(err, "error creating connection to '%s': %v", address, err)
127 | }
128 | if hasToken := os.Getenv(apiTokenEnvVarName); hasToken != "" {
129 | logger.Println("client uses API token")
130 | }
131 | return NewClientWithConnection(conn), nil
132 | }
133 |
134 | // NewClientWithConnection instantiates Dapr client using specific connection.
135 | func NewClientWithConnection(conn *grpc.ClientConn) Client {
136 | return &GRPCClient{
137 | connection: conn,
138 | protoClient: pb.NewDaprClient(conn),
139 | authToken: os.Getenv(apiTokenEnvVarName),
140 | }
141 | }
142 |
143 | // GRPCClient is the gRPC implementation of Dapr client.
144 | type GRPCClient struct {
145 | connection *grpc.ClientConn
146 | protoClient pb.DaprClient
147 | authToken string
148 | mux sync.Mutex
149 | }
150 |
151 | // Close cleans up all resources created by the client.
152 | func (c *GRPCClient) Close() {
153 | if c.connection != nil {
154 | c.connection.Close()
155 | }
156 | }
157 |
158 | // WithAuthToken sets Dapr API token on the instantiated client.
159 | // Allows empty string to reset token on existing client
160 | func (c *GRPCClient) WithAuthToken(token string) {
161 | c.mux.Lock()
162 | c.authToken = token
163 | c.mux.Unlock()
164 | }
165 |
166 | // WithTraceID adds existing trace ID to the outgoing context
167 | func (c *GRPCClient) WithTraceID(ctx context.Context, id string) context.Context {
168 | if id == "" {
169 | return ctx
170 | }
171 | logger.Printf("using trace parent ID: %s", id)
172 | md := metadata.Pairs(traceparentKey, id)
173 | return metadata.NewOutgoingContext(ctx, md)
174 | }
175 |
176 | func (c *GRPCClient) withAuthToken(ctx context.Context) context.Context {
177 | if c.authToken == "" {
178 | return ctx
179 | }
180 | return metadata.NewOutgoingContext(ctx, metadata.Pairs(apiTokenKey, string(c.authToken)))
181 | }
182 |
--------------------------------------------------------------------------------
/client/state_test.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 | "testing"
6 | "time"
7 |
8 | v1 "github.com/dapr/go-sdk/dapr/proto/common/v1"
9 | "github.com/stretchr/testify/assert"
10 | )
11 |
12 | func TestDurationConverter(t *testing.T) {
13 | d := time.Duration(10 * time.Second)
14 | pd := toProtoDuration(d)
15 | assert.NotNil(t, pd)
16 | assert.Equal(t, pd.Seconds, int64(10))
17 | }
18 |
19 | func TestStateOptionsConverter(t *testing.T) {
20 | s := &StateOptions{
21 | Concurrency: StateConcurrencyLastWrite,
22 | Consistency: StateConsistencyStrong,
23 | }
24 | p := toProtoStateOptions(s)
25 | assert.NotNil(t, p)
26 | assert.Equal(t, p.Concurrency, v1.StateOptions_CONCURRENCY_LAST_WRITE)
27 | assert.Equal(t, p.Consistency, v1.StateOptions_CONSISTENCY_STRONG)
28 | }
29 |
30 | // go test -timeout 30s ./client -count 1 -run ^TestSaveState$
31 | func TestSaveState(t *testing.T) {
32 | ctx := context.Background()
33 | data := "test"
34 | store := "test"
35 | key := "key1"
36 |
37 | t.Run("save data", func(t *testing.T) {
38 | err := testClient.SaveState(ctx, store, key, []byte(data))
39 | assert.Nil(t, err)
40 | })
41 |
42 | t.Run("get saved data", func(t *testing.T) {
43 | item, err := testClient.GetState(ctx, store, key)
44 | assert.Nil(t, err)
45 | assert.NotNil(t, item)
46 | assert.NotEmpty(t, item.Etag)
47 | assert.Equal(t, item.Key, key)
48 | assert.Equal(t, string(item.Value), data)
49 | })
50 |
51 | t.Run("get saved data with consistency", func(t *testing.T) {
52 | item, err := testClient.GetStateWithConsistency(ctx, store, key, nil, StateConsistencyStrong)
53 | assert.Nil(t, err)
54 | assert.NotNil(t, item)
55 | assert.NotEmpty(t, item.Etag)
56 | assert.Equal(t, item.Key, key)
57 | assert.Equal(t, string(item.Value), data)
58 | })
59 |
60 | t.Run("save data with version", func(t *testing.T) {
61 | item := &SetStateItem{
62 | Etag: "1",
63 | Key: key,
64 | Value: []byte(data),
65 | }
66 | err := testClient.SaveStateItems(ctx, store, item)
67 | assert.Nil(t, err)
68 | })
69 |
70 | t.Run("delete data", func(t *testing.T) {
71 | err := testClient.DeleteState(ctx, store, key)
72 | assert.Nil(t, err)
73 | })
74 | }
75 |
76 | // go test -timeout 30s ./client -count 1 -run ^TestDeleteState$
77 | func TestDeleteState(t *testing.T) {
78 | ctx := context.Background()
79 | data := "test"
80 | store := "test"
81 | key := "key1"
82 |
83 | t.Run("delete not exist data", func(t *testing.T) {
84 | err := testClient.DeleteState(ctx, store, key)
85 | assert.Nil(t, err)
86 | })
87 | t.Run("delete not exist data with etag and meta", func(t *testing.T) {
88 | err := testClient.DeleteStateWithETag(ctx, store, key, "100", map[string]string{"meta1": "value1"},
89 | &StateOptions{Concurrency: StateConcurrencyFirstWrite, Consistency: StateConsistencyEventual})
90 | assert.Nil(t, err)
91 | })
92 |
93 | t.Run("save data", func(t *testing.T) {
94 | err := testClient.SaveState(ctx, store, key, []byte(data))
95 | assert.Nil(t, err)
96 | })
97 | t.Run("confirm data saved", func(t *testing.T) {
98 | item, err := testClient.GetState(ctx, store, key)
99 | assert.Nil(t, err)
100 | assert.NotNil(t, item)
101 | assert.NotEmpty(t, item.Etag)
102 | assert.Equal(t, item.Key, key)
103 | assert.Equal(t, string(item.Value), data)
104 | })
105 |
106 | t.Run("delete exist data", func(t *testing.T) {
107 | err := testClient.DeleteState(ctx, store, key)
108 | assert.Nil(t, err)
109 | })
110 | t.Run("confirm data deleted", func(t *testing.T) {
111 | item, err := testClient.GetState(ctx, store, key)
112 | assert.Nil(t, err)
113 | assert.NotNil(t, item)
114 | assert.NotEmpty(t, item.Etag)
115 | assert.Equal(t, item.Key, key)
116 | assert.Nil(t, item.Value)
117 | })
118 |
119 | t.Run("save data again with etag, meta", func(t *testing.T) {
120 | err := testClient.SaveStateItems(ctx, store, &SetStateItem{
121 | Key: key,
122 | Value: []byte(data),
123 | Etag: "100",
124 | Metadata: map[string]string{"meta1": "value1"},
125 | Options: &StateOptions{Concurrency: StateConcurrencyFirstWrite, Consistency: StateConsistencyEventual},
126 | })
127 | assert.Nil(t, err)
128 | })
129 | t.Run("confirm data saved", func(t *testing.T) {
130 | item, err := testClient.GetStateWithConsistency(ctx, store, key, map[string]string{"meta1": "value1"}, StateConsistencyEventual)
131 | assert.Nil(t, err)
132 | assert.NotNil(t, item)
133 | assert.NotEmpty(t, item.Etag)
134 | assert.Equal(t, item.Key, key)
135 | assert.Equal(t, string(item.Value), data)
136 | })
137 |
138 | t.Run("delete exist data with etag and meta", func(t *testing.T) {
139 | err := testClient.DeleteStateWithETag(ctx, store, key, "100", map[string]string{"meta1": "value1"},
140 | &StateOptions{Concurrency: StateConcurrencyFirstWrite, Consistency: StateConsistencyEventual})
141 | assert.Nil(t, err)
142 | })
143 | t.Run("confirm data deleted", func(t *testing.T) {
144 | item, err := testClient.GetStateWithConsistency(ctx, store, key, map[string]string{"meta1": "value1"}, StateConsistencyEventual)
145 | assert.Nil(t, err)
146 | assert.NotNil(t, item)
147 | assert.NotEmpty(t, item.Etag)
148 | assert.Equal(t, item.Key, key)
149 | assert.Nil(t, item.Value)
150 | })
151 | }
152 |
153 | // go test -timeout 30s ./client -count 1 -run ^TestStateTransactions$
154 | func TestStateTransactions(t *testing.T) {
155 | ctx := context.Background()
156 | data := `{ "message": "test" }`
157 | store := "test"
158 | meta := map[string]string{}
159 | keys := []string{"k1", "k2", "k3"}
160 | adds := make([]*StateOperation, 0)
161 |
162 | for _, k := range keys {
163 | op := &StateOperation{
164 | Type: StateOperationTypeUpsert,
165 | Item: &SetStateItem{
166 | Key: k,
167 | Value: []byte(data),
168 | },
169 | }
170 | adds = append(adds, op)
171 | }
172 |
173 | t.Run("exec inserts", func(t *testing.T) {
174 | err := testClient.ExecuteStateTransaction(ctx, store, meta, adds)
175 | assert.Nil(t, err)
176 | })
177 |
178 | t.Run("exec upserts", func(t *testing.T) {
179 | items, err := testClient.GetBulkItems(ctx, store, keys, 10)
180 | assert.Nil(t, err)
181 | assert.NotNil(t, items)
182 | assert.Len(t, items, len(keys))
183 |
184 | upsers := make([]*StateOperation, 0)
185 | for _, item := range items {
186 | op := &StateOperation{
187 | Type: StateOperationTypeUpsert,
188 | Item: &SetStateItem{
189 | Key: item.Key,
190 | Etag: item.Etag,
191 | Value: item.Value,
192 | },
193 | }
194 | upsers = append(upsers, op)
195 | }
196 | err = testClient.ExecuteStateTransaction(ctx, store, meta, upsers)
197 | assert.Nil(t, err)
198 | })
199 |
200 | t.Run("get and validate inserts", func(t *testing.T) {
201 | items, err := testClient.GetBulkItems(ctx, store, keys, 10)
202 | assert.Nil(t, err)
203 | assert.NotNil(t, items)
204 | assert.Len(t, items, len(keys))
205 | assert.Equal(t, data, string(items[0].Value))
206 | })
207 |
208 | for _, op := range adds {
209 | op.Type = StateOperationTypeDelete
210 | }
211 |
212 | t.Run("exec deletes", func(t *testing.T) {
213 | err := testClient.ExecuteStateTransaction(ctx, store, meta, adds)
214 | assert.Nil(t, err)
215 | })
216 |
217 | t.Run("ensure deletes", func(t *testing.T) {
218 | items, err := testClient.GetBulkItems(ctx, store, keys, 3)
219 | assert.Nil(t, err)
220 | assert.NotNil(t, items)
221 | assert.Len(t, items, 0)
222 | })
223 |
224 | }
225 |
--------------------------------------------------------------------------------
/Readme.md:
--------------------------------------------------------------------------------
1 | # Dapr SDK for Go
2 |
3 | Client library to help you build Dapr application in go. This client supports all public [Dapr APIs](https://github.com/dapr/docs/tree/master/reference/api) while focusing on idiomatic go experience and developer productivity.
4 |
5 | [](https://github.com/dapr/go-sdk/actions?query=workflow%3ATest) [](https://github.com/dapr/go-sdk/actions?query=workflow%3ARelease) [](https://goreportcard.com/report/github.com/dapr/go-sdk)  [](https://codecov.io/gh/dapr/go-sdk)
6 |
7 | ## Usage
8 |
9 | > Assuming you already have [installed](https://golang.org/doc/install) go
10 |
11 | Dapr go client includes two packages: `client` (for invoking public Dapr API), and `service` (to create services that will be invoked by Dapr, this is sometimes refereed to as "callback").
12 |
13 | ### Creating client
14 |
15 | Import Dapr go `client` package:
16 |
17 | ```go
18 | import "github.com/dapr/go-sdk/client"
19 | ```
20 |
21 | #### Quick start
22 |
23 | ```go
24 | package main
25 |
26 | import (
27 | dapr "github.com/dapr/go-sdk/client"
28 | )
29 |
30 | func main() {
31 | client, err := dapr.NewClient()
32 | if err != nil {
33 | panic(err)
34 | }
35 | defer client.Close()
36 | //TODO: use the client here, see below for examples
37 | }
38 | ```
39 |
40 | Assuming you have [Dapr CLI](https://github.com/dapr/docs/blob/master/getting-started/environment-setup.md) installed, you can then launch your app locally like this:
41 |
42 | ```shell
43 | dapr run --app-id example-service \
44 | --app-protocol grpc \
45 | --app-port 50001 \
46 | go run main.go
47 | ```
48 |
49 | See the [example folder](./example) for more working Dapr client examples.
50 |
51 | #### Usage
52 |
53 | The go client supports all the building blocks exposed by Dapr API. Let's review these one by one:
54 |
55 |
56 | ##### State
57 |
58 | For simple use-cases, Dapr client provides easy to use `Save`, `Get`, and `Delete` methods:
59 |
60 | ```go
61 | ctx := context.Background()
62 | data := []byte("hello")
63 | store := "my-store" // defined in the component YAML
64 |
65 | // save state with the key key1
66 | if err := client.SaveState(ctx, store, "key1", data); err != nil {
67 | panic(err)
68 | }
69 |
70 | // get state for key key1
71 | item, err := client.GetState(ctx, store, "key1")
72 | if err != nil {
73 | panic(err)
74 | }
75 | fmt.Printf("data [key:%s etag:%s]: %s", item.Key, item.Etag, string(item.Value))
76 |
77 | // delete state for key key1
78 | if err := client.DeleteState(ctx, store, "key1"); err != nil {
79 | panic(err)
80 | }
81 | ```
82 |
83 | For more granular control, the Dapr go client exposes `SetStateItem` type, which can be use to gain more control over the state operations and allow for multiple items to be saved at once:
84 |
85 | ```go
86 | item1 := &dapr.SetStateItem{
87 | Key: "key1",
88 | Etag: "2",
89 | Metadata: map[string]string{
90 | "created-on": time.Now().UTC().String(),
91 | },
92 | Value: []byte("hello"),
93 | Options: &dapr.StateOptions{
94 | Concurrency: dapr.StateConcurrencyLastWrite,
95 | Consistency: dapr.StateConsistencyStrong,
96 | },
97 | }
98 |
99 | item2 := &dapr.SetStateItem{
100 | Key: "key2",
101 | Metadata: map[string]string{
102 | "created-on": time.Now().UTC().String(),
103 | },
104 | Value: []byte("hello again"),
105 | }
106 |
107 | item3 := &dapr.SetStateItem{
108 | Key: "key3",
109 | Etag: "1",
110 | Value: []byte("hello again"),
111 | }
112 |
113 | if err := client.SaveStateItems(ctx, store, item1, item2, item3); err != nil {
114 | panic(err)
115 | }
116 | ```
117 |
118 | Similarly, `GetBulkItems` method provides a way to retrieve multiple state items in a single operation:
119 |
120 | ```go
121 | keys := []string{"key1", "key2", "key3"}
122 | items, err := client.GetBulkItems(ctx, store, keys, 100)
123 | ```
124 |
125 | And the `ExecuteStateTransaction` method to execute multiple `upsert` or `delete` operations transactionally.
126 |
127 | ```go
128 | ops := make([]*dapr.StateOperation, 0)
129 |
130 | op1 := &dapr.StateOperation{
131 | Type: dapr.StateOperationTypeUpsert,
132 | Item: &dapr.SetStateItem{
133 | Key: "key1",
134 | Value: []byte(data),
135 | },
136 | }
137 | op2 := &dapr.StateOperation{
138 | Type: dapr.StateOperationTypeDelete,
139 | Item: &dapr.SetStateItem{
140 | Key: "key2",
141 | },
142 | }
143 | ops = append(ops, op1, op2)
144 | meta := map[string]string{}
145 | err := testClient.ExecuteStateTransaction(ctx, store, meta, ops)
146 | ```
147 |
148 | ##### PubSub
149 |
150 | To publish data onto a topic, the Dapr client provides a simple method:
151 |
152 | ```go
153 | data := []byte(`{ "id": "a123", "value": "abcdefg", "valid": true }`)
154 | if err := client.PublishEvent(ctx, "component-name", "topic-name", data); err != nil {
155 | panic(err)
156 | }
157 | ```
158 |
159 | ##### Service Invocation
160 |
161 | To invoke a specific method on another service running with Dapr sidecar, the Dapr client provides two options. To invoke a service without any data:
162 |
163 | ```go
164 | resp, err = client.InvokeService(ctx, "service-name", "method-name")
165 | ```
166 |
167 | And to invoke a service with data:
168 |
169 | ```go
170 | content := &dapr.DataContent{
171 | ContentType: "application/json",
172 | Data: []byte(`{ "id": "a123", "value": "demo", "valid": true }`),
173 | }
174 |
175 | resp, err := client.InvokeServiceWithContent(ctx, "service-name", "method-name", content)
176 | ```
177 |
178 | ##### Bindings
179 |
180 | Similarly to Service, Dapr client provides two methods to invoke an operation on a [Dapr-defined binding](https://github.com/dapr/docs/tree/master/concepts/bindings). Dapr supports input, output, and bidirectional bindings.
181 |
182 | For simple, output only biding:
183 |
184 | ```go
185 | in := &dapr.BindingInvocation{ Name: "binding-name", Operation: "operation-name" }
186 | err = client.InvokeOutputBinding(ctx, in)
187 | ```
188 |
189 | To invoke method with content and metadata:
190 |
191 | ```go
192 | in := &dapr.BindingInvocation{
193 | Name: "binding-name",
194 | Operation: "operation-name",
195 | Data: []byte("hello"),
196 | Metadata: map[string]string{"k1": "v1", "k2": "v2"},
197 | }
198 |
199 | out, err := client.InvokeBinding(ctx, in)
200 | ```
201 |
202 | ##### Secrets
203 |
204 | The Dapr client also provides access to the runtime secrets that can be backed by any number of secrete stores (e.g. Kubernetes Secrets, Hashicorp Vault, or Azure KeyVault):
205 |
206 | ```go
207 | opt := map[string]string{
208 | "version": "2",
209 | }
210 |
211 | secret, err := client.GetSecret(ctx, "store-name", "secret-name", opt)
212 | ```
213 |
214 |
215 | #### Authentication
216 |
217 | By default, Dapr relies on the network boundary to limit access to its API. If however the target Dapr API is configured with token-based authentication, users can configure the go Dapr client with that token in two ways:
218 |
219 | ##### Environment Variable
220 |
221 | If the `DAPR_API_TOKEN` environment variable is defined, Dapr will automatically use it to augment its Dapr API invocations to ensure authentication.
222 |
223 | ##### Explicit Method
224 |
225 | In addition, users can also set the API token explicitly on any Dapr client instance. This approach is helpful in cases when the user code needs to create multiple clients for different Dapr API endpoints.
226 |
227 | ```go
228 | func main() {
229 | client, err := dapr.NewClient()
230 | if err != nil {
231 | panic(err)
232 | }
233 | defer client.Close()
234 | client.WithAuthToken("your-Dapr-API-token-here")
235 | }
236 | ```
237 |
238 | ## Service (callback)
239 |
240 | In addition to the client capabilities that allow you to call into the Dapr API, the go SDK also provides `service` package to help you bootstrap Dapr callback services in either gRPC or HTTP. Instructions on how to use it are located [here](./service/Readme.md)
241 |
242 | ## Contributing to Dapr go client
243 |
244 | See the [Contribution Guide](./CONTRIBUTING.md) to get started with building and developing.
245 |
246 | ## Code of Conduct
247 |
248 | Please refer to our [Dapr Community Code of Conduct](https://github.com/dapr/community/blob/master/CODE-OF-CONDUCT.md)
249 |
--------------------------------------------------------------------------------
/client/state.go:
--------------------------------------------------------------------------------
1 | package client
2 |
3 | import (
4 | "context"
5 | "time"
6 |
7 | v1 "github.com/dapr/go-sdk/dapr/proto/common/v1"
8 | pb "github.com/dapr/go-sdk/dapr/proto/runtime/v1"
9 | duration "github.com/golang/protobuf/ptypes/duration"
10 | "github.com/pkg/errors"
11 | )
12 |
13 | const (
14 | // StateConsistencyUndefined is the undefined value for state consistency.
15 | StateConsistencyUndefined StateConsistency = 0
16 | // StateConsistencyEventual represents eventual state consistency value.
17 | StateConsistencyEventual StateConsistency = 1
18 | // StateConsistencyStrong represents strong state consistency value.
19 | StateConsistencyStrong StateConsistency = 2
20 |
21 | // StateConcurrencyUndefined is the undefined value for state concurrency.
22 | StateConcurrencyUndefined StateConcurrency = 0
23 | // StateConcurrencyFirstWrite represents first write concurrency value.
24 | StateConcurrencyFirstWrite StateConcurrency = 1
25 | // StateConcurrencyLastWrite represents last write concurrency value.
26 | StateConcurrencyLastWrite StateConcurrency = 2
27 |
28 | // StateOperationTypeUndefined is the undefined value for state operation type.
29 | StateOperationTypeUndefined OperationType = 0
30 | // StateOperationTypeUpsert represents upsert operation type value.
31 | StateOperationTypeUpsert OperationType = 1
32 | // StateOperationTypeDelete represents delete operation type value.
33 | StateOperationTypeDelete OperationType = 2
34 | )
35 |
36 | type (
37 | // StateConsistency is the consistency enum type.
38 | StateConsistency int
39 | // StateConcurrency is the concurrency enum type.
40 | StateConcurrency int
41 | // OperationType is the operation enum type.
42 | OperationType int
43 | )
44 |
45 | // String returns the string value of the OperationType.
46 | func (o OperationType) String() string {
47 | names := [...]string{
48 | "undefined",
49 | "upsert",
50 | "delete",
51 | }
52 | if o < StateOperationTypeUpsert || o > StateOperationTypeDelete {
53 | return "undefined"
54 | }
55 |
56 | return names[o]
57 | }
58 |
59 | // String returns the string value of the StateConsistency.
60 | func (c StateConsistency) String() string {
61 | names := [...]string{
62 | "undefined",
63 | "strong",
64 | "eventual",
65 | }
66 | if c < StateConsistencyStrong || c > StateConsistencyEventual {
67 | return "undefined"
68 | }
69 |
70 | return names[c]
71 | }
72 |
73 | // String returns the string value of the StateConcurrency.
74 | func (c StateConcurrency) String() string {
75 | names := [...]string{
76 | "undefined",
77 | "first-write",
78 | "last-write",
79 | }
80 | if c < StateConcurrencyFirstWrite || c > StateConcurrencyLastWrite {
81 | return "undefined"
82 | }
83 |
84 | return names[c]
85 | }
86 |
87 | var (
88 | stateOptionDefault = &v1.StateOptions{
89 | Concurrency: v1.StateOptions_CONCURRENCY_LAST_WRITE,
90 | Consistency: v1.StateOptions_CONSISTENCY_STRONG,
91 | }
92 | )
93 |
94 | // StateOperation is a collection of StateItems with a store name.
95 | type StateOperation struct {
96 | Type OperationType
97 | Item *SetStateItem
98 | }
99 |
100 | // StateItem represents a single state item.
101 | type StateItem struct {
102 | Key string
103 | Value []byte
104 | Etag string
105 | }
106 |
107 | // SetStateItem represents a single state to be persisted.
108 | type SetStateItem struct {
109 | Key string
110 | Value []byte
111 | Etag string
112 | Metadata map[string]string
113 | Options *StateOptions
114 | }
115 |
116 | // StateOptions represents the state store persistence policy.
117 | type StateOptions struct {
118 | Concurrency StateConcurrency
119 | Consistency StateConsistency
120 | }
121 |
122 | func toProtoSaveStateItem(si *SetStateItem) (item *v1.StateItem) {
123 | return &v1.StateItem{
124 | Etag: si.Etag,
125 | Key: si.Key,
126 | Metadata: si.Metadata,
127 | Value: si.Value,
128 | Options: toProtoStateOptions(si.Options),
129 | }
130 | }
131 |
132 | func toProtoStateOptions(so *StateOptions) (opts *v1.StateOptions) {
133 | if so == nil {
134 | return stateOptionDefault
135 | }
136 | return &v1.StateOptions{
137 | Concurrency: (v1.StateOptions_StateConcurrency(so.Concurrency)),
138 | Consistency: (v1.StateOptions_StateConsistency(so.Consistency)),
139 | }
140 | }
141 |
142 | func toProtoDuration(d time.Duration) *duration.Duration {
143 | nanos := d.Nanoseconds()
144 | secs := nanos / 1e9
145 | nanos -= secs * 1e9
146 | return &duration.Duration{
147 | Seconds: int64(secs),
148 | Nanos: int32(nanos),
149 | }
150 | }
151 |
152 | // ExecuteStateTransaction provides way to execute multiple operations on a specified store.
153 | func (c *GRPCClient) ExecuteStateTransaction(ctx context.Context, store string, meta map[string]string, ops []*StateOperation) error {
154 | if store == "" {
155 | return errors.New("nil store")
156 | }
157 | if len(ops) == 0 {
158 | return nil
159 | }
160 |
161 | items := make([]*pb.TransactionalStateOperation, 0)
162 | for _, op := range ops {
163 | item := &pb.TransactionalStateOperation{
164 | OperationType: op.Type.String(),
165 | Request: toProtoSaveStateItem(op.Item),
166 | }
167 | items = append(items, item)
168 | }
169 |
170 | req := &pb.ExecuteStateTransactionRequest{
171 | Metadata: meta,
172 | StoreName: store,
173 | Operations: items,
174 | }
175 | _, err := c.protoClient.ExecuteStateTransaction(c.withAuthToken(ctx), req)
176 | if err != nil {
177 | return errors.Wrap(err, "error executing state transaction")
178 | }
179 | return nil
180 | }
181 |
182 | // SaveState saves the raw data into store using default state options.
183 | func (c *GRPCClient) SaveState(ctx context.Context, store, key string, data []byte) error {
184 | item := &SetStateItem{Key: key, Value: data}
185 | return c.SaveStateItems(ctx, store, item)
186 | }
187 |
188 | // SaveStateItems saves the multiple state item to store.
189 | func (c *GRPCClient) SaveStateItems(ctx context.Context, store string, items ...*SetStateItem) error {
190 | if store == "" {
191 | return errors.New("nil store")
192 | }
193 | if items == nil {
194 | return errors.New("nil item")
195 | }
196 |
197 | req := &pb.SaveStateRequest{
198 | StoreName: store,
199 | States: make([]*v1.StateItem, 0),
200 | }
201 |
202 | for _, si := range items {
203 | item := toProtoSaveStateItem(si)
204 | req.States = append(req.States, item)
205 | }
206 |
207 | _, err := c.protoClient.SaveState(c.withAuthToken(ctx), req)
208 | if err != nil {
209 | return errors.Wrap(err, "error saving state")
210 | }
211 | return nil
212 |
213 | }
214 |
215 | // GetBulkItems retreaves state for multiple keys from specific store.
216 | func (c *GRPCClient) GetBulkItems(ctx context.Context, store string, keys []string, parallelism int32) ([]*StateItem, error) {
217 | if store == "" {
218 | return nil, errors.New("nil store")
219 | }
220 | if len(keys) == 0 {
221 | return nil, errors.New("keys required")
222 | }
223 | items := make([]*StateItem, 0)
224 |
225 | req := &pb.GetBulkStateRequest{
226 | StoreName: store,
227 | Keys: keys,
228 | Parallelism: parallelism,
229 | }
230 |
231 | results, err := c.protoClient.GetBulkState(c.withAuthToken(ctx), req)
232 | if err != nil {
233 | return nil, errors.Wrap(err, "error getting state")
234 | }
235 |
236 | if results == nil || results.Items == nil {
237 | return items, nil
238 | }
239 |
240 | for _, r := range results.Items {
241 | item := &StateItem{
242 | Key: r.Key,
243 | Etag: r.Etag,
244 | Value: r.Data,
245 | }
246 | items = append(items, item)
247 | }
248 |
249 | return items, nil
250 | }
251 |
252 | // GetState retreaves state from specific store using default consistency option.
253 | func (c *GRPCClient) GetState(ctx context.Context, store, key string) (item *StateItem, err error) {
254 | return c.GetStateWithConsistency(ctx, store, key, nil, StateConsistencyStrong)
255 | }
256 |
257 | // GetStateWithConsistency retreaves state from specific store using provided state consistency.
258 | func (c *GRPCClient) GetStateWithConsistency(ctx context.Context, store, key string, meta map[string]string, sc StateConsistency) (item *StateItem, err error) {
259 | if store == "" {
260 | return nil, errors.New("nil store")
261 | }
262 | if key == "" {
263 | return nil, errors.New("nil key")
264 | }
265 |
266 | req := &pb.GetStateRequest{
267 | StoreName: store,
268 | Key: key,
269 | Consistency: (v1.StateOptions_StateConsistency(sc)),
270 | Metadata: meta,
271 | }
272 |
273 | result, err := c.protoClient.GetState(c.withAuthToken(ctx), req)
274 | if err != nil {
275 | return nil, errors.Wrap(err, "error getting state")
276 | }
277 |
278 | return &StateItem{
279 | Etag: result.Etag,
280 | Key: key,
281 | Value: result.Data,
282 | }, nil
283 | }
284 |
285 | // DeleteState deletes content from store using default state options.
286 | func (c *GRPCClient) DeleteState(ctx context.Context, store, key string) error {
287 | return c.DeleteStateWithETag(ctx, store, key, "", nil, nil)
288 | }
289 |
290 | // DeleteStateWithETag deletes content from store using provided state options and etag.
291 | func (c *GRPCClient) DeleteStateWithETag(ctx context.Context, store, key, etag string, meta map[string]string, opts *StateOptions) error {
292 | if store == "" {
293 | return errors.New("nil store")
294 | }
295 | if key == "" {
296 | return errors.New("nil key")
297 | }
298 |
299 | req := &pb.DeleteStateRequest{
300 | StoreName: store,
301 | Key: key,
302 | Etag: etag,
303 | Options: toProtoStateOptions(opts),
304 | Metadata: meta,
305 | }
306 |
307 | _, err := c.protoClient.DeleteState(c.withAuthToken(ctx), req)
308 | if err != nil {
309 | return errors.Wrap(err, "error deleting state")
310 | }
311 |
312 | return nil
313 | }
314 |
--------------------------------------------------------------------------------
/go.sum:
--------------------------------------------------------------------------------
1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3 | github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
4 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
5 | github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
6 | github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
7 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
9 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
10 | github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
11 | github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
12 | github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
13 | github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
14 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
15 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
16 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
17 | github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
18 | github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
19 | github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
20 | github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
21 | github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
22 | github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
23 | github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
24 | github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
25 | github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
26 | github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
27 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
28 | github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
29 | github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
30 | github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
31 | github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
32 | github.com/google/go-cmp v0.5.0 h1:/QaMHBdZ26BB3SSst0Iwl10Epc+xhTquomWX0oZEB6w=
33 | github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
34 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
35 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
36 | github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
37 | github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
38 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
39 | github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
40 | github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
41 | github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
42 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
43 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
44 | github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
45 | github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
46 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
47 | github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
48 | github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
49 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
50 | golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
51 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
52 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
53 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
54 | golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
55 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
56 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
57 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
58 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
59 | golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
60 | golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
61 | golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
62 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
63 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
64 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
65 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
66 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
67 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
68 | golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
69 | golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
70 | golang.org/x/sys v0.0.0-20200917073148-efd3b9a0ff20 h1:4X356008q5SA3YXu8PiRap39KFmy4Lf6sGlceJKZQsU=
71 | golang.org/x/sys v0.0.0-20200917073148-efd3b9a0ff20/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
72 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
73 | golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
74 | golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
75 | golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
76 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
77 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
78 | golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
79 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A=
80 | golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
81 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
82 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
83 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
84 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
85 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
86 | google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
87 | google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
88 | google.golang.org/genproto v0.0.0-20200917134801-bb4cff56e0d0 h1:uslsjIdqvZYANxSBQjTI47vZfwMaTN3mLELkMnMIY/A=
89 | google.golang.org/genproto v0.0.0-20200917134801-bb4cff56e0d0/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
90 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
91 | google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
92 | google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
93 | google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
94 | google.golang.org/grpc v1.32.0 h1:zWTV+LMdc3kaiJMSTOFz2UgSBgx8RNQoTGiZu3fR9S0=
95 | google.golang.org/grpc v1.32.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
96 | google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
97 | google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
98 | google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
99 | google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
100 | google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
101 | google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
102 | google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
103 | google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
104 | google.golang.org/protobuf v1.24.0 h1:UhZDfRO8JRQru4/+LlLE0BRKGF8L+PICnvYZmx/fEGA=
105 | google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
106 | google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
107 | google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
108 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
109 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
110 | gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
111 | gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
112 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
113 | gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 h1:tQIYjPdBoyREyB9XMu+nnTclpTYkz2zFM+lzLJFO4gQ=
114 | gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
115 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
116 | honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
117 |
--------------------------------------------------------------------------------
/dapr/proto/common/v1/common.pb.go:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | // ------------------------------------------------------------
5 |
6 | // Code generated by protoc-gen-go. DO NOT EDIT.
7 | // versions:
8 | // protoc-gen-go v1.24.0
9 | // protoc v3.13.0
10 | // source: dapr/proto/common/v1/common.proto
11 |
12 | package common
13 |
14 | import (
15 | proto "github.com/golang/protobuf/proto"
16 | any "github.com/golang/protobuf/ptypes/any"
17 | protoreflect "google.golang.org/protobuf/reflect/protoreflect"
18 | protoimpl "google.golang.org/protobuf/runtime/protoimpl"
19 | reflect "reflect"
20 | sync "sync"
21 | )
22 |
23 | const (
24 | // Verify that this generated code is sufficiently up-to-date.
25 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
26 | // Verify that runtime/protoimpl is sufficiently up-to-date.
27 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
28 | )
29 |
30 | // This is a compile-time assertion that a sufficiently up-to-date version
31 | // of the legacy proto package is being used.
32 | const _ = proto.ProtoPackageIsVersion4
33 |
34 | // Type of HTTP 1.1 Methods
35 | // RFC 7231: https://tools.ietf.org/html/rfc7231#page-24
36 | type HTTPExtension_Verb int32
37 |
38 | const (
39 | HTTPExtension_NONE HTTPExtension_Verb = 0
40 | HTTPExtension_GET HTTPExtension_Verb = 1
41 | HTTPExtension_HEAD HTTPExtension_Verb = 2
42 | HTTPExtension_POST HTTPExtension_Verb = 3
43 | HTTPExtension_PUT HTTPExtension_Verb = 4
44 | HTTPExtension_DELETE HTTPExtension_Verb = 5
45 | HTTPExtension_CONNECT HTTPExtension_Verb = 6
46 | HTTPExtension_OPTIONS HTTPExtension_Verb = 7
47 | HTTPExtension_TRACE HTTPExtension_Verb = 8
48 | )
49 |
50 | // Enum value maps for HTTPExtension_Verb.
51 | var (
52 | HTTPExtension_Verb_name = map[int32]string{
53 | 0: "NONE",
54 | 1: "GET",
55 | 2: "HEAD",
56 | 3: "POST",
57 | 4: "PUT",
58 | 5: "DELETE",
59 | 6: "CONNECT",
60 | 7: "OPTIONS",
61 | 8: "TRACE",
62 | }
63 | HTTPExtension_Verb_value = map[string]int32{
64 | "NONE": 0,
65 | "GET": 1,
66 | "HEAD": 2,
67 | "POST": 3,
68 | "PUT": 4,
69 | "DELETE": 5,
70 | "CONNECT": 6,
71 | "OPTIONS": 7,
72 | "TRACE": 8,
73 | }
74 | )
75 |
76 | func (x HTTPExtension_Verb) Enum() *HTTPExtension_Verb {
77 | p := new(HTTPExtension_Verb)
78 | *p = x
79 | return p
80 | }
81 |
82 | func (x HTTPExtension_Verb) String() string {
83 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
84 | }
85 |
86 | func (HTTPExtension_Verb) Descriptor() protoreflect.EnumDescriptor {
87 | return file_dapr_proto_common_v1_common_proto_enumTypes[0].Descriptor()
88 | }
89 |
90 | func (HTTPExtension_Verb) Type() protoreflect.EnumType {
91 | return &file_dapr_proto_common_v1_common_proto_enumTypes[0]
92 | }
93 |
94 | func (x HTTPExtension_Verb) Number() protoreflect.EnumNumber {
95 | return protoreflect.EnumNumber(x)
96 | }
97 |
98 | // Deprecated: Use HTTPExtension_Verb.Descriptor instead.
99 | func (HTTPExtension_Verb) EnumDescriptor() ([]byte, []int) {
100 | return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{0, 0}
101 | }
102 |
103 | // Enum describing the supported concurrency for state.
104 | type StateOptions_StateConcurrency int32
105 |
106 | const (
107 | StateOptions_CONCURRENCY_UNSPECIFIED StateOptions_StateConcurrency = 0
108 | StateOptions_CONCURRENCY_FIRST_WRITE StateOptions_StateConcurrency = 1
109 | StateOptions_CONCURRENCY_LAST_WRITE StateOptions_StateConcurrency = 2
110 | )
111 |
112 | // Enum value maps for StateOptions_StateConcurrency.
113 | var (
114 | StateOptions_StateConcurrency_name = map[int32]string{
115 | 0: "CONCURRENCY_UNSPECIFIED",
116 | 1: "CONCURRENCY_FIRST_WRITE",
117 | 2: "CONCURRENCY_LAST_WRITE",
118 | }
119 | StateOptions_StateConcurrency_value = map[string]int32{
120 | "CONCURRENCY_UNSPECIFIED": 0,
121 | "CONCURRENCY_FIRST_WRITE": 1,
122 | "CONCURRENCY_LAST_WRITE": 2,
123 | }
124 | )
125 |
126 | func (x StateOptions_StateConcurrency) Enum() *StateOptions_StateConcurrency {
127 | p := new(StateOptions_StateConcurrency)
128 | *p = x
129 | return p
130 | }
131 |
132 | func (x StateOptions_StateConcurrency) String() string {
133 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
134 | }
135 |
136 | func (StateOptions_StateConcurrency) Descriptor() protoreflect.EnumDescriptor {
137 | return file_dapr_proto_common_v1_common_proto_enumTypes[1].Descriptor()
138 | }
139 |
140 | func (StateOptions_StateConcurrency) Type() protoreflect.EnumType {
141 | return &file_dapr_proto_common_v1_common_proto_enumTypes[1]
142 | }
143 |
144 | func (x StateOptions_StateConcurrency) Number() protoreflect.EnumNumber {
145 | return protoreflect.EnumNumber(x)
146 | }
147 |
148 | // Deprecated: Use StateOptions_StateConcurrency.Descriptor instead.
149 | func (StateOptions_StateConcurrency) EnumDescriptor() ([]byte, []int) {
150 | return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{4, 0}
151 | }
152 |
153 | // Enum describing the supported consistency for state.
154 | type StateOptions_StateConsistency int32
155 |
156 | const (
157 | StateOptions_CONSISTENCY_UNSPECIFIED StateOptions_StateConsistency = 0
158 | StateOptions_CONSISTENCY_EVENTUAL StateOptions_StateConsistency = 1
159 | StateOptions_CONSISTENCY_STRONG StateOptions_StateConsistency = 2
160 | )
161 |
162 | // Enum value maps for StateOptions_StateConsistency.
163 | var (
164 | StateOptions_StateConsistency_name = map[int32]string{
165 | 0: "CONSISTENCY_UNSPECIFIED",
166 | 1: "CONSISTENCY_EVENTUAL",
167 | 2: "CONSISTENCY_STRONG",
168 | }
169 | StateOptions_StateConsistency_value = map[string]int32{
170 | "CONSISTENCY_UNSPECIFIED": 0,
171 | "CONSISTENCY_EVENTUAL": 1,
172 | "CONSISTENCY_STRONG": 2,
173 | }
174 | )
175 |
176 | func (x StateOptions_StateConsistency) Enum() *StateOptions_StateConsistency {
177 | p := new(StateOptions_StateConsistency)
178 | *p = x
179 | return p
180 | }
181 |
182 | func (x StateOptions_StateConsistency) String() string {
183 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
184 | }
185 |
186 | func (StateOptions_StateConsistency) Descriptor() protoreflect.EnumDescriptor {
187 | return file_dapr_proto_common_v1_common_proto_enumTypes[2].Descriptor()
188 | }
189 |
190 | func (StateOptions_StateConsistency) Type() protoreflect.EnumType {
191 | return &file_dapr_proto_common_v1_common_proto_enumTypes[2]
192 | }
193 |
194 | func (x StateOptions_StateConsistency) Number() protoreflect.EnumNumber {
195 | return protoreflect.EnumNumber(x)
196 | }
197 |
198 | // Deprecated: Use StateOptions_StateConsistency.Descriptor instead.
199 | func (StateOptions_StateConsistency) EnumDescriptor() ([]byte, []int) {
200 | return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{4, 1}
201 | }
202 |
203 | // HTTPExtension includes HTTP verb and querystring
204 | // when Dapr runtime delivers HTTP content.
205 | //
206 | // For example, when callers calls http invoke api
207 | // POST http://localhost:3500/v1.0/invoke//method/?query1=value1&query2=value2
208 | //
209 | // Dapr runtime will parse POST as a verb and extract querystring to quersytring map.
210 | type HTTPExtension struct {
211 | state protoimpl.MessageState
212 | sizeCache protoimpl.SizeCache
213 | unknownFields protoimpl.UnknownFields
214 |
215 | // Required. HTTP verb.
216 | Verb HTTPExtension_Verb `protobuf:"varint,1,opt,name=verb,proto3,enum=dapr.proto.common.v1.HTTPExtension_Verb" json:"verb,omitempty"`
217 | // querystring includes HTTP querystring.
218 | Querystring map[string]string `protobuf:"bytes,2,rep,name=querystring,proto3" json:"querystring,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
219 | }
220 |
221 | func (x *HTTPExtension) Reset() {
222 | *x = HTTPExtension{}
223 | if protoimpl.UnsafeEnabled {
224 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[0]
225 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
226 | ms.StoreMessageInfo(mi)
227 | }
228 | }
229 |
230 | func (x *HTTPExtension) String() string {
231 | return protoimpl.X.MessageStringOf(x)
232 | }
233 |
234 | func (*HTTPExtension) ProtoMessage() {}
235 |
236 | func (x *HTTPExtension) ProtoReflect() protoreflect.Message {
237 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[0]
238 | if protoimpl.UnsafeEnabled && x != nil {
239 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
240 | if ms.LoadMessageInfo() == nil {
241 | ms.StoreMessageInfo(mi)
242 | }
243 | return ms
244 | }
245 | return mi.MessageOf(x)
246 | }
247 |
248 | // Deprecated: Use HTTPExtension.ProtoReflect.Descriptor instead.
249 | func (*HTTPExtension) Descriptor() ([]byte, []int) {
250 | return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{0}
251 | }
252 |
253 | func (x *HTTPExtension) GetVerb() HTTPExtension_Verb {
254 | if x != nil {
255 | return x.Verb
256 | }
257 | return HTTPExtension_NONE
258 | }
259 |
260 | func (x *HTTPExtension) GetQuerystring() map[string]string {
261 | if x != nil {
262 | return x.Querystring
263 | }
264 | return nil
265 | }
266 |
267 | // InvokeRequest is the message to invoke a method with the data.
268 | // This message is used in InvokeService of Dapr gRPC Service and OnInvoke
269 | // of AppCallback gRPC service.
270 | type InvokeRequest struct {
271 | state protoimpl.MessageState
272 | sizeCache protoimpl.SizeCache
273 | unknownFields protoimpl.UnknownFields
274 |
275 | // Required. method is a method name which will be invoked by caller.
276 | Method string `protobuf:"bytes,1,opt,name=method,proto3" json:"method,omitempty"`
277 | // Required. Bytes value or Protobuf message which caller sent.
278 | // Dapr treats Any.value as bytes type if Any.type_url is unset.
279 | Data *any.Any `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
280 | // The type of data content.
281 | //
282 | // This field is required if data delivers http request body
283 | // Otherwise, this is optional.
284 | ContentType string `protobuf:"bytes,3,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
285 | // HTTP specific fields if request conveys http-compatible request.
286 | //
287 | // This field is required for http-compatible request. Otherwise,
288 | // this field is optional.
289 | HttpExtension *HTTPExtension `protobuf:"bytes,4,opt,name=http_extension,json=httpExtension,proto3" json:"http_extension,omitempty"`
290 | }
291 |
292 | func (x *InvokeRequest) Reset() {
293 | *x = InvokeRequest{}
294 | if protoimpl.UnsafeEnabled {
295 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[1]
296 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
297 | ms.StoreMessageInfo(mi)
298 | }
299 | }
300 |
301 | func (x *InvokeRequest) String() string {
302 | return protoimpl.X.MessageStringOf(x)
303 | }
304 |
305 | func (*InvokeRequest) ProtoMessage() {}
306 |
307 | func (x *InvokeRequest) ProtoReflect() protoreflect.Message {
308 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[1]
309 | if protoimpl.UnsafeEnabled && x != nil {
310 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
311 | if ms.LoadMessageInfo() == nil {
312 | ms.StoreMessageInfo(mi)
313 | }
314 | return ms
315 | }
316 | return mi.MessageOf(x)
317 | }
318 |
319 | // Deprecated: Use InvokeRequest.ProtoReflect.Descriptor instead.
320 | func (*InvokeRequest) Descriptor() ([]byte, []int) {
321 | return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{1}
322 | }
323 |
324 | func (x *InvokeRequest) GetMethod() string {
325 | if x != nil {
326 | return x.Method
327 | }
328 | return ""
329 | }
330 |
331 | func (x *InvokeRequest) GetData() *any.Any {
332 | if x != nil {
333 | return x.Data
334 | }
335 | return nil
336 | }
337 |
338 | func (x *InvokeRequest) GetContentType() string {
339 | if x != nil {
340 | return x.ContentType
341 | }
342 | return ""
343 | }
344 |
345 | func (x *InvokeRequest) GetHttpExtension() *HTTPExtension {
346 | if x != nil {
347 | return x.HttpExtension
348 | }
349 | return nil
350 | }
351 |
352 | // InvokeResponse is the response message inclduing data and its content type
353 | // from app callback.
354 | // This message is used in InvokeService of Dapr gRPC Service and OnInvoke
355 | // of AppCallback gRPC service.
356 | type InvokeResponse struct {
357 | state protoimpl.MessageState
358 | sizeCache protoimpl.SizeCache
359 | unknownFields protoimpl.UnknownFields
360 |
361 | // Required. The content body of InvokeService response.
362 | Data *any.Any `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
363 | // Required. The type of data content.
364 | ContentType string `protobuf:"bytes,2,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
365 | }
366 |
367 | func (x *InvokeResponse) Reset() {
368 | *x = InvokeResponse{}
369 | if protoimpl.UnsafeEnabled {
370 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[2]
371 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
372 | ms.StoreMessageInfo(mi)
373 | }
374 | }
375 |
376 | func (x *InvokeResponse) String() string {
377 | return protoimpl.X.MessageStringOf(x)
378 | }
379 |
380 | func (*InvokeResponse) ProtoMessage() {}
381 |
382 | func (x *InvokeResponse) ProtoReflect() protoreflect.Message {
383 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[2]
384 | if protoimpl.UnsafeEnabled && x != nil {
385 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
386 | if ms.LoadMessageInfo() == nil {
387 | ms.StoreMessageInfo(mi)
388 | }
389 | return ms
390 | }
391 | return mi.MessageOf(x)
392 | }
393 |
394 | // Deprecated: Use InvokeResponse.ProtoReflect.Descriptor instead.
395 | func (*InvokeResponse) Descriptor() ([]byte, []int) {
396 | return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{2}
397 | }
398 |
399 | func (x *InvokeResponse) GetData() *any.Any {
400 | if x != nil {
401 | return x.Data
402 | }
403 | return nil
404 | }
405 |
406 | func (x *InvokeResponse) GetContentType() string {
407 | if x != nil {
408 | return x.ContentType
409 | }
410 | return ""
411 | }
412 |
413 | // StateItem represents state key, value, and additional options to save state.
414 | type StateItem struct {
415 | state protoimpl.MessageState
416 | sizeCache protoimpl.SizeCache
417 | unknownFields protoimpl.UnknownFields
418 |
419 | // Required. The state key
420 | Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"`
421 | // Required. The state data for key
422 | Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
423 | // The entity tag which represents the specific version of data.
424 | // The exact ETag format is defined by the corresponding data store.
425 | Etag string `protobuf:"bytes,3,opt,name=etag,proto3" json:"etag,omitempty"`
426 | // The metadata which will be passed to state store component.
427 | Metadata map[string]string `protobuf:"bytes,4,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
428 | // Options for concurrency and consistency to save the state.
429 | Options *StateOptions `protobuf:"bytes,5,opt,name=options,proto3" json:"options,omitempty"`
430 | }
431 |
432 | func (x *StateItem) Reset() {
433 | *x = StateItem{}
434 | if protoimpl.UnsafeEnabled {
435 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[3]
436 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
437 | ms.StoreMessageInfo(mi)
438 | }
439 | }
440 |
441 | func (x *StateItem) String() string {
442 | return protoimpl.X.MessageStringOf(x)
443 | }
444 |
445 | func (*StateItem) ProtoMessage() {}
446 |
447 | func (x *StateItem) ProtoReflect() protoreflect.Message {
448 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[3]
449 | if protoimpl.UnsafeEnabled && x != nil {
450 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
451 | if ms.LoadMessageInfo() == nil {
452 | ms.StoreMessageInfo(mi)
453 | }
454 | return ms
455 | }
456 | return mi.MessageOf(x)
457 | }
458 |
459 | // Deprecated: Use StateItem.ProtoReflect.Descriptor instead.
460 | func (*StateItem) Descriptor() ([]byte, []int) {
461 | return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{3}
462 | }
463 |
464 | func (x *StateItem) GetKey() string {
465 | if x != nil {
466 | return x.Key
467 | }
468 | return ""
469 | }
470 |
471 | func (x *StateItem) GetValue() []byte {
472 | if x != nil {
473 | return x.Value
474 | }
475 | return nil
476 | }
477 |
478 | func (x *StateItem) GetEtag() string {
479 | if x != nil {
480 | return x.Etag
481 | }
482 | return ""
483 | }
484 |
485 | func (x *StateItem) GetMetadata() map[string]string {
486 | if x != nil {
487 | return x.Metadata
488 | }
489 | return nil
490 | }
491 |
492 | func (x *StateItem) GetOptions() *StateOptions {
493 | if x != nil {
494 | return x.Options
495 | }
496 | return nil
497 | }
498 |
499 | // StateOptions configures concurrency and consistency for state operations
500 | type StateOptions struct {
501 | state protoimpl.MessageState
502 | sizeCache protoimpl.SizeCache
503 | unknownFields protoimpl.UnknownFields
504 |
505 | Concurrency StateOptions_StateConcurrency `protobuf:"varint,1,opt,name=concurrency,proto3,enum=dapr.proto.common.v1.StateOptions_StateConcurrency" json:"concurrency,omitempty"`
506 | Consistency StateOptions_StateConsistency `protobuf:"varint,2,opt,name=consistency,proto3,enum=dapr.proto.common.v1.StateOptions_StateConsistency" json:"consistency,omitempty"`
507 | }
508 |
509 | func (x *StateOptions) Reset() {
510 | *x = StateOptions{}
511 | if protoimpl.UnsafeEnabled {
512 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[4]
513 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
514 | ms.StoreMessageInfo(mi)
515 | }
516 | }
517 |
518 | func (x *StateOptions) String() string {
519 | return protoimpl.X.MessageStringOf(x)
520 | }
521 |
522 | func (*StateOptions) ProtoMessage() {}
523 |
524 | func (x *StateOptions) ProtoReflect() protoreflect.Message {
525 | mi := &file_dapr_proto_common_v1_common_proto_msgTypes[4]
526 | if protoimpl.UnsafeEnabled && x != nil {
527 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
528 | if ms.LoadMessageInfo() == nil {
529 | ms.StoreMessageInfo(mi)
530 | }
531 | return ms
532 | }
533 | return mi.MessageOf(x)
534 | }
535 |
536 | // Deprecated: Use StateOptions.ProtoReflect.Descriptor instead.
537 | func (*StateOptions) Descriptor() ([]byte, []int) {
538 | return file_dapr_proto_common_v1_common_proto_rawDescGZIP(), []int{4}
539 | }
540 |
541 | func (x *StateOptions) GetConcurrency() StateOptions_StateConcurrency {
542 | if x != nil {
543 | return x.Concurrency
544 | }
545 | return StateOptions_CONCURRENCY_UNSPECIFIED
546 | }
547 |
548 | func (x *StateOptions) GetConsistency() StateOptions_StateConsistency {
549 | if x != nil {
550 | return x.Consistency
551 | }
552 | return StateOptions_CONSISTENCY_UNSPECIFIED
553 | }
554 |
555 | var File_dapr_proto_common_v1_common_proto protoreflect.FileDescriptor
556 |
557 | var file_dapr_proto_common_v1_common_proto_rawDesc = []byte{
558 | 0x0a, 0x21, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d,
559 | 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72,
560 | 0x6f, 0x74, 0x6f, 0x12, 0x14, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
561 | 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x1a, 0x19, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
562 | 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70,
563 | 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xce, 0x02, 0x0a, 0x0d, 0x48, 0x54, 0x54, 0x50, 0x45, 0x78, 0x74,
564 | 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x3c, 0x0a, 0x04, 0x76, 0x65, 0x72, 0x62, 0x18, 0x01,
565 | 0x20, 0x01, 0x28, 0x0e, 0x32, 0x28, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,
566 | 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x54, 0x54, 0x50,
567 | 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x56, 0x65, 0x72, 0x62, 0x52, 0x04,
568 | 0x76, 0x65, 0x72, 0x62, 0x12, 0x56, 0x0a, 0x0b, 0x71, 0x75, 0x65, 0x72, 0x79, 0x73, 0x74, 0x72,
569 | 0x69, 0x6e, 0x67, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x34, 0x2e, 0x64, 0x61, 0x70, 0x72,
570 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31,
571 | 0x2e, 0x48, 0x54, 0x54, 0x50, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x2e, 0x51,
572 | 0x75, 0x65, 0x72, 0x79, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52,
573 | 0x0b, 0x71, 0x75, 0x65, 0x72, 0x79, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x1a, 0x3e, 0x0a, 0x10,
574 | 0x51, 0x75, 0x65, 0x72, 0x79, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x45, 0x6e, 0x74, 0x72, 0x79,
575 | 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b,
576 | 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
577 | 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x67, 0x0a, 0x04,
578 | 0x56, 0x65, 0x72, 0x62, 0x12, 0x08, 0x0a, 0x04, 0x4e, 0x4f, 0x4e, 0x45, 0x10, 0x00, 0x12, 0x07,
579 | 0x0a, 0x03, 0x47, 0x45, 0x54, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x48, 0x45, 0x41, 0x44, 0x10,
580 | 0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4f, 0x53, 0x54, 0x10, 0x03, 0x12, 0x07, 0x0a, 0x03, 0x50,
581 | 0x55, 0x54, 0x10, 0x04, 0x12, 0x0a, 0x0a, 0x06, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x10, 0x05,
582 | 0x12, 0x0b, 0x0a, 0x07, 0x43, 0x4f, 0x4e, 0x4e, 0x45, 0x43, 0x54, 0x10, 0x06, 0x12, 0x0b, 0x0a,
583 | 0x07, 0x4f, 0x50, 0x54, 0x49, 0x4f, 0x4e, 0x53, 0x10, 0x07, 0x12, 0x09, 0x0a, 0x05, 0x54, 0x52,
584 | 0x41, 0x43, 0x45, 0x10, 0x08, 0x22, 0xc0, 0x01, 0x0a, 0x0d, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65,
585 | 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f,
586 | 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12,
587 | 0x28, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e,
588 | 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e,
589 | 0x41, 0x6e, 0x79, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e,
590 | 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
591 | 0x0b, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x4a, 0x0a, 0x0e,
592 | 0x68, 0x74, 0x74, 0x70, 0x5f, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x04,
593 | 0x20, 0x01, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,
594 | 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x48, 0x54, 0x54, 0x50,
595 | 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x68, 0x74, 0x74, 0x70, 0x45,
596 | 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x5d, 0x0a, 0x0e, 0x49, 0x6e, 0x76, 0x6f,
597 | 0x6b, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x28, 0x0a, 0x04, 0x64, 0x61,
598 | 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x14, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c,
599 | 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x04,
600 | 0x64, 0x61, 0x74, 0x61, 0x12, 0x21, 0x0a, 0x0c, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f,
601 | 0x74, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x74,
602 | 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x22, 0x8d, 0x02, 0x0a, 0x09, 0x53, 0x74, 0x61, 0x74,
603 | 0x65, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01,
604 | 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
605 | 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x12, 0x12, 0x0a,
606 | 0x04, 0x65, 0x74, 0x61, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x65, 0x74, 0x61,
607 | 0x67, 0x12, 0x49, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20,
608 | 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
609 | 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65,
610 | 0x49, 0x74, 0x65, 0x6d, 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74,
611 | 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x12, 0x3c, 0x0a, 0x07,
612 | 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e,
613 | 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
614 | 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
615 | 0x73, 0x52, 0x07, 0x6f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65,
616 | 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b,
617 | 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a,
618 | 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61,
619 | 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x89, 0x03, 0x0a, 0x0c, 0x53, 0x74, 0x61, 0x74,
620 | 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x55, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63,
621 | 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x33, 0x2e,
622 | 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f,
623 | 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e,
624 | 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e,
625 | 0x63, 0x79, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12,
626 | 0x55, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x18, 0x02,
627 | 0x20, 0x01, 0x28, 0x0e, 0x32, 0x33, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74,
628 | 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x53, 0x74, 0x61, 0x74,
629 | 0x65, 0x4f, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x6f,
630 | 0x6e, 0x73, 0x69, 0x73, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x52, 0x0b, 0x63, 0x6f, 0x6e, 0x73, 0x69,
631 | 0x73, 0x74, 0x65, 0x6e, 0x63, 0x79, 0x22, 0x68, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43,
632 | 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f,
633 | 0x4e, 0x43, 0x55, 0x52, 0x52, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43,
634 | 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x00, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x4e, 0x43, 0x55,
635 | 0x52, 0x52, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x46, 0x49, 0x52, 0x53, 0x54, 0x5f, 0x57, 0x52, 0x49,
636 | 0x54, 0x45, 0x10, 0x01, 0x12, 0x1a, 0x0a, 0x16, 0x43, 0x4f, 0x4e, 0x43, 0x55, 0x52, 0x52, 0x45,
637 | 0x4e, 0x43, 0x59, 0x5f, 0x4c, 0x41, 0x53, 0x54, 0x5f, 0x57, 0x52, 0x49, 0x54, 0x45, 0x10, 0x02,
638 | 0x22, 0x61, 0x0a, 0x10, 0x53, 0x74, 0x61, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x73, 0x69, 0x73, 0x74,
639 | 0x65, 0x6e, 0x63, 0x79, 0x12, 0x1b, 0x0a, 0x17, 0x43, 0x4f, 0x4e, 0x53, 0x49, 0x53, 0x54, 0x45,
640 | 0x4e, 0x43, 0x59, 0x5f, 0x55, 0x4e, 0x53, 0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10,
641 | 0x00, 0x12, 0x18, 0x0a, 0x14, 0x43, 0x4f, 0x4e, 0x53, 0x49, 0x53, 0x54, 0x45, 0x4e, 0x43, 0x59,
642 | 0x5f, 0x45, 0x56, 0x45, 0x4e, 0x54, 0x55, 0x41, 0x4c, 0x10, 0x01, 0x12, 0x16, 0x0a, 0x12, 0x43,
643 | 0x4f, 0x4e, 0x53, 0x49, 0x53, 0x54, 0x45, 0x4e, 0x43, 0x59, 0x5f, 0x53, 0x54, 0x52, 0x4f, 0x4e,
644 | 0x47, 0x10, 0x02, 0x42, 0x6c, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x76,
645 | 0x31, 0x42, 0x0c, 0x43, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x5a,
646 | 0x32, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x61, 0x70, 0x72,
647 | 0x2f, 0x67, 0x6f, 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f,
648 | 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d,
649 | 0x6d, 0x6f, 0x6e, 0xaa, 0x02, 0x1b, 0x44, 0x61, 0x70, 0x72, 0x2e, 0x43, 0x6c, 0x69, 0x65, 0x6e,
650 | 0x74, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x2e, 0x76,
651 | 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
652 | }
653 |
654 | var (
655 | file_dapr_proto_common_v1_common_proto_rawDescOnce sync.Once
656 | file_dapr_proto_common_v1_common_proto_rawDescData = file_dapr_proto_common_v1_common_proto_rawDesc
657 | )
658 |
659 | func file_dapr_proto_common_v1_common_proto_rawDescGZIP() []byte {
660 | file_dapr_proto_common_v1_common_proto_rawDescOnce.Do(func() {
661 | file_dapr_proto_common_v1_common_proto_rawDescData = protoimpl.X.CompressGZIP(file_dapr_proto_common_v1_common_proto_rawDescData)
662 | })
663 | return file_dapr_proto_common_v1_common_proto_rawDescData
664 | }
665 |
666 | var file_dapr_proto_common_v1_common_proto_enumTypes = make([]protoimpl.EnumInfo, 3)
667 | var file_dapr_proto_common_v1_common_proto_msgTypes = make([]protoimpl.MessageInfo, 7)
668 | var file_dapr_proto_common_v1_common_proto_goTypes = []interface{}{
669 | (HTTPExtension_Verb)(0), // 0: dapr.proto.common.v1.HTTPExtension.Verb
670 | (StateOptions_StateConcurrency)(0), // 1: dapr.proto.common.v1.StateOptions.StateConcurrency
671 | (StateOptions_StateConsistency)(0), // 2: dapr.proto.common.v1.StateOptions.StateConsistency
672 | (*HTTPExtension)(nil), // 3: dapr.proto.common.v1.HTTPExtension
673 | (*InvokeRequest)(nil), // 4: dapr.proto.common.v1.InvokeRequest
674 | (*InvokeResponse)(nil), // 5: dapr.proto.common.v1.InvokeResponse
675 | (*StateItem)(nil), // 6: dapr.proto.common.v1.StateItem
676 | (*StateOptions)(nil), // 7: dapr.proto.common.v1.StateOptions
677 | nil, // 8: dapr.proto.common.v1.HTTPExtension.QuerystringEntry
678 | nil, // 9: dapr.proto.common.v1.StateItem.MetadataEntry
679 | (*any.Any)(nil), // 10: google.protobuf.Any
680 | }
681 | var file_dapr_proto_common_v1_common_proto_depIdxs = []int32{
682 | 0, // 0: dapr.proto.common.v1.HTTPExtension.verb:type_name -> dapr.proto.common.v1.HTTPExtension.Verb
683 | 8, // 1: dapr.proto.common.v1.HTTPExtension.querystring:type_name -> dapr.proto.common.v1.HTTPExtension.QuerystringEntry
684 | 10, // 2: dapr.proto.common.v1.InvokeRequest.data:type_name -> google.protobuf.Any
685 | 3, // 3: dapr.proto.common.v1.InvokeRequest.http_extension:type_name -> dapr.proto.common.v1.HTTPExtension
686 | 10, // 4: dapr.proto.common.v1.InvokeResponse.data:type_name -> google.protobuf.Any
687 | 9, // 5: dapr.proto.common.v1.StateItem.metadata:type_name -> dapr.proto.common.v1.StateItem.MetadataEntry
688 | 7, // 6: dapr.proto.common.v1.StateItem.options:type_name -> dapr.proto.common.v1.StateOptions
689 | 1, // 7: dapr.proto.common.v1.StateOptions.concurrency:type_name -> dapr.proto.common.v1.StateOptions.StateConcurrency
690 | 2, // 8: dapr.proto.common.v1.StateOptions.consistency:type_name -> dapr.proto.common.v1.StateOptions.StateConsistency
691 | 9, // [9:9] is the sub-list for method output_type
692 | 9, // [9:9] is the sub-list for method input_type
693 | 9, // [9:9] is the sub-list for extension type_name
694 | 9, // [9:9] is the sub-list for extension extendee
695 | 0, // [0:9] is the sub-list for field type_name
696 | }
697 |
698 | func init() { file_dapr_proto_common_v1_common_proto_init() }
699 | func file_dapr_proto_common_v1_common_proto_init() {
700 | if File_dapr_proto_common_v1_common_proto != nil {
701 | return
702 | }
703 | if !protoimpl.UnsafeEnabled {
704 | file_dapr_proto_common_v1_common_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
705 | switch v := v.(*HTTPExtension); i {
706 | case 0:
707 | return &v.state
708 | case 1:
709 | return &v.sizeCache
710 | case 2:
711 | return &v.unknownFields
712 | default:
713 | return nil
714 | }
715 | }
716 | file_dapr_proto_common_v1_common_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
717 | switch v := v.(*InvokeRequest); i {
718 | case 0:
719 | return &v.state
720 | case 1:
721 | return &v.sizeCache
722 | case 2:
723 | return &v.unknownFields
724 | default:
725 | return nil
726 | }
727 | }
728 | file_dapr_proto_common_v1_common_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
729 | switch v := v.(*InvokeResponse); i {
730 | case 0:
731 | return &v.state
732 | case 1:
733 | return &v.sizeCache
734 | case 2:
735 | return &v.unknownFields
736 | default:
737 | return nil
738 | }
739 | }
740 | file_dapr_proto_common_v1_common_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
741 | switch v := v.(*StateItem); i {
742 | case 0:
743 | return &v.state
744 | case 1:
745 | return &v.sizeCache
746 | case 2:
747 | return &v.unknownFields
748 | default:
749 | return nil
750 | }
751 | }
752 | file_dapr_proto_common_v1_common_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
753 | switch v := v.(*StateOptions); i {
754 | case 0:
755 | return &v.state
756 | case 1:
757 | return &v.sizeCache
758 | case 2:
759 | return &v.unknownFields
760 | default:
761 | return nil
762 | }
763 | }
764 | }
765 | type x struct{}
766 | out := protoimpl.TypeBuilder{
767 | File: protoimpl.DescBuilder{
768 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
769 | RawDescriptor: file_dapr_proto_common_v1_common_proto_rawDesc,
770 | NumEnums: 3,
771 | NumMessages: 7,
772 | NumExtensions: 0,
773 | NumServices: 0,
774 | },
775 | GoTypes: file_dapr_proto_common_v1_common_proto_goTypes,
776 | DependencyIndexes: file_dapr_proto_common_v1_common_proto_depIdxs,
777 | EnumInfos: file_dapr_proto_common_v1_common_proto_enumTypes,
778 | MessageInfos: file_dapr_proto_common_v1_common_proto_msgTypes,
779 | }.Build()
780 | File_dapr_proto_common_v1_common_proto = out.File
781 | file_dapr_proto_common_v1_common_proto_rawDesc = nil
782 | file_dapr_proto_common_v1_common_proto_goTypes = nil
783 | file_dapr_proto_common_v1_common_proto_depIdxs = nil
784 | }
785 |
--------------------------------------------------------------------------------
/dapr/proto/runtime/v1/appcallback.pb.go:
--------------------------------------------------------------------------------
1 | // ------------------------------------------------------------
2 | // Copyright (c) Microsoft Corporation.
3 | // Licensed under the MIT License.
4 | // ------------------------------------------------------------
5 |
6 | // Code generated by protoc-gen-go. DO NOT EDIT.
7 | // versions:
8 | // protoc-gen-go v1.24.0
9 | // protoc v3.13.0
10 | // source: dapr/proto/runtime/v1/appcallback.proto
11 |
12 | package runtime
13 |
14 | import (
15 | context "context"
16 | v1 "github.com/dapr/go-sdk/dapr/proto/common/v1"
17 | proto "github.com/golang/protobuf/proto"
18 | empty "github.com/golang/protobuf/ptypes/empty"
19 | grpc "google.golang.org/grpc"
20 | codes "google.golang.org/grpc/codes"
21 | status "google.golang.org/grpc/status"
22 | protoreflect "google.golang.org/protobuf/reflect/protoreflect"
23 | protoimpl "google.golang.org/protobuf/runtime/protoimpl"
24 | reflect "reflect"
25 | sync "sync"
26 | )
27 |
28 | const (
29 | // Verify that this generated code is sufficiently up-to-date.
30 | _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
31 | // Verify that runtime/protoimpl is sufficiently up-to-date.
32 | _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
33 | )
34 |
35 | // This is a compile-time assertion that a sufficiently up-to-date version
36 | // of the legacy proto package is being used.
37 | const _ = proto.ProtoPackageIsVersion4
38 |
39 | // TopicEventResponseStatus allows apps to have finer control over handling of the message.
40 | type TopicEventResponse_TopicEventResponseStatus int32
41 |
42 | const (
43 | // SUCCESS is the default behavior: message is acknowledged and not retried or logged.
44 | TopicEventResponse_SUCCESS TopicEventResponse_TopicEventResponseStatus = 0
45 | // RETRY status signals Dapr to retry the message as part of an expected scenario (no warning is logged).
46 | TopicEventResponse_RETRY TopicEventResponse_TopicEventResponseStatus = 1
47 | // DROP status signals Dapr to drop the message as part of an unexpected scenario (warning is logged).
48 | TopicEventResponse_DROP TopicEventResponse_TopicEventResponseStatus = 2
49 | )
50 |
51 | // Enum value maps for TopicEventResponse_TopicEventResponseStatus.
52 | var (
53 | TopicEventResponse_TopicEventResponseStatus_name = map[int32]string{
54 | 0: "SUCCESS",
55 | 1: "RETRY",
56 | 2: "DROP",
57 | }
58 | TopicEventResponse_TopicEventResponseStatus_value = map[string]int32{
59 | "SUCCESS": 0,
60 | "RETRY": 1,
61 | "DROP": 2,
62 | }
63 | )
64 |
65 | func (x TopicEventResponse_TopicEventResponseStatus) Enum() *TopicEventResponse_TopicEventResponseStatus {
66 | p := new(TopicEventResponse_TopicEventResponseStatus)
67 | *p = x
68 | return p
69 | }
70 |
71 | func (x TopicEventResponse_TopicEventResponseStatus) String() string {
72 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
73 | }
74 |
75 | func (TopicEventResponse_TopicEventResponseStatus) Descriptor() protoreflect.EnumDescriptor {
76 | return file_dapr_proto_runtime_v1_appcallback_proto_enumTypes[0].Descriptor()
77 | }
78 |
79 | func (TopicEventResponse_TopicEventResponseStatus) Type() protoreflect.EnumType {
80 | return &file_dapr_proto_runtime_v1_appcallback_proto_enumTypes[0]
81 | }
82 |
83 | func (x TopicEventResponse_TopicEventResponseStatus) Number() protoreflect.EnumNumber {
84 | return protoreflect.EnumNumber(x)
85 | }
86 |
87 | // Deprecated: Use TopicEventResponse_TopicEventResponseStatus.Descriptor instead.
88 | func (TopicEventResponse_TopicEventResponseStatus) EnumDescriptor() ([]byte, []int) {
89 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{1, 0}
90 | }
91 |
92 | // BindingEventConcurrency is the kind of concurrency
93 | type BindingEventResponse_BindingEventConcurrency int32
94 |
95 | const (
96 | // SEQUENTIAL sends data to output bindings specified in "to" sequentially.
97 | BindingEventResponse_SEQUENTIAL BindingEventResponse_BindingEventConcurrency = 0
98 | // PARALLEL sends data to output bindings specified in "to" in parallel.
99 | BindingEventResponse_PARALLEL BindingEventResponse_BindingEventConcurrency = 1
100 | )
101 |
102 | // Enum value maps for BindingEventResponse_BindingEventConcurrency.
103 | var (
104 | BindingEventResponse_BindingEventConcurrency_name = map[int32]string{
105 | 0: "SEQUENTIAL",
106 | 1: "PARALLEL",
107 | }
108 | BindingEventResponse_BindingEventConcurrency_value = map[string]int32{
109 | "SEQUENTIAL": 0,
110 | "PARALLEL": 1,
111 | }
112 | )
113 |
114 | func (x BindingEventResponse_BindingEventConcurrency) Enum() *BindingEventResponse_BindingEventConcurrency {
115 | p := new(BindingEventResponse_BindingEventConcurrency)
116 | *p = x
117 | return p
118 | }
119 |
120 | func (x BindingEventResponse_BindingEventConcurrency) String() string {
121 | return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
122 | }
123 |
124 | func (BindingEventResponse_BindingEventConcurrency) Descriptor() protoreflect.EnumDescriptor {
125 | return file_dapr_proto_runtime_v1_appcallback_proto_enumTypes[1].Descriptor()
126 | }
127 |
128 | func (BindingEventResponse_BindingEventConcurrency) Type() protoreflect.EnumType {
129 | return &file_dapr_proto_runtime_v1_appcallback_proto_enumTypes[1]
130 | }
131 |
132 | func (x BindingEventResponse_BindingEventConcurrency) Number() protoreflect.EnumNumber {
133 | return protoreflect.EnumNumber(x)
134 | }
135 |
136 | // Deprecated: Use BindingEventResponse_BindingEventConcurrency.Descriptor instead.
137 | func (BindingEventResponse_BindingEventConcurrency) EnumDescriptor() ([]byte, []int) {
138 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{3, 0}
139 | }
140 |
141 | // TopicEventRequest message is compatiable with CloudEvent spec v1.0
142 | // https://github.com/cloudevents/spec/blob/v1.0/spec.md
143 | type TopicEventRequest struct {
144 | state protoimpl.MessageState
145 | sizeCache protoimpl.SizeCache
146 | unknownFields protoimpl.UnknownFields
147 |
148 | // id identifies the event. Producers MUST ensure that source + id
149 | // is unique for each distinct event. If a duplicate event is re-sent
150 | // (e.g. due to a network error) it MAY have the same id.
151 | Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
152 | // source identifies the context in which an event happened.
153 | // Often this will include information such as the type of the
154 | // event source, the organization publishing the event or the process
155 | // that produced the event. The exact syntax and semantics behind
156 | // the data encoded in the URI is defined by the event producer.
157 | Source string `protobuf:"bytes,2,opt,name=source,proto3" json:"source,omitempty"`
158 | // The type of event related to the originating occurrence.
159 | Type string `protobuf:"bytes,3,opt,name=type,proto3" json:"type,omitempty"`
160 | // The version of the CloudEvents specification.
161 | SpecVersion string `protobuf:"bytes,4,opt,name=spec_version,json=specVersion,proto3" json:"spec_version,omitempty"`
162 | // The content type of data value.
163 | DataContentType string `protobuf:"bytes,5,opt,name=data_content_type,json=dataContentType,proto3" json:"data_content_type,omitempty"`
164 | // The content of the event.
165 | Data []byte `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"`
166 | // The pubsub topic which publisher sent to.
167 | Topic string `protobuf:"bytes,6,opt,name=topic,proto3" json:"topic,omitempty"`
168 | // The name of the pubsub the publisher sent to.
169 | PubsubName string `protobuf:"bytes,8,opt,name=pubsub_name,json=pubsubName,proto3" json:"pubsub_name,omitempty"`
170 | }
171 |
172 | func (x *TopicEventRequest) Reset() {
173 | *x = TopicEventRequest{}
174 | if protoimpl.UnsafeEnabled {
175 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[0]
176 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
177 | ms.StoreMessageInfo(mi)
178 | }
179 | }
180 |
181 | func (x *TopicEventRequest) String() string {
182 | return protoimpl.X.MessageStringOf(x)
183 | }
184 |
185 | func (*TopicEventRequest) ProtoMessage() {}
186 |
187 | func (x *TopicEventRequest) ProtoReflect() protoreflect.Message {
188 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[0]
189 | if protoimpl.UnsafeEnabled && x != nil {
190 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
191 | if ms.LoadMessageInfo() == nil {
192 | ms.StoreMessageInfo(mi)
193 | }
194 | return ms
195 | }
196 | return mi.MessageOf(x)
197 | }
198 |
199 | // Deprecated: Use TopicEventRequest.ProtoReflect.Descriptor instead.
200 | func (*TopicEventRequest) Descriptor() ([]byte, []int) {
201 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{0}
202 | }
203 |
204 | func (x *TopicEventRequest) GetId() string {
205 | if x != nil {
206 | return x.Id
207 | }
208 | return ""
209 | }
210 |
211 | func (x *TopicEventRequest) GetSource() string {
212 | if x != nil {
213 | return x.Source
214 | }
215 | return ""
216 | }
217 |
218 | func (x *TopicEventRequest) GetType() string {
219 | if x != nil {
220 | return x.Type
221 | }
222 | return ""
223 | }
224 |
225 | func (x *TopicEventRequest) GetSpecVersion() string {
226 | if x != nil {
227 | return x.SpecVersion
228 | }
229 | return ""
230 | }
231 |
232 | func (x *TopicEventRequest) GetDataContentType() string {
233 | if x != nil {
234 | return x.DataContentType
235 | }
236 | return ""
237 | }
238 |
239 | func (x *TopicEventRequest) GetData() []byte {
240 | if x != nil {
241 | return x.Data
242 | }
243 | return nil
244 | }
245 |
246 | func (x *TopicEventRequest) GetTopic() string {
247 | if x != nil {
248 | return x.Topic
249 | }
250 | return ""
251 | }
252 |
253 | func (x *TopicEventRequest) GetPubsubName() string {
254 | if x != nil {
255 | return x.PubsubName
256 | }
257 | return ""
258 | }
259 |
260 | // TopicEventResponse is response from app on published message
261 | type TopicEventResponse struct {
262 | state protoimpl.MessageState
263 | sizeCache protoimpl.SizeCache
264 | unknownFields protoimpl.UnknownFields
265 |
266 | // The list of output bindings.
267 | Status TopicEventResponse_TopicEventResponseStatus `protobuf:"varint,1,opt,name=status,proto3,enum=dapr.proto.runtime.v1.TopicEventResponse_TopicEventResponseStatus" json:"status,omitempty"`
268 | }
269 |
270 | func (x *TopicEventResponse) Reset() {
271 | *x = TopicEventResponse{}
272 | if protoimpl.UnsafeEnabled {
273 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[1]
274 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
275 | ms.StoreMessageInfo(mi)
276 | }
277 | }
278 |
279 | func (x *TopicEventResponse) String() string {
280 | return protoimpl.X.MessageStringOf(x)
281 | }
282 |
283 | func (*TopicEventResponse) ProtoMessage() {}
284 |
285 | func (x *TopicEventResponse) ProtoReflect() protoreflect.Message {
286 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[1]
287 | if protoimpl.UnsafeEnabled && x != nil {
288 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
289 | if ms.LoadMessageInfo() == nil {
290 | ms.StoreMessageInfo(mi)
291 | }
292 | return ms
293 | }
294 | return mi.MessageOf(x)
295 | }
296 |
297 | // Deprecated: Use TopicEventResponse.ProtoReflect.Descriptor instead.
298 | func (*TopicEventResponse) Descriptor() ([]byte, []int) {
299 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{1}
300 | }
301 |
302 | func (x *TopicEventResponse) GetStatus() TopicEventResponse_TopicEventResponseStatus {
303 | if x != nil {
304 | return x.Status
305 | }
306 | return TopicEventResponse_SUCCESS
307 | }
308 |
309 | // BindingEventRequest represents input bindings event.
310 | type BindingEventRequest struct {
311 | state protoimpl.MessageState
312 | sizeCache protoimpl.SizeCache
313 | unknownFields protoimpl.UnknownFields
314 |
315 | // Requried. The name of the input binding component.
316 | Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
317 | // Required. The payload that the input bindings sent
318 | Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
319 | // The metadata set by the input binging components.
320 | Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
321 | }
322 |
323 | func (x *BindingEventRequest) Reset() {
324 | *x = BindingEventRequest{}
325 | if protoimpl.UnsafeEnabled {
326 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[2]
327 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
328 | ms.StoreMessageInfo(mi)
329 | }
330 | }
331 |
332 | func (x *BindingEventRequest) String() string {
333 | return protoimpl.X.MessageStringOf(x)
334 | }
335 |
336 | func (*BindingEventRequest) ProtoMessage() {}
337 |
338 | func (x *BindingEventRequest) ProtoReflect() protoreflect.Message {
339 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[2]
340 | if protoimpl.UnsafeEnabled && x != nil {
341 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
342 | if ms.LoadMessageInfo() == nil {
343 | ms.StoreMessageInfo(mi)
344 | }
345 | return ms
346 | }
347 | return mi.MessageOf(x)
348 | }
349 |
350 | // Deprecated: Use BindingEventRequest.ProtoReflect.Descriptor instead.
351 | func (*BindingEventRequest) Descriptor() ([]byte, []int) {
352 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{2}
353 | }
354 |
355 | func (x *BindingEventRequest) GetName() string {
356 | if x != nil {
357 | return x.Name
358 | }
359 | return ""
360 | }
361 |
362 | func (x *BindingEventRequest) GetData() []byte {
363 | if x != nil {
364 | return x.Data
365 | }
366 | return nil
367 | }
368 |
369 | func (x *BindingEventRequest) GetMetadata() map[string]string {
370 | if x != nil {
371 | return x.Metadata
372 | }
373 | return nil
374 | }
375 |
376 | // BindingEventResponse includes operations to save state or
377 | // send data to output bindings optionally.
378 | type BindingEventResponse struct {
379 | state protoimpl.MessageState
380 | sizeCache protoimpl.SizeCache
381 | unknownFields protoimpl.UnknownFields
382 |
383 | // The name of state store where states are saved.
384 | StoreName string `protobuf:"bytes,1,opt,name=store_name,json=storeName,proto3" json:"store_name,omitempty"`
385 | // The state key values which will be stored in store_name.
386 | States []*v1.StateItem `protobuf:"bytes,2,rep,name=states,proto3" json:"states,omitempty"`
387 | // The list of output bindings.
388 | To []string `protobuf:"bytes,3,rep,name=to,proto3" json:"to,omitempty"`
389 | // The content which will be sent to "to" output bindings.
390 | Data []byte `protobuf:"bytes,4,opt,name=data,proto3" json:"data,omitempty"`
391 | // The concurrency of output bindings to send data to
392 | // "to" output bindings list. The default is SEQUENTIAL.
393 | Concurrency BindingEventResponse_BindingEventConcurrency `protobuf:"varint,5,opt,name=concurrency,proto3,enum=dapr.proto.runtime.v1.BindingEventResponse_BindingEventConcurrency" json:"concurrency,omitempty"`
394 | }
395 |
396 | func (x *BindingEventResponse) Reset() {
397 | *x = BindingEventResponse{}
398 | if protoimpl.UnsafeEnabled {
399 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[3]
400 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
401 | ms.StoreMessageInfo(mi)
402 | }
403 | }
404 |
405 | func (x *BindingEventResponse) String() string {
406 | return protoimpl.X.MessageStringOf(x)
407 | }
408 |
409 | func (*BindingEventResponse) ProtoMessage() {}
410 |
411 | func (x *BindingEventResponse) ProtoReflect() protoreflect.Message {
412 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[3]
413 | if protoimpl.UnsafeEnabled && x != nil {
414 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
415 | if ms.LoadMessageInfo() == nil {
416 | ms.StoreMessageInfo(mi)
417 | }
418 | return ms
419 | }
420 | return mi.MessageOf(x)
421 | }
422 |
423 | // Deprecated: Use BindingEventResponse.ProtoReflect.Descriptor instead.
424 | func (*BindingEventResponse) Descriptor() ([]byte, []int) {
425 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{3}
426 | }
427 |
428 | func (x *BindingEventResponse) GetStoreName() string {
429 | if x != nil {
430 | return x.StoreName
431 | }
432 | return ""
433 | }
434 |
435 | func (x *BindingEventResponse) GetStates() []*v1.StateItem {
436 | if x != nil {
437 | return x.States
438 | }
439 | return nil
440 | }
441 |
442 | func (x *BindingEventResponse) GetTo() []string {
443 | if x != nil {
444 | return x.To
445 | }
446 | return nil
447 | }
448 |
449 | func (x *BindingEventResponse) GetData() []byte {
450 | if x != nil {
451 | return x.Data
452 | }
453 | return nil
454 | }
455 |
456 | func (x *BindingEventResponse) GetConcurrency() BindingEventResponse_BindingEventConcurrency {
457 | if x != nil {
458 | return x.Concurrency
459 | }
460 | return BindingEventResponse_SEQUENTIAL
461 | }
462 |
463 | // ListTopicSubscriptionsResponse is the message including the list of the subscribing topics.
464 | type ListTopicSubscriptionsResponse struct {
465 | state protoimpl.MessageState
466 | sizeCache protoimpl.SizeCache
467 | unknownFields protoimpl.UnknownFields
468 |
469 | // The list of topics.
470 | Subscriptions []*TopicSubscription `protobuf:"bytes,1,rep,name=subscriptions,proto3" json:"subscriptions,omitempty"`
471 | }
472 |
473 | func (x *ListTopicSubscriptionsResponse) Reset() {
474 | *x = ListTopicSubscriptionsResponse{}
475 | if protoimpl.UnsafeEnabled {
476 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[4]
477 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
478 | ms.StoreMessageInfo(mi)
479 | }
480 | }
481 |
482 | func (x *ListTopicSubscriptionsResponse) String() string {
483 | return protoimpl.X.MessageStringOf(x)
484 | }
485 |
486 | func (*ListTopicSubscriptionsResponse) ProtoMessage() {}
487 |
488 | func (x *ListTopicSubscriptionsResponse) ProtoReflect() protoreflect.Message {
489 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[4]
490 | if protoimpl.UnsafeEnabled && x != nil {
491 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
492 | if ms.LoadMessageInfo() == nil {
493 | ms.StoreMessageInfo(mi)
494 | }
495 | return ms
496 | }
497 | return mi.MessageOf(x)
498 | }
499 |
500 | // Deprecated: Use ListTopicSubscriptionsResponse.ProtoReflect.Descriptor instead.
501 | func (*ListTopicSubscriptionsResponse) Descriptor() ([]byte, []int) {
502 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{4}
503 | }
504 |
505 | func (x *ListTopicSubscriptionsResponse) GetSubscriptions() []*TopicSubscription {
506 | if x != nil {
507 | return x.Subscriptions
508 | }
509 | return nil
510 | }
511 |
512 | // TopicSubscription represents topic and metadata.
513 | type TopicSubscription struct {
514 | state protoimpl.MessageState
515 | sizeCache protoimpl.SizeCache
516 | unknownFields protoimpl.UnknownFields
517 |
518 | // Required. The name of the pubsub containing the topic below to subscribe to.
519 | PubsubName string `protobuf:"bytes,1,opt,name=pubsub_name,json=pubsubName,proto3" json:"pubsub_name,omitempty"`
520 | // Required. The name of topic which will be subscribed
521 | Topic string `protobuf:"bytes,2,opt,name=topic,proto3" json:"topic,omitempty"`
522 | // The optional properties used for this topic's subscribtion e.g. session id
523 | Metadata map[string]string `protobuf:"bytes,3,rep,name=metadata,proto3" json:"metadata,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
524 | }
525 |
526 | func (x *TopicSubscription) Reset() {
527 | *x = TopicSubscription{}
528 | if protoimpl.UnsafeEnabled {
529 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[5]
530 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
531 | ms.StoreMessageInfo(mi)
532 | }
533 | }
534 |
535 | func (x *TopicSubscription) String() string {
536 | return protoimpl.X.MessageStringOf(x)
537 | }
538 |
539 | func (*TopicSubscription) ProtoMessage() {}
540 |
541 | func (x *TopicSubscription) ProtoReflect() protoreflect.Message {
542 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[5]
543 | if protoimpl.UnsafeEnabled && x != nil {
544 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
545 | if ms.LoadMessageInfo() == nil {
546 | ms.StoreMessageInfo(mi)
547 | }
548 | return ms
549 | }
550 | return mi.MessageOf(x)
551 | }
552 |
553 | // Deprecated: Use TopicSubscription.ProtoReflect.Descriptor instead.
554 | func (*TopicSubscription) Descriptor() ([]byte, []int) {
555 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{5}
556 | }
557 |
558 | func (x *TopicSubscription) GetPubsubName() string {
559 | if x != nil {
560 | return x.PubsubName
561 | }
562 | return ""
563 | }
564 |
565 | func (x *TopicSubscription) GetTopic() string {
566 | if x != nil {
567 | return x.Topic
568 | }
569 | return ""
570 | }
571 |
572 | func (x *TopicSubscription) GetMetadata() map[string]string {
573 | if x != nil {
574 | return x.Metadata
575 | }
576 | return nil
577 | }
578 |
579 | // ListInputBindingsResponse is the message including the list of input bindings.
580 | type ListInputBindingsResponse struct {
581 | state protoimpl.MessageState
582 | sizeCache protoimpl.SizeCache
583 | unknownFields protoimpl.UnknownFields
584 |
585 | // The list of input bindings.
586 | Bindings []string `protobuf:"bytes,1,rep,name=bindings,proto3" json:"bindings,omitempty"`
587 | }
588 |
589 | func (x *ListInputBindingsResponse) Reset() {
590 | *x = ListInputBindingsResponse{}
591 | if protoimpl.UnsafeEnabled {
592 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[6]
593 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
594 | ms.StoreMessageInfo(mi)
595 | }
596 | }
597 |
598 | func (x *ListInputBindingsResponse) String() string {
599 | return protoimpl.X.MessageStringOf(x)
600 | }
601 |
602 | func (*ListInputBindingsResponse) ProtoMessage() {}
603 |
604 | func (x *ListInputBindingsResponse) ProtoReflect() protoreflect.Message {
605 | mi := &file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[6]
606 | if protoimpl.UnsafeEnabled && x != nil {
607 | ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
608 | if ms.LoadMessageInfo() == nil {
609 | ms.StoreMessageInfo(mi)
610 | }
611 | return ms
612 | }
613 | return mi.MessageOf(x)
614 | }
615 |
616 | // Deprecated: Use ListInputBindingsResponse.ProtoReflect.Descriptor instead.
617 | func (*ListInputBindingsResponse) Descriptor() ([]byte, []int) {
618 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP(), []int{6}
619 | }
620 |
621 | func (x *ListInputBindingsResponse) GetBindings() []string {
622 | if x != nil {
623 | return x.Bindings
624 | }
625 | return nil
626 | }
627 |
628 | var File_dapr_proto_runtime_v1_appcallback_proto protoreflect.FileDescriptor
629 |
630 | var file_dapr_proto_runtime_v1_appcallback_proto_rawDesc = []byte{
631 | 0x0a, 0x27, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x72, 0x75, 0x6e,
632 | 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x2f, 0x61, 0x70, 0x70, 0x63, 0x61, 0x6c, 0x6c, 0x62,
633 | 0x61, 0x63, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x15, 0x64, 0x61, 0x70, 0x72, 0x2e,
634 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31,
635 | 0x1a, 0x1b, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75,
636 | 0x66, 0x2f, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x21, 0x64,
637 | 0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e,
638 | 0x2f, 0x76, 0x31, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
639 | 0x22, 0xe9, 0x01, 0x0a, 0x11, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
640 | 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
641 | 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65,
642 | 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x12, 0x12,
643 | 0x0a, 0x04, 0x74, 0x79, 0x70, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x79,
644 | 0x70, 0x65, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x70, 0x65, 0x63, 0x5f, 0x76, 0x65, 0x72, 0x73, 0x69,
645 | 0x6f, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x73, 0x70, 0x65, 0x63, 0x56, 0x65,
646 | 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x2a, 0x0a, 0x11, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x63, 0x6f,
647 | 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
648 | 0x52, 0x0f, 0x64, 0x61, 0x74, 0x61, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70,
649 | 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x07, 0x20, 0x01, 0x28, 0x0c, 0x52,
650 | 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x06,
651 | 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x12, 0x1f, 0x0a, 0x0b, 0x70,
652 | 0x75, 0x62, 0x73, 0x75, 0x62, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x09,
653 | 0x52, 0x0a, 0x70, 0x75, 0x62, 0x73, 0x75, 0x62, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0xae, 0x01, 0x0a,
654 | 0x12, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f,
655 | 0x6e, 0x73, 0x65, 0x12, 0x5a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20,
656 | 0x01, 0x28, 0x0e, 0x32, 0x42, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
657 | 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69,
658 | 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x54,
659 | 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
660 | 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22,
661 | 0x3c, 0x0a, 0x18, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
662 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0b, 0x0a, 0x07, 0x53,
663 | 0x55, 0x43, 0x43, 0x45, 0x53, 0x53, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x52, 0x45, 0x54, 0x52,
664 | 0x59, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x44, 0x52, 0x4f, 0x50, 0x10, 0x02, 0x22, 0xd0, 0x01,
665 | 0x0a, 0x13, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65,
666 | 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
667 | 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74,
668 | 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x54, 0x0a,
669 | 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
670 | 0x38, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e,
671 | 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45,
672 | 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x4d, 0x65, 0x74, 0x61,
673 | 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64,
674 | 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45,
675 | 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
676 | 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18,
677 | 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
678 | 0x22, 0xb2, 0x02, 0x0a, 0x14, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e,
679 | 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x74, 0x6f,
680 | 0x72, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x73,
681 | 0x74, 0x6f, 0x72, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x37, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74,
682 | 0x65, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x1f, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e,
683 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e,
684 | 0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x65,
685 | 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x74, 0x6f, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x74,
686 | 0x6f, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0c, 0x52,
687 | 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x65, 0x0a, 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72,
688 | 0x65, 0x6e, 0x63, 0x79, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x43, 0x2e, 0x64, 0x61, 0x70,
689 | 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e,
690 | 0x76, 0x31, 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
691 | 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45,
692 | 0x76, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x52,
693 | 0x0b, 0x63, 0x6f, 0x6e, 0x63, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x22, 0x37, 0x0a, 0x17,
694 | 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x43, 0x6f, 0x6e, 0x63,
695 | 0x75, 0x72, 0x72, 0x65, 0x6e, 0x63, 0x79, 0x12, 0x0e, 0x0a, 0x0a, 0x53, 0x45, 0x51, 0x55, 0x45,
696 | 0x4e, 0x54, 0x49, 0x41, 0x4c, 0x10, 0x00, 0x12, 0x0c, 0x0a, 0x08, 0x50, 0x41, 0x52, 0x41, 0x4c,
697 | 0x4c, 0x45, 0x4c, 0x10, 0x01, 0x22, 0x70, 0x0a, 0x1e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x6f, 0x70,
698 | 0x69, 0x63, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52,
699 | 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x4e, 0x0a, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63,
700 | 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28,
701 | 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74,
702 | 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x53, 0x75, 0x62, 0x73,
703 | 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0d, 0x73, 0x75, 0x62, 0x73, 0x63, 0x72,
704 | 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0xdb, 0x01, 0x0a, 0x11, 0x54, 0x6f, 0x70, 0x69,
705 | 0x63, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1f, 0x0a,
706 | 0x0b, 0x70, 0x75, 0x62, 0x73, 0x75, 0x62, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
707 | 0x28, 0x09, 0x52, 0x0a, 0x70, 0x75, 0x62, 0x73, 0x75, 0x62, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14,
708 | 0x0a, 0x05, 0x74, 0x6f, 0x70, 0x69, 0x63, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74,
709 | 0x6f, 0x70, 0x69, 0x63, 0x12, 0x52, 0x0a, 0x08, 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61,
710 | 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x36, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72,
711 | 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54,
712 | 0x6f, 0x70, 0x69, 0x63, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
713 | 0x2e, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x08,
714 | 0x6d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0x1a, 0x3b, 0x0a, 0x0d, 0x4d, 0x65, 0x74, 0x61,
715 | 0x64, 0x61, 0x74, 0x61, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79,
716 | 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76,
717 | 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75,
718 | 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x37, 0x0a, 0x19, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x6e, 0x70,
719 | 0x75, 0x74, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
720 | 0x73, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x18, 0x01,
721 | 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x62, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x32, 0x86,
722 | 0x04, 0x0a, 0x0b, 0x41, 0x70, 0x70, 0x43, 0x61, 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x12, 0x57,
723 | 0x0a, 0x08, 0x4f, 0x6e, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x12, 0x23, 0x2e, 0x64, 0x61, 0x70,
724 | 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x6f, 0x6e, 0x2e, 0x76,
725 | 0x31, 0x2e, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a,
726 | 0x24, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x63, 0x6f, 0x6d,
727 | 0x6d, 0x6f, 0x6e, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x76, 0x6f, 0x6b, 0x65, 0x52, 0x65, 0x73,
728 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x69, 0x0a, 0x16, 0x4c, 0x69, 0x73, 0x74, 0x54,
729 | 0x6f, 0x70, 0x69, 0x63, 0x53, 0x75, 0x62, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e,
730 | 0x73, 0x12, 0x16, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f,
731 | 0x62, 0x75, 0x66, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x35, 0x2e, 0x64, 0x61, 0x70, 0x72,
732 | 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76,
733 | 0x31, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x53, 0x75, 0x62, 0x73, 0x63,
734 | 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
735 | 0x22, 0x00, 0x12, 0x65, 0x0a, 0x0c, 0x4f, 0x6e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65,
736 | 0x6e, 0x74, 0x12, 0x28, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e,
737 | 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63,
738 | 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x64,
739 | 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d,
740 | 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x54, 0x6f, 0x70, 0x69, 0x63, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52,
741 | 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x5f, 0x0a, 0x11, 0x4c, 0x69, 0x73,
742 | 0x74, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73, 0x12, 0x16,
743 | 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66,
744 | 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x1a, 0x30, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72,
745 | 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x4c,
746 | 0x69, 0x73, 0x74, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x73,
747 | 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x6b, 0x0a, 0x0e, 0x4f, 0x6e,
748 | 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x12, 0x2a, 0x2e, 0x64,
749 | 0x61, 0x70, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d,
750 | 0x65, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e,
751 | 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x2b, 0x2e, 0x64, 0x61, 0x70, 0x72, 0x2e,
752 | 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2e, 0x76, 0x31,
753 | 0x2e, 0x42, 0x69, 0x6e, 0x64, 0x69, 0x6e, 0x67, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73,
754 | 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0x7c, 0x0a, 0x0a, 0x69, 0x6f, 0x2e, 0x64, 0x61,
755 | 0x70, 0x72, 0x2e, 0x76, 0x31, 0x42, 0x15, 0x44, 0x61, 0x70, 0x72, 0x41, 0x70, 0x70, 0x43, 0x61,
756 | 0x6c, 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x73, 0x5a, 0x34, 0x67, 0x69,
757 | 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x67, 0x6f,
758 | 0x2d, 0x73, 0x64, 0x6b, 0x2f, 0x64, 0x61, 0x70, 0x72, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2f,
759 | 0x72, 0x75, 0x6e, 0x74, 0x69, 0x6d, 0x65, 0x2f, 0x76, 0x31, 0x3b, 0x72, 0x75, 0x6e, 0x74, 0x69,
760 | 0x6d, 0x65, 0xaa, 0x02, 0x20, 0x44, 0x61, 0x70, 0x72, 0x2e, 0x41, 0x70, 0x70, 0x43, 0x61, 0x6c,
761 | 0x6c, 0x62, 0x61, 0x63, 0x6b, 0x2e, 0x41, 0x75, 0x74, 0x6f, 0x67, 0x65, 0x6e, 0x2e, 0x47, 0x72,
762 | 0x70, 0x63, 0x2e, 0x76, 0x31, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
763 | }
764 |
765 | var (
766 | file_dapr_proto_runtime_v1_appcallback_proto_rawDescOnce sync.Once
767 | file_dapr_proto_runtime_v1_appcallback_proto_rawDescData = file_dapr_proto_runtime_v1_appcallback_proto_rawDesc
768 | )
769 |
770 | func file_dapr_proto_runtime_v1_appcallback_proto_rawDescGZIP() []byte {
771 | file_dapr_proto_runtime_v1_appcallback_proto_rawDescOnce.Do(func() {
772 | file_dapr_proto_runtime_v1_appcallback_proto_rawDescData = protoimpl.X.CompressGZIP(file_dapr_proto_runtime_v1_appcallback_proto_rawDescData)
773 | })
774 | return file_dapr_proto_runtime_v1_appcallback_proto_rawDescData
775 | }
776 |
777 | var file_dapr_proto_runtime_v1_appcallback_proto_enumTypes = make([]protoimpl.EnumInfo, 2)
778 | var file_dapr_proto_runtime_v1_appcallback_proto_msgTypes = make([]protoimpl.MessageInfo, 9)
779 | var file_dapr_proto_runtime_v1_appcallback_proto_goTypes = []interface{}{
780 | (TopicEventResponse_TopicEventResponseStatus)(0), // 0: dapr.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus
781 | (BindingEventResponse_BindingEventConcurrency)(0), // 1: dapr.proto.runtime.v1.BindingEventResponse.BindingEventConcurrency
782 | (*TopicEventRequest)(nil), // 2: dapr.proto.runtime.v1.TopicEventRequest
783 | (*TopicEventResponse)(nil), // 3: dapr.proto.runtime.v1.TopicEventResponse
784 | (*BindingEventRequest)(nil), // 4: dapr.proto.runtime.v1.BindingEventRequest
785 | (*BindingEventResponse)(nil), // 5: dapr.proto.runtime.v1.BindingEventResponse
786 | (*ListTopicSubscriptionsResponse)(nil), // 6: dapr.proto.runtime.v1.ListTopicSubscriptionsResponse
787 | (*TopicSubscription)(nil), // 7: dapr.proto.runtime.v1.TopicSubscription
788 | (*ListInputBindingsResponse)(nil), // 8: dapr.proto.runtime.v1.ListInputBindingsResponse
789 | nil, // 9: dapr.proto.runtime.v1.BindingEventRequest.MetadataEntry
790 | nil, // 10: dapr.proto.runtime.v1.TopicSubscription.MetadataEntry
791 | (*v1.StateItem)(nil), // 11: dapr.proto.common.v1.StateItem
792 | (*v1.InvokeRequest)(nil), // 12: dapr.proto.common.v1.InvokeRequest
793 | (*empty.Empty)(nil), // 13: google.protobuf.Empty
794 | (*v1.InvokeResponse)(nil), // 14: dapr.proto.common.v1.InvokeResponse
795 | }
796 | var file_dapr_proto_runtime_v1_appcallback_proto_depIdxs = []int32{
797 | 0, // 0: dapr.proto.runtime.v1.TopicEventResponse.status:type_name -> dapr.proto.runtime.v1.TopicEventResponse.TopicEventResponseStatus
798 | 9, // 1: dapr.proto.runtime.v1.BindingEventRequest.metadata:type_name -> dapr.proto.runtime.v1.BindingEventRequest.MetadataEntry
799 | 11, // 2: dapr.proto.runtime.v1.BindingEventResponse.states:type_name -> dapr.proto.common.v1.StateItem
800 | 1, // 3: dapr.proto.runtime.v1.BindingEventResponse.concurrency:type_name -> dapr.proto.runtime.v1.BindingEventResponse.BindingEventConcurrency
801 | 7, // 4: dapr.proto.runtime.v1.ListTopicSubscriptionsResponse.subscriptions:type_name -> dapr.proto.runtime.v1.TopicSubscription
802 | 10, // 5: dapr.proto.runtime.v1.TopicSubscription.metadata:type_name -> dapr.proto.runtime.v1.TopicSubscription.MetadataEntry
803 | 12, // 6: dapr.proto.runtime.v1.AppCallback.OnInvoke:input_type -> dapr.proto.common.v1.InvokeRequest
804 | 13, // 7: dapr.proto.runtime.v1.AppCallback.ListTopicSubscriptions:input_type -> google.protobuf.Empty
805 | 2, // 8: dapr.proto.runtime.v1.AppCallback.OnTopicEvent:input_type -> dapr.proto.runtime.v1.TopicEventRequest
806 | 13, // 9: dapr.proto.runtime.v1.AppCallback.ListInputBindings:input_type -> google.protobuf.Empty
807 | 4, // 10: dapr.proto.runtime.v1.AppCallback.OnBindingEvent:input_type -> dapr.proto.runtime.v1.BindingEventRequest
808 | 14, // 11: dapr.proto.runtime.v1.AppCallback.OnInvoke:output_type -> dapr.proto.common.v1.InvokeResponse
809 | 6, // 12: dapr.proto.runtime.v1.AppCallback.ListTopicSubscriptions:output_type -> dapr.proto.runtime.v1.ListTopicSubscriptionsResponse
810 | 3, // 13: dapr.proto.runtime.v1.AppCallback.OnTopicEvent:output_type -> dapr.proto.runtime.v1.TopicEventResponse
811 | 8, // 14: dapr.proto.runtime.v1.AppCallback.ListInputBindings:output_type -> dapr.proto.runtime.v1.ListInputBindingsResponse
812 | 5, // 15: dapr.proto.runtime.v1.AppCallback.OnBindingEvent:output_type -> dapr.proto.runtime.v1.BindingEventResponse
813 | 11, // [11:16] is the sub-list for method output_type
814 | 6, // [6:11] is the sub-list for method input_type
815 | 6, // [6:6] is the sub-list for extension type_name
816 | 6, // [6:6] is the sub-list for extension extendee
817 | 0, // [0:6] is the sub-list for field type_name
818 | }
819 |
820 | func init() { file_dapr_proto_runtime_v1_appcallback_proto_init() }
821 | func file_dapr_proto_runtime_v1_appcallback_proto_init() {
822 | if File_dapr_proto_runtime_v1_appcallback_proto != nil {
823 | return
824 | }
825 | if !protoimpl.UnsafeEnabled {
826 | file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
827 | switch v := v.(*TopicEventRequest); i {
828 | case 0:
829 | return &v.state
830 | case 1:
831 | return &v.sizeCache
832 | case 2:
833 | return &v.unknownFields
834 | default:
835 | return nil
836 | }
837 | }
838 | file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
839 | switch v := v.(*TopicEventResponse); i {
840 | case 0:
841 | return &v.state
842 | case 1:
843 | return &v.sizeCache
844 | case 2:
845 | return &v.unknownFields
846 | default:
847 | return nil
848 | }
849 | }
850 | file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
851 | switch v := v.(*BindingEventRequest); i {
852 | case 0:
853 | return &v.state
854 | case 1:
855 | return &v.sizeCache
856 | case 2:
857 | return &v.unknownFields
858 | default:
859 | return nil
860 | }
861 | }
862 | file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
863 | switch v := v.(*BindingEventResponse); i {
864 | case 0:
865 | return &v.state
866 | case 1:
867 | return &v.sizeCache
868 | case 2:
869 | return &v.unknownFields
870 | default:
871 | return nil
872 | }
873 | }
874 | file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
875 | switch v := v.(*ListTopicSubscriptionsResponse); i {
876 | case 0:
877 | return &v.state
878 | case 1:
879 | return &v.sizeCache
880 | case 2:
881 | return &v.unknownFields
882 | default:
883 | return nil
884 | }
885 | }
886 | file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
887 | switch v := v.(*TopicSubscription); i {
888 | case 0:
889 | return &v.state
890 | case 1:
891 | return &v.sizeCache
892 | case 2:
893 | return &v.unknownFields
894 | default:
895 | return nil
896 | }
897 | }
898 | file_dapr_proto_runtime_v1_appcallback_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} {
899 | switch v := v.(*ListInputBindingsResponse); i {
900 | case 0:
901 | return &v.state
902 | case 1:
903 | return &v.sizeCache
904 | case 2:
905 | return &v.unknownFields
906 | default:
907 | return nil
908 | }
909 | }
910 | }
911 | type x struct{}
912 | out := protoimpl.TypeBuilder{
913 | File: protoimpl.DescBuilder{
914 | GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
915 | RawDescriptor: file_dapr_proto_runtime_v1_appcallback_proto_rawDesc,
916 | NumEnums: 2,
917 | NumMessages: 9,
918 | NumExtensions: 0,
919 | NumServices: 1,
920 | },
921 | GoTypes: file_dapr_proto_runtime_v1_appcallback_proto_goTypes,
922 | DependencyIndexes: file_dapr_proto_runtime_v1_appcallback_proto_depIdxs,
923 | EnumInfos: file_dapr_proto_runtime_v1_appcallback_proto_enumTypes,
924 | MessageInfos: file_dapr_proto_runtime_v1_appcallback_proto_msgTypes,
925 | }.Build()
926 | File_dapr_proto_runtime_v1_appcallback_proto = out.File
927 | file_dapr_proto_runtime_v1_appcallback_proto_rawDesc = nil
928 | file_dapr_proto_runtime_v1_appcallback_proto_goTypes = nil
929 | file_dapr_proto_runtime_v1_appcallback_proto_depIdxs = nil
930 | }
931 |
932 | // Reference imports to suppress errors if they are not otherwise used.
933 | var _ context.Context
934 | var _ grpc.ClientConnInterface
935 |
936 | // This is a compile-time assertion to ensure that this generated file
937 | // is compatible with the grpc package it is being compiled against.
938 | const _ = grpc.SupportPackageIsVersion6
939 |
940 | // AppCallbackClient is the client API for AppCallback service.
941 | //
942 | // For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
943 | type AppCallbackClient interface {
944 | // Invokes service method with InvokeRequest.
945 | OnInvoke(ctx context.Context, in *v1.InvokeRequest, opts ...grpc.CallOption) (*v1.InvokeResponse, error)
946 | // Lists all topics subscribed by this app.
947 | ListTopicSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListTopicSubscriptionsResponse, error)
948 | // Subscribes events from Pubsub
949 | OnTopicEvent(ctx context.Context, in *TopicEventRequest, opts ...grpc.CallOption) (*TopicEventResponse, error)
950 | // Lists all input bindings subscribed by this app.
951 | ListInputBindings(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListInputBindingsResponse, error)
952 | // Listens events from the input bindings
953 | //
954 | // User application can save the states or send the events to the output
955 | // bindings optionally by returning BindingEventResponse.
956 | OnBindingEvent(ctx context.Context, in *BindingEventRequest, opts ...grpc.CallOption) (*BindingEventResponse, error)
957 | }
958 |
959 | type appCallbackClient struct {
960 | cc grpc.ClientConnInterface
961 | }
962 |
963 | func NewAppCallbackClient(cc grpc.ClientConnInterface) AppCallbackClient {
964 | return &appCallbackClient{cc}
965 | }
966 |
967 | func (c *appCallbackClient) OnInvoke(ctx context.Context, in *v1.InvokeRequest, opts ...grpc.CallOption) (*v1.InvokeResponse, error) {
968 | out := new(v1.InvokeResponse)
969 | err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/OnInvoke", in, out, opts...)
970 | if err != nil {
971 | return nil, err
972 | }
973 | return out, nil
974 | }
975 |
976 | func (c *appCallbackClient) ListTopicSubscriptions(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListTopicSubscriptionsResponse, error) {
977 | out := new(ListTopicSubscriptionsResponse)
978 | err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/ListTopicSubscriptions", in, out, opts...)
979 | if err != nil {
980 | return nil, err
981 | }
982 | return out, nil
983 | }
984 |
985 | func (c *appCallbackClient) OnTopicEvent(ctx context.Context, in *TopicEventRequest, opts ...grpc.CallOption) (*TopicEventResponse, error) {
986 | out := new(TopicEventResponse)
987 | err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/OnTopicEvent", in, out, opts...)
988 | if err != nil {
989 | return nil, err
990 | }
991 | return out, nil
992 | }
993 |
994 | func (c *appCallbackClient) ListInputBindings(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*ListInputBindingsResponse, error) {
995 | out := new(ListInputBindingsResponse)
996 | err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/ListInputBindings", in, out, opts...)
997 | if err != nil {
998 | return nil, err
999 | }
1000 | return out, nil
1001 | }
1002 |
1003 | func (c *appCallbackClient) OnBindingEvent(ctx context.Context, in *BindingEventRequest, opts ...grpc.CallOption) (*BindingEventResponse, error) {
1004 | out := new(BindingEventResponse)
1005 | err := c.cc.Invoke(ctx, "/dapr.proto.runtime.v1.AppCallback/OnBindingEvent", in, out, opts...)
1006 | if err != nil {
1007 | return nil, err
1008 | }
1009 | return out, nil
1010 | }
1011 |
1012 | // AppCallbackServer is the server API for AppCallback service.
1013 | type AppCallbackServer interface {
1014 | // Invokes service method with InvokeRequest.
1015 | OnInvoke(context.Context, *v1.InvokeRequest) (*v1.InvokeResponse, error)
1016 | // Lists all topics subscribed by this app.
1017 | ListTopicSubscriptions(context.Context, *empty.Empty) (*ListTopicSubscriptionsResponse, error)
1018 | // Subscribes events from Pubsub
1019 | OnTopicEvent(context.Context, *TopicEventRequest) (*TopicEventResponse, error)
1020 | // Lists all input bindings subscribed by this app.
1021 | ListInputBindings(context.Context, *empty.Empty) (*ListInputBindingsResponse, error)
1022 | // Listens events from the input bindings
1023 | //
1024 | // User application can save the states or send the events to the output
1025 | // bindings optionally by returning BindingEventResponse.
1026 | OnBindingEvent(context.Context, *BindingEventRequest) (*BindingEventResponse, error)
1027 | }
1028 |
1029 | // UnimplementedAppCallbackServer can be embedded to have forward compatible implementations.
1030 | type UnimplementedAppCallbackServer struct {
1031 | }
1032 |
1033 | func (*UnimplementedAppCallbackServer) OnInvoke(context.Context, *v1.InvokeRequest) (*v1.InvokeResponse, error) {
1034 | return nil, status.Errorf(codes.Unimplemented, "method OnInvoke not implemented")
1035 | }
1036 | func (*UnimplementedAppCallbackServer) ListTopicSubscriptions(context.Context, *empty.Empty) (*ListTopicSubscriptionsResponse, error) {
1037 | return nil, status.Errorf(codes.Unimplemented, "method ListTopicSubscriptions not implemented")
1038 | }
1039 | func (*UnimplementedAppCallbackServer) OnTopicEvent(context.Context, *TopicEventRequest) (*TopicEventResponse, error) {
1040 | return nil, status.Errorf(codes.Unimplemented, "method OnTopicEvent not implemented")
1041 | }
1042 | func (*UnimplementedAppCallbackServer) ListInputBindings(context.Context, *empty.Empty) (*ListInputBindingsResponse, error) {
1043 | return nil, status.Errorf(codes.Unimplemented, "method ListInputBindings not implemented")
1044 | }
1045 | func (*UnimplementedAppCallbackServer) OnBindingEvent(context.Context, *BindingEventRequest) (*BindingEventResponse, error) {
1046 | return nil, status.Errorf(codes.Unimplemented, "method OnBindingEvent not implemented")
1047 | }
1048 |
1049 | func RegisterAppCallbackServer(s *grpc.Server, srv AppCallbackServer) {
1050 | s.RegisterService(&_AppCallback_serviceDesc, srv)
1051 | }
1052 |
1053 | func _AppCallback_OnInvoke_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
1054 | in := new(v1.InvokeRequest)
1055 | if err := dec(in); err != nil {
1056 | return nil, err
1057 | }
1058 | if interceptor == nil {
1059 | return srv.(AppCallbackServer).OnInvoke(ctx, in)
1060 | }
1061 | info := &grpc.UnaryServerInfo{
1062 | Server: srv,
1063 | FullMethod: "/dapr.proto.runtime.v1.AppCallback/OnInvoke",
1064 | }
1065 | handler := func(ctx context.Context, req interface{}) (interface{}, error) {
1066 | return srv.(AppCallbackServer).OnInvoke(ctx, req.(*v1.InvokeRequest))
1067 | }
1068 | return interceptor(ctx, in, info, handler)
1069 | }
1070 |
1071 | func _AppCallback_ListTopicSubscriptions_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
1072 | in := new(empty.Empty)
1073 | if err := dec(in); err != nil {
1074 | return nil, err
1075 | }
1076 | if interceptor == nil {
1077 | return srv.(AppCallbackServer).ListTopicSubscriptions(ctx, in)
1078 | }
1079 | info := &grpc.UnaryServerInfo{
1080 | Server: srv,
1081 | FullMethod: "/dapr.proto.runtime.v1.AppCallback/ListTopicSubscriptions",
1082 | }
1083 | handler := func(ctx context.Context, req interface{}) (interface{}, error) {
1084 | return srv.(AppCallbackServer).ListTopicSubscriptions(ctx, req.(*empty.Empty))
1085 | }
1086 | return interceptor(ctx, in, info, handler)
1087 | }
1088 |
1089 | func _AppCallback_OnTopicEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
1090 | in := new(TopicEventRequest)
1091 | if err := dec(in); err != nil {
1092 | return nil, err
1093 | }
1094 | if interceptor == nil {
1095 | return srv.(AppCallbackServer).OnTopicEvent(ctx, in)
1096 | }
1097 | info := &grpc.UnaryServerInfo{
1098 | Server: srv,
1099 | FullMethod: "/dapr.proto.runtime.v1.AppCallback/OnTopicEvent",
1100 | }
1101 | handler := func(ctx context.Context, req interface{}) (interface{}, error) {
1102 | return srv.(AppCallbackServer).OnTopicEvent(ctx, req.(*TopicEventRequest))
1103 | }
1104 | return interceptor(ctx, in, info, handler)
1105 | }
1106 |
1107 | func _AppCallback_ListInputBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
1108 | in := new(empty.Empty)
1109 | if err := dec(in); err != nil {
1110 | return nil, err
1111 | }
1112 | if interceptor == nil {
1113 | return srv.(AppCallbackServer).ListInputBindings(ctx, in)
1114 | }
1115 | info := &grpc.UnaryServerInfo{
1116 | Server: srv,
1117 | FullMethod: "/dapr.proto.runtime.v1.AppCallback/ListInputBindings",
1118 | }
1119 | handler := func(ctx context.Context, req interface{}) (interface{}, error) {
1120 | return srv.(AppCallbackServer).ListInputBindings(ctx, req.(*empty.Empty))
1121 | }
1122 | return interceptor(ctx, in, info, handler)
1123 | }
1124 |
1125 | func _AppCallback_OnBindingEvent_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
1126 | in := new(BindingEventRequest)
1127 | if err := dec(in); err != nil {
1128 | return nil, err
1129 | }
1130 | if interceptor == nil {
1131 | return srv.(AppCallbackServer).OnBindingEvent(ctx, in)
1132 | }
1133 | info := &grpc.UnaryServerInfo{
1134 | Server: srv,
1135 | FullMethod: "/dapr.proto.runtime.v1.AppCallback/OnBindingEvent",
1136 | }
1137 | handler := func(ctx context.Context, req interface{}) (interface{}, error) {
1138 | return srv.(AppCallbackServer).OnBindingEvent(ctx, req.(*BindingEventRequest))
1139 | }
1140 | return interceptor(ctx, in, info, handler)
1141 | }
1142 |
1143 | var _AppCallback_serviceDesc = grpc.ServiceDesc{
1144 | ServiceName: "dapr.proto.runtime.v1.AppCallback",
1145 | HandlerType: (*AppCallbackServer)(nil),
1146 | Methods: []grpc.MethodDesc{
1147 | {
1148 | MethodName: "OnInvoke",
1149 | Handler: _AppCallback_OnInvoke_Handler,
1150 | },
1151 | {
1152 | MethodName: "ListTopicSubscriptions",
1153 | Handler: _AppCallback_ListTopicSubscriptions_Handler,
1154 | },
1155 | {
1156 | MethodName: "OnTopicEvent",
1157 | Handler: _AppCallback_OnTopicEvent_Handler,
1158 | },
1159 | {
1160 | MethodName: "ListInputBindings",
1161 | Handler: _AppCallback_ListInputBindings_Handler,
1162 | },
1163 | {
1164 | MethodName: "OnBindingEvent",
1165 | Handler: _AppCallback_OnBindingEvent_Handler,
1166 | },
1167 | },
1168 | Streams: []grpc.StreamDesc{},
1169 | Metadata: "dapr/proto/runtime/v1/appcallback.proto",
1170 | }
1171 |
--------------------------------------------------------------------------------