Skip to content

Commit

Permalink
feat: advanced usage
Browse files Browse the repository at this point in the history
  • Loading branch information
brenoepics committed Jun 26, 2024
1 parent 3f58ef4 commit cd9b3e2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions docs/src/advanced/threading.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Creating an AzureApi with a Custom ExecutorService

This guide will walk you through the process of creating an `AzureApiBuilder` with a custom `ExecutorService`.

## Steps

1. **Create a custom ExecutorService**

For this example, we'll create a custom `ExecutorService` using the Virtual Threads API introduced in Java 21:

```java
ExecutorService customExecutorService = Executors.newVirtualThreadPerTaskExecutor();
```

2. **Create an AzureApiBuilder**

You can create an `AzureApi` by using the `AzureApiBuilder` class. Here's an example:
```java
String azureKey = "<Your Azure Subscription Key>";
String azureRegion = "<Your Azure Subscription Region>";
AzureApi azureApi = new AzureApiBuilder()
.setKey(azureKey)
.region(azureRegion)
.executorService(customExecutorService).build();
```
This will create an `AzureApi` with the settings you specified in the `AzureApiBuilder`.
That's it! You've successfully created an `AzureApi` with a custom `ExecutorService`. You can now use this `AzureApi` to
make requests to the Azure API.

0 comments on commit cd9b3e2

Please sign in to comment.