Adds docs for client initialisation with env variables (#992)

* Adds docs for client init with env variables

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Fix

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Adds DAPR_HTTP_ENDPOINT

Signed-off-by: Elena Kolevska <elena@kolevska.com>

* Update daprdocs/content/en/java-sdk-docs/java-client/_index.md

Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com>
Signed-off-by: Elena Kolevska <elena-kolevska@users.noreply.github.com>

---------

Signed-off-by: Elena Kolevska <elena@kolevska.com>
Signed-off-by: Elena Kolevska <elena-kolevska@users.noreply.github.com>
Co-authored-by: Cassie Coyle <cassie.i.coyle@gmail.com>
This commit is contained in:
Elena Kolevska 2024-01-24 16:02:36 +00:00 committed by GitHub
parent 7eb24ffc69
commit a9a09ba2ac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 0 deletions

View File

@ -17,6 +17,31 @@ If you haven't already, [try out one of the quickstarts]({{< ref quickstarts >}}
[Complete initial setup and import the Java SDK into your project]({{< ref java >}})
## Initializing the client
You can initialize a Dapr client as so:
```java
DaprClient client = new DaprClientBuilder().build()
```
This will connect to the default Dapr gRPC endpoint `localhost:50001`.
#### Environment variables:
##### Dapr Sidecar Endpoints
You can use the standardized `DAPR_GRPC_ENDPOINT` and `DAPR_HTTP_ENDPOINT` environment variables to
specify a different gRPC or HTTP endpoint. When these variables are set, the client will automatically use them to connect to the Dapr sidecar.
The legacy environment variables `DAPR_HTTP_PORT` and `DAPR_GRPC_PORT` are still supported, but `DAPR_GRPC_ENDPOINT` and `DAPR_HTTP_ENDPOINT` take precedence.
##### Dapr API Token
If your Dapr instance is configured to require the `DAPR_API_TOKEN` environment variable, you can
set it in the environment and the client will use it automatically.
You can read more about Dapr API token authentication [here](https://docs.dapr.io/operations/security/api-token/).
## Building blocks
The Java SDK allows you to interface with all of the [Dapr building blocks]({{< ref building-blocks >}}).