-
Notifications
You must be signed in to change notification settings - Fork 777
Extend service invocation to non-Dapr endpoints docs #3384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
msfussell
merged 15 commits into
dapr:v1.11
from
sicoyle:docs-nondaprized-svc-invocation
May 18, 2023
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
d48d41d
docs(httpendpoint): add docs for service invocation to non-daprized e…
sicoyle f0a92bd
Merge branch 'v1.11' into docs-nondaprized-svc-invocation
hhunter-ms b427966
Merge branch 'v1.11' into docs-nondaprized-svc-invocation
msfussell af78e7f
style: non-daprized -> non-dapr
sicoyle cacbc04
Merge branch 'docs-nondaprized-svc-invocation' of github.com:sicoyle/…
sicoyle dcfda7d
docs: address some feedback
sicoyle 514f57f
docs: update according to rest of feedback
sicoyle bb6a0a2
Update howto-invoke-non-dapr-endpoints.md
msfussell ece1b85
docs: update last pr feedback
sicoyle 45fe56e
style: address grammar feedback
sicoyle 97da568
Merge branch 'v1.11' into docs-nondaprized-svc-invocation
msfussell 219fe5d
Merge branch 'v1.11' into docs-nondaprized-svc-invocation
hhunter-ms 62c7e44
Merge branch 'v1.11' into docs-nondaprized-svc-invocation
hhunter-ms 1524292
Update _index.md
msfussell c29eb08
Update howto-invoke-non-dapr-endpoints.md
msfussell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
...lications/building-blocks/service-invocation/howto-invoke-non-dapr-endpoints.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
--- | ||
type: docs | ||
title: "How-To: Invoke Non-Dapr Endpoints using HTTP" | ||
linkTitle: "How-To: Invoke Non-Dapr Endpoints" | ||
description: "Call Non-Dapr endpoints from Dapr applications using service invocation" | ||
weight: 2000 | ||
--- | ||
|
||
This article demonstrates how to call a non-Dapr endpoint using Dapr over HTTP. | ||
|
||
Using Dapr's service invocation API, you can communicate with endpoints that either use or do not use Dapr. Using Dapr to call endpoints that do not use Dapr not only provides a consistent API, but also the following [Dapr service invocation]({{< ref service-invocation-overview.md >}}) benefits: | ||
|
||
- Ability to apply resiliency policies | ||
- Call observability with tracing & metrics | ||
- Security access control through scoping | ||
- Ability to utilize middleware pipeline components | ||
- Service discovery | ||
- Authentication through the use of headers | ||
|
||
## HTTP service invocation to external services or non-Dapr endpoints | ||
Sometimes you need to call a non-Dapr HTTP endpoint. For example: | ||
- You may choose to only use Dapr in part of your overall application, including brownfield development | ||
- You may not have access to the code to migrate an existing application to use Dapr | ||
- You need to call an external HTTP service. | ||
|
||
By defining an `HTTPEndpoint` resource, you declaratively define a way to interact with a non-Dapr endpoint. You then use the service invocation URL to invoke non-Dapr endpoints. Alternatively, you can place a non-Dapr Fully Qualified Domain Name (FQDN) endpoint URL directly into the service invocation URL. | ||
|
||
### Order of precedence between HttpEndpoint, FQDN URL, and appId | ||
When using service invocation, the Dapr runtime follows a precedence order: | ||
|
||
1. Is this a named `HTTPEndpoint` resource? | ||
2. Is this an FQDN URL with an`http://` or `https://` prefix? | ||
3. Is this an `appID`? | ||
|
||
## Service invocation and non-Dapr HTTP endpoint | ||
The diagram below is an overview of how Dapr's service invocation works when invoking non-Dapr endpoints. | ||
|
||
<img src="/images/service-invocation-overview-non-dapr-endpoint.png" width=800 alt="Diagram showing the steps of service invocation to non-Dapr endpoints"> | ||
|
||
1. Service A makes an HTTP call targeting Service B, a non-Dapr endpoint. The call goes to the local Dapr sidecar. | ||
2. Dapr discovers Service B's location using the `HTTPEndpoint` or FQDN URL. | ||
3. Dapr forwards the message to Service B. | ||
4. Service B runs its business logic code. | ||
5. Service B sends a response to Service A's Dapr sidecar. | ||
6. Service A receives the response. | ||
|
||
## Using an HTTPEndpoint resource or FQDN URL for non-Dapr endpoints | ||
There are two ways to invoke a non-Dapr endpoint when communicating either to Dapr applications or non-Dapr applications. A Dapr application can invoke a non-Dapr endpoint by providing one of the following: | ||
|
||
- A named `HTTPEndpoint` resource, including defining an `HTTPEndpoint` resource type. See the [HTTPEndpoint reference]({{< ref httpendpoints-reference.md >}}) guide for an example. | ||
|
||
```sh | ||
localhost:3500/v1.0/invoke/<HTTPEndpoint-name>/method/<my-method> | ||
``` | ||
|
||
For example, with an `HTTPEndpoint` resource called "palpatine" and a method called "Order66", this would be: | ||
```sh | ||
curl http://localhost:3500/v1.0/invoke/palpatine/method/order66 | ||
``` | ||
|
||
- A FQDN URL to the non-Dapr endpoint. | ||
|
||
```sh | ||
localhost:3500/v1.0/invoke/<URL>/method/<my-method> | ||
``` | ||
|
||
For example, with an FQDN resource called `https://darthsidious.starwars`, this would be: | ||
```sh | ||
curl http://localhost:3500/v1.0/invoke/https://darthsidious.starwars/method/order66 | ||
``` | ||
|
||
### Using appId when calling Dapr enabled applications | ||
AppIDs are always used to call Dapr applications with the `appID` and `my-method. Read the [How-To: Invoke services using HTTP]({{< ref howto-invoke-discover-services.md >}}) guide for more information. For example: | ||
|
||
```sh | ||
localhost:3500/v1.0/invoke/<appID>/method/<my-method> | ||
``` | ||
```sh | ||
curl http://localhost:3602/v1.0/invoke/orderprocessor/method/checkout | ||
``` | ||
|
||
## Related Links | ||
|
||
- [HTTPEndpoint reference]({{< ref httpendpoints-reference.md >}}) | ||
- [Service invocation overview]({{< ref service-invocation-overview.md >}}) | ||
- [Service invocation API specification]({{< ref service_invocation_api.md >}}) | ||
|
||
## Community call demo | ||
Watch this [video](https://youtu.be/BEXJgLsO4hA?t=364) on how to use service invocation to call non-Dapr endpoints. | ||
<div class="embed-responsive embed-responsive-16by9"> | ||
<iframe width="560" height="315" src="https://www.youtube-nocookie.com/embed/BEXJgLsO4hA?t=364" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> | ||
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
type: docs | ||
title: "Dapr resource specs" | ||
linkTitle: "Resource specs" | ||
description: "Detailed information and specifications on Dapr resources" | ||
weight: 500 | ||
--- |
41 changes: 41 additions & 0 deletions
41
daprdocs/content/en/reference/resource-specs/httpendpoints-reference.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
type: docs | ||
title: "HTTPEndpoint spec" | ||
linkTitle: "HTTPEndpoint spec" | ||
description: "The HTTPEndpoint resource spec" | ||
weight: 300 | ||
aliases: | ||
- "/operations/httpEndpoints/" | ||
--- | ||
|
||
The `HTTPEndpoint` is a Dapr resource that is used to enable the invocation of non-Dapr endpoints from a Dapr application. | ||
|
||
## HTTPEndpoint format | ||
|
||
```yaml | ||
apiVersion: dapr.io/v1alpha1 | ||
kind: HTTPEndpoint | ||
metadata: | ||
name: <NAME> | ||
spec: | ||
version: v1alpha1 | ||
baseUrl: <REPLACE-WITH-BASEURL> # Required. Use "http://" or "https://" prefix. | ||
sicoyle marked this conversation as resolved.
Show resolved
Hide resolved
|
||
headers: # Optional | ||
- name: <REPLACE-WITH-A-HEADER-NAME> | ||
value: <REPLACE-WITH-A-HEADER-VALUE> | ||
- name: <REPLACE-WITH-A-HEADER-NAME> | ||
secretKeyRef: | ||
name: <REPLACE-WITH-SECRET-NAME> | ||
key: <REPLACE-WITH-SECRET-KEY> | ||
scopes: # Optional | ||
- <REPLACE-WITH-SCOPED-APPIDS> | ||
auth: # Optional | ||
secretStore: <REPLACE-WITH-SECRETSTORE> | ||
``` | ||
|
||
## Spec fields | ||
|
||
| Field | Required | Details | Example | | ||
|--------------------|:--------:|---------|---------| | ||
| baseUrl | Y | Base URL of the non-Dapr endpoint | `"https://api.github.com"`, `"http://api.github.com"` | ||
| headers | N | HTTP request headers for service invocation | `name: "Accept-Language" value: "en-US"` <br/> `name: "Authorization" secretKeyRef.name: "my-secret" secretKeyRef.key: "myGithubToken" ` |
Binary file added
BIN
+108 KB
daprdocs/static/images/service-invocation-overview-non-dapr-endpoint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.