mirror of https://github.com/dapr/docs.git
[Bindings] Docset refresh (#2595)
* bindings initial refresh Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com> * updates per Mark Signed-off-by: Hannah Hunter <hannahhunter@microsoft.com> Co-authored-by: Mark Fussell <markfussell@gmail.com>
This commit is contained in:
parent
96165997ee
commit
dd445be31f
|
@ -6,51 +6,67 @@ weight: 100
|
|||
description: Overview of the bindings API building block
|
||||
---
|
||||
|
||||
Using Dapr's bindings API, you can both trigger your app with events coming in from external systems and interface with external systems. In addition, the Dapr binding API enables you to:
|
||||
Using Dapr's bindings API, you can trigger your app with events coming in from external systems and interface with external systems. With the bindings API, you can:
|
||||
|
||||
- Remove the complexities of connecting to and polling from messaging systems, such as queues and message buses
|
||||
- Focus on business logic, instead of the implementation details of how to interact with a system
|
||||
- Keep your code free from SDKs or libraries
|
||||
- Handle retries and failure recovery
|
||||
- Switch between bindings at run time
|
||||
- Build portable applications with environment-specific bindings set up and no code changes required
|
||||
- Avoid the complexities of connecting to and polling from messaging systems, such as queues and message buses.
|
||||
- Focus on business logic, instead of the implementation details of interacting with a system.
|
||||
- Keep your code free from SDKs or libraries.
|
||||
- Handle retries and failure recovery.
|
||||
- Switch between bindings at runtime.
|
||||
- Build portable applications with environment-specific bindings set-up and no required code changes.
|
||||
|
||||
For example, with bindings, your microservice can respond to incoming Twilio/SMS messages without:
|
||||
|
||||
- Adding or configuring a third-party Twilio SDK
|
||||
- Worrying about polling from Twilio (or using websockets, etc.)
|
||||
- Worrying about polling from Twilio (or using WebSockets, etc.)
|
||||
|
||||
{{% alert title="Note" color="primary" %}}
|
||||
Bindings are developed independently of Dapr runtime. You can [view and contribute to the bindings](https://github.com/dapr/components-contrib/tree/master/bindings).
|
||||
|
||||
{{% /alert %}}
|
||||
|
||||
## Input bindings
|
||||
|
||||
With input bindings, you can trigger your application when an event from an external resource has occurred. An optional payload and metadata may be sent with the request.
|
||||
With input bindings, you can trigger your application when an event from an external resource occurs. An optional payload and metadata may be sent with the request.
|
||||
|
||||
In order to receive events from an input binding:
|
||||
To receive events from an input binding:
|
||||
|
||||
1. Define the component YAML that describes the type of binding and its metadata (connection info, etc.).
|
||||
2. Listen on an HTTP endpoint for the incoming event, or use the gRPC proto library to get incoming events.
|
||||
1. Define the component YAML that describes the binding type and its metadata (connection info, etc.).
|
||||
1. Listen for the incoming event using:
|
||||
- An HTTP endpoint
|
||||
- The gRPC proto library to get incoming events.
|
||||
|
||||
{{% alert title="Note" color="primary" %}}
|
||||
On startup, Dapr sends [an OPTIONS request]({{< ref "bindings_api.md#invoking-service-code-through-input-bindings" >}}) for all defined input bindings to the application and expects a status code 2xx or 405 if this application wants to subscribe to the binding.
|
||||
On startup, Dapr sends [an OPTIONS request]({{< ref "bindings_api.md#invoking-service-code-through-input-bindings" >}}) for all defined input bindings to the application. If the application wants to subscribe to the binding, Dapr expects a status code of 2xx or 405.
|
||||
|
||||
{{% /alert %}}
|
||||
|
||||
Read the [Create an event-driven app using input bindings]({{< ref howto-triggers.md >}}) page to get started with input bindings.
|
||||
Read the [Create an event-driven app using input bindings guide]({{< ref howto-triggers.md >}}) to get started with input bindings.
|
||||
|
||||
## Output bindings
|
||||
|
||||
With output bindings, you can invoke external resources. An optional payload and metadata can be sent with the invocation request.
|
||||
|
||||
In order to invoke an output binding:
|
||||
To invoke an output binding:
|
||||
|
||||
1. Define the component YAML that describes the type of binding and its metadata (connection info, etc.).
|
||||
1. Define the component YAML that describes the binding type and its metadata (connection info, etc.).
|
||||
2. Use the HTTP endpoint or gRPC method to invoke the binding with an optional payload.
|
||||
|
||||
Read the [Use output bindings to interface with external resources]({{< ref howto-bindings.md >}}) page to get started with output bindings.
|
||||
Read the [Use output bindings to interface with external resources guide]({{< ref howto-bindings.md >}}) to get started with output bindings.
|
||||
|
||||
## Try out bindings
|
||||
|
||||
### Quickstarts and tutorials
|
||||
|
||||
Want to put the Dapr bindings API to the test? Walk through the following quickstart and tutorials to see bindings in action:
|
||||
|
||||
| Quickstart/tutorial | Description |
|
||||
| ------------------- | ----------- |
|
||||
| [Bindings quickstart]({{< ref bindings-quickstart.md >}}) | Work with external systems using input bindings to respond to events and output bindings to call operations. |
|
||||
| [Bindings tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/bindings) | Demonstrates how to use Dapr to create input and output bindings to other components. Uses bindings to Kafka. |
|
||||
|
||||
### Start using bindings directly in your app
|
||||
|
||||
Want to skip the quickstarts? Not a problem. You can try out the bindings building block directly in your application to invoke output bindings and trigger input bindings. After [Dapr is installed]({{< ref "getting-started/_index.md" >}}), you can begin using the bindings API starting with [the input bindings how-to guide]({{< ref howto-triggers.md >}}).
|
||||
|
||||
## Next Steps
|
||||
|
||||
|
|
|
@ -6,23 +6,31 @@ description: "Invoke external systems with output bindings"
|
|||
weight: 300
|
||||
---
|
||||
|
||||
With output bindings, you can invoke external resources without depending on special SDK or libraries. An output binding represents a resource that Dapr uses to invoke and send messages to. For a complete sample showing output bindings, [walk through the tutorial](https://github.com/dapr/quickstarts/tree/master/tutorials/bindings).
|
||||
With output bindings, you can invoke external resources. An optional payload and metadata can be sent with the invocation request.
|
||||
|
||||
<img src="/images/building-block-output-binding-example.png" width=1000 alt="Diagram showing bindings of example service">
|
||||
<img src="/images/howto-bindings/kafka-output-binding.png" width=1000 alt="Diagram showing bindings of example service">
|
||||
|
||||
This guide uses a Kafka binding as an example. You can find your preferred binding spec from [the list of bindings components]({{< ref setup-bindings >}}).
|
||||
This guide uses a Kafka binding as an example. You can find your preferred binding spec from [the list of bindings components]({{< ref setup-bindings >}}). In this guide:
|
||||
|
||||
1. The example invokes the `/binding` endpoint with `checkout`, the name of the binding to invoke.
|
||||
1. The payload goes inside the mandatory `data` field, and can be any JSON serializable value.
|
||||
1. The `operation` field tells the binding what action it needs to take. For example, [the Kafka binding supports the `create` operation]({{< ref "kafka.md#binding-support" >}}).
|
||||
- You can check [which operations (specific to each component) are supported for every output binding]({{< ref supported-bindings >}}).
|
||||
|
||||
{{% alert title="Note" color="primary" %}}
|
||||
If you haven't already, [try out the bindings quickstart]({{< ref bindings-quickstart.md >}}) for a quick walk-through on how to use the bindings API.
|
||||
|
||||
{{% /alert %}}
|
||||
|
||||
## Create a binding
|
||||
|
||||
Create a new binding component with the name of `checkout`.
|
||||
Create a `binding.yaml` file and save to a `components` sub-folder in your application directory.
|
||||
|
||||
Within the `metadata` section, configure Kafka-related properties, such as:
|
||||
Create a new binding component named `checkout`. Within the `metadata` section, configure the following Kafka-related properties:
|
||||
|
||||
- The topic to which you'll publish the message
|
||||
- The broker
|
||||
|
||||
Create the following `binding.yaml` file and save to a `components` sub-folder in your application directory.
|
||||
|
||||
{{< tabs "Self-Hosted (CLI)" Kubernetes >}}
|
||||
|
||||
{{% codetab %}}
|
||||
|
@ -89,7 +97,7 @@ spec:
|
|||
|
||||
## Send an event (output binding)
|
||||
|
||||
Below are code examples that leverage Dapr SDKs to interact with an output binding.
|
||||
The code examples below leverage Dapr SDKs to invoke the output bindings endpoint on a running Dapr instance.
|
||||
|
||||
{{< tabs Dotnet Java Python Go JavaScript>}}
|
||||
|
||||
|
@ -277,22 +285,12 @@ function sleep(ms) {
|
|||
|
||||
{{< /tabs >}}
|
||||
|
||||
Invoke the output bindings endpoint on a running Dapr instance.
|
||||
|
||||
You can also invoke the output bindings endpoint using HTTP:
|
||||
|
||||
```bash
|
||||
curl -X POST -H 'Content-Type: application/json' http://localhost:3601/v1.0/bindings/checkout -d '{ "data": 100, "operation": "create" }'
|
||||
```
|
||||
|
||||
As seen above:
|
||||
|
||||
1. The example invoked the `/binding` endpoint with `checkout`, the name of the binding to invoke.
|
||||
1. The payload goes inside the mandatory `data` field, and can be any JSON serializable value.
|
||||
1. The `operation` field tells the binding what action it needs to take. For example, [the Kafka binding supports the `create` operation]({{< ref "kafka.md#binding-support" >}}).
|
||||
|
||||
You can check [which operations (specific to each component) are supported for every output binding]({{< ref supported-bindings >}}).
|
||||
|
||||
Watch this [video](https://www.youtube.com/watch?v=ysklxm81MTs&feature=youtu.be&t=1960) on how to use bi-directional output bindings.
|
||||
|
||||
<div class="embed-responsive embed-responsive-16by9">
|
||||
|
|
|
@ -6,29 +6,36 @@ description: "Use Dapr input bindings to trigger event driven applications"
|
|||
weight: 200
|
||||
---
|
||||
|
||||
Using bindings, your code can be triggered with incoming events from different resources which can be anything: a queue, messaging pipeline, cloud-service, filesystem etc.
|
||||
With input bindings, you can trigger your application when an event from an external resource occurs. An external resource could be a queue, messaging pipeline, cloud-service, filesystem, etc. An optional payload and metadata may be sent with the request.
|
||||
|
||||
This is ideal for event-driven processing, data pipelines, or generally reacting to events and performing further processing.
|
||||
Input bindings are ideal for event-driven processing, data pipelines, or generally reacting to events and performing further processing. Dapr input bindings allow you to:
|
||||
|
||||
Dapr bindings allow you to:
|
||||
- Receive events without including specific SDKs or libraries
|
||||
- Replace bindings without changing your code
|
||||
- Focus on business logic and not the event resource implementation
|
||||
|
||||
* Receive events without including specific SDKs or libraries
|
||||
* Replace bindings without changing your code
|
||||
* Focus on business logic and not the event resource implementation
|
||||
<img src="/images/howto-triggers/kafka-input-binding.png" width=1000 alt="Diagram showing bindings of example service">
|
||||
|
||||
An input binding represents a resource that Dapr uses to read events from and push to your application. Read the [bindings overview for more information]({{<ref bindings-overview.md>}}).
|
||||
This guide uses a Kafka binding as an example. You can find your preferred binding spec from [the list of bindings components]({{< ref setup-bindings >}}). In this guide:
|
||||
|
||||
<img src="/images/building-block-input-binding-example.png" width=1000 alt="Diagram showing bindings of example service">
|
||||
1. The example invokes the `/binding` endpoint with `checkout`, the name of the binding to invoke.
|
||||
1. The payload goes inside the mandatory `data` field, and can be any JSON serializable value.
|
||||
1. The `operation` field tells the binding what action it needs to take. For example, [the Kafka binding supports the `create` operation]({{< ref "kafka.md#binding-support" >}}).
|
||||
- You can check [which operations (specific to each component) are supported for every output binding]({{< ref supported-bindings >}}).
|
||||
|
||||
This guide uses a Kafka binding as an example. You can find your preferred binding spec from [the list of bindings components]({{< ref setup-bindings >}}).
|
||||
{{% alert title="Note" color="primary" %}}
|
||||
If you haven't already, [try out the bindings quickstart]({{< ref bindings-quickstart.md >}}) for a quick walk-through on how to use the bindings API.
|
||||
|
||||
{{% /alert %}}
|
||||
|
||||
## Create a binding
|
||||
|
||||
Create a new binding component with the name of `checkout`.
|
||||
Create a `binding.yaml` file and save to a `components` sub-folder in your application directory.
|
||||
|
||||
Inside the `metadata` section, configure Kafka-related properties, such as the topic to publish the message to and the broker.
|
||||
Create a new binding component named `checkout`. Within the `metadata` section, configure the following Kafka-related properties:
|
||||
|
||||
Create the following `binding.yaml` file and save it to a `components` sub-folder in your application directory.
|
||||
- The topic to which you'll publish the message
|
||||
- The broker
|
||||
|
||||
{{< tabs "Self-Hosted (CLI)" Kubernetes >}}
|
||||
|
||||
|
@ -96,7 +103,9 @@ spec:
|
|||
|
||||
## Listen for incoming events (input binding)
|
||||
|
||||
Configure your application to receive incoming events. If using HTTP, you need to listen on a `POST` endpoint with the name of the binding, as specified in `metadata.name` in the `binding.yaml` file. Additionally make sure that your application allows dapr to make an `OPTIONS` request for this endpoint.
|
||||
Configure your application to receive incoming events. If you're using HTTP, you need to:
|
||||
- Listen on a `POST` endpoint with the name of the binding, as specified in `metadata.name` in the `binding.yaml` file.
|
||||
- Verify your application allows Dapr to make an `OPTIONS` request for this endpoint.
|
||||
|
||||
Below are code examples that leverage Dapr SDKs to demonstrate an output binding.
|
||||
|
||||
|
@ -249,8 +258,7 @@ Tell Dapr the event was not processed correctly in your application and schedule
|
|||
|
||||
### Specifying a custom route
|
||||
|
||||
By default, incoming events will be sent to an HTTP endpoint that corresponds to the name of the input binding.
|
||||
You can override this by setting the following metadata property in `binding.yaml`:
|
||||
By default, incoming events will be sent to an HTTP endpoint that corresponds to the name of the input binding. You can override this by setting the following metadata property in `binding.yaml`:
|
||||
|
||||
```yaml
|
||||
name: mybinding
|
||||
|
@ -267,7 +275,7 @@ Event delivery guarantees are controlled by the binding implementation. Dependin
|
|||
|
||||
## References
|
||||
|
||||
* [Bindings building block]({{< ref bindings >}})
|
||||
* [Bindings API]({{< ref bindings_api.md >}})
|
||||
* [Components concept]({{< ref components-concept.md >}})
|
||||
* [Supported bindings]({{< ref supported-bindings >}})
|
||||
- [Bindings building block]({{< ref bindings >}})
|
||||
- [Bindings API]({{< ref bindings_api.md >}})
|
||||
- [Components concept]({{< ref components-concept.md >}})
|
||||
- [Supported bindings]({{< ref supported-bindings >}})
|
Binary file not shown.
Before Width: | Height: | Size: 86 KiB |
Binary file not shown.
Before Width: | Height: | Size: 93 KiB |
Binary file not shown.
After Width: | Height: | Size: 25 KiB |
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Loading…
Reference in New Issue