From 3f2d2e6ffa46cc797a66eebe5a53394ea9c224f2 Mon Sep 17 00:00:00 2001 From: Ricardo Niepel Date: Tue, 31 Mar 2020 23:58:57 +0200 Subject: [PATCH 1/2] Add optional Binding HTTP response body into spec (#471) * Add Binding AppResponse spec * Update bindings_api.md * Update bindings_api.md Co-authored-by: Yaron Schneider Co-authored-by: Mark Fussell Co-authored-by: Aman Bhardwaj --- reference/api/bindings_api.md | 71 ++++++++++++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 2 deletions(-) diff --git a/reference/api/bindings_api.md b/reference/api/bindings_api.md index 3667e42aa..1a4e8dd67 100644 --- a/reference/api/bindings_api.md +++ b/reference/api/bindings_api.md @@ -80,6 +80,73 @@ def incoming(): return "Kafka Event Processed!" ``` +### Binding endpoints + +Bindings are discovered from component yaml files. Dapr calls this endpoint on startup to ensure that app can handle this call. If the app doesn't have the endpoint, Dapr ignores it. + +#### HTTP Request + +```http +OPTIONS http://localhost:/ +``` + +#### HTTP Response codes + +Code | Description +---- | ----------- +404 | Application does not want to bind to the binding +all others | Application wants to bind to the binding + +#### URL Parameters + +Parameter | Description +--------- | ----------- +appPort | the application port +name | the name of the binding + +### Binding payload + +In order to deliver binding inputs, a POST call is made to user code with the name of the binding as the URL path. + +#### HTTP Request + +```http +POST http://localhost:/ +``` + +#### HTTP Response codes + +Code | Description +---- | ----------- +200 | Application processed the input binding successfully + +#### URL Parameters + +Parameter | Description +--------- | ----------- +appPort | the application port +name | the name of the binding + +#### HTTP Response body (optional) + +Optionally, a response body can be used to directly bind input bindings with state stores or output bindings. + +**Example:** +Dapr stores ```stateDataToStore``` into a state store named "stateStore". +Dapr sends ```jsonObject``` to the output bindings named "storage" and "queue" in parallel. +If ```concurrency``` is not set, it is sent out sequential (the example below shows these operations are done in parallel) + +```json +{ + "storeName": "stateStore", + "state": stateDataToStore, + + "to": ['storage', 'queue'], + "concurrency": "parallel", + "data": jsonObject, +} +``` + ## Sending Messages to Output Bindings This endpoint lets you invoke an Dapr output binding. @@ -111,14 +178,14 @@ The bindings endpoint receives the following JSON payload: ``` The `data` field takes any JSON serializable value and acts as the payload to be sent to the output binding. -The metadata is an array of key/value pairs and allows to set binding specific metadata for each call. +The metadata is an array of key/value pairs and allows you to set binding specific metadata for each call. ### URL Parameters Parameter | Description --------- | ----------- daprPort | the Dapr port -name | the name of the binding to invoke +name | the name of the output binding to invoke ### Examples From b6b4e2127611f78b313439debc533921f52cdd8c Mon Sep 17 00:00:00 2001 From: Yaron Schneider Date: Tue, 31 Mar 2020 15:00:00 -0700 Subject: [PATCH 2/2] remove redundant code snippet (#484) --- howto/create-grpc-app/README.md | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/howto/create-grpc-app/README.md b/howto/create-grpc-app/README.md index dfaa01a2c..77fe5fd99 100644 --- a/howto/create-grpc-app/README.md +++ b/howto/create-grpc-app/README.md @@ -66,8 +66,6 @@ import ( 2. Create the client -If mTLS is disabled: - ```go // Get the Dapr port and create a connection daprPort := os.Getenv("DAPR_GRPC_PORT") @@ -82,25 +80,6 @@ If mTLS is disabled: client := pb.NewDaprClient(conn) ``` -If mTLS is enabled: - -```go -tlsConfig := &tls.Config{ - InsecureSkipVerify: true, -} - -creds := credentials.NewTLS(tlsConfig) -conn, err := grpc.Dial(daprAddress, grpc.WithTransportCredentials(creds)) - -if err != nil { - fmt.Println(err) -} -defer conn.Close() - -// Create the client -client := pb.NewDaprClient(conn) -``` - 3. Invoke the Save State method ```go