-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3f58ef4
commit cd9b3e2
Showing
1 changed file
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,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. |