Skip to content
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

Add Placement API topic #3745

Merged
merged 19 commits into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion daprdocs/content/en/reference/api/error_codes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ type: docs
title: "Error codes returned by APIs"
linkTitle: "Error codes"
description: "Detailed reference of the Dapr API error codes"
weight: 1200
weight: 1300
---

For http calls made to Dapr runtime, when an error is encountered, an error json is returned in http response body. The json contains an error code and an descriptive error message, e.g.
Expand Down
64 changes: 64 additions & 0 deletions daprdocs/content/en/reference/api/placement_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
type: docs
title: "Placement API reference"
linkTitle: "Placement API"
description: "Detailed documentation on the Placement API"
weight: 1200
---

Dapr has an HTTP API `/placement/state` for placement service that exposes placement table information. The API is exposed on the sidecar on the same port as the healthz. This is an unauthenticated endpoint, and is disabled by default.

You need to set `DAPR_PLACEMENT_METADATA_ENABLED` environment or `metadata-enabled` command line args to true to enable it. If you are using helm, set `dapr_placement.metadataEnabled` to true.
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved

## Usecase

The placement table API can be used for retrieving the current placement table, which contains all the actors registered. This can be helpful for debugging and allows tools to extract and present information about actors.

## HTTP Request

```
GET http://localhost:<healthzPort>/placement/state
```

## HTTP Response Codes

Code | Description
---- | -----------
200 | Placement tables information returned
500 | Placement could not return the placement tables information

## HTTP Response Body

**Placement tables API Response Object**

Name | Type | Description
---- | ---- | -----------
tableVersion | int | The placement table version
hostList | [Actor Host Info](#actorhostinfo)[] | A json array of registered actors host info.

<a id="actorhostinfo"></a>**Actor Host Info**

Name | Type | Description
---- | ---- | -----------
name | string | The host:port address of the actor.
appId | string | app id.
actorTypes | json string array | List of actor types it hosts.
updatedAt | timestamp | Timestamp of the actor registered/updated.

## Examples

```shell
curl localhost:8080/placement/state
```

```json
{
"hostList": [{
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
"name": "198.18.0.1:49347",
"appId": "actor",
"actorTypes": ["testActorType"],
"updatedAt": 1690274322325260000
}],
"tableVersion": 1
}
```
3 changes: 2 additions & 1 deletion daprdocs/content/en/reference/environment/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ The following table lists the environment variables used by the Dapr runtime, CL
| OTEL_EXPORTER_OTLP_INSECURE | OpenTelemetry Tracing | Sets the connection to the endpoint as unencrypted. (`true`, `false`) |
| OTEL_EXPORTER_OTLP_PROTOCOL | OpenTelemetry Tracing | The OTLP protocol to use Transport protocol. (`grpc`, `http/protobuf`, `http/json`) |
| DAPR_COMPONENTS_SOCKETS_FOLDER | Dapr runtime and the .NET, Go, and Java pluggable component SDKs | The location or path where Dapr looks for Pluggable Components Unix Domain Socket files. If unset this location defaults to `/tmp/dapr-components-sockets` |
| DAPR_COMPONENTS_SOCKETS_EXTENSION | .NET and Java pluggable component SDKs | A per-SDK configuration that indicates the default file extension applied to socket files created by the SDKs. Not a Dapr-enforced behavior. |
| DAPR_COMPONENTS_SOCKETS_EXTENSION | .NET and Java pluggable component SDKs | A per-SDK configuration that indicates the default file extension applied to socket files created by the SDKs. Not a Dapr-enforced behavior. |
hhunter-ms marked this conversation as resolved.
Show resolved Hide resolved
| DAPR_PLACEMENT_METADATA_ENABLED | Dapr placement | A placement service that exposes placement table information. Set to `true` to enable. [Learn more about the Placement API]({{< ref placement_api.md >}}) |
Loading