Skip to content

Commit

Permalink
[ACS JobRouter] Max concurrent offers on workers (#38664)
Browse files Browse the repository at this point in the history
* remove unwanted changes

* fix lint error
  • Loading branch information
sarkar-rajarshi committed Mar 5, 2024
1 parent a73995e commit 370d14d
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 9 deletions.
3 changes: 3 additions & 0 deletions sdk/communication/azure-communication-jobrouter/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

### Features Added

#### RouterWorker && CreateWorkerOptions
- Added `MaxConcurrentOffers`

### Breaking Changes

### Bugs Fixed
Expand Down
2 changes: 1 addition & 1 deletion sdk/communication/azure-communication-jobrouter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ add the direct dependency to your project as follows.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-jobrouter</artifactId>
<version>1.0.0</version>
<version>1.1.1</version>
</dependency>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/communication/azure-communication-jobrouter",
"Tag": "java/communication/azure-communication-jobrouter_5a7c315465"
"Tag": "java/communication/azure-communication-jobrouter_1c81042504"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,7 @@ public Mono<Response<BinaryData>> getQueueStatisticsWithResponse(String queueId,
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
* <p>
Expand Down Expand Up @@ -1197,6 +1198,7 @@ public Mono<Response<BinaryData>> getQueueStatisticsWithResponse(String queueId,
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -1568,6 +1570,7 @@ public Mono<RouterWorker> createWorker(CreateWorkerOptions createWorkerOptions)
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -1693,6 +1696,7 @@ public Mono<Response<Void>> deleteWorkerWithResponse(String workerId, RequestOpt
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ public Response<BinaryData> getQueueStatisticsWithResponse(String queueId, Reque
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
* <p>
Expand Down Expand Up @@ -1203,6 +1204,7 @@ public Response<BinaryData> getQueueStatisticsWithResponse(String queueId, Reque
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -1577,6 +1579,7 @@ public RouterWorker createWorker(CreateWorkerOptions createWorkerOptions) {
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -1702,6 +1705,7 @@ public Response<Void> deleteWorkerWithResponse(String workerId, RequestOptions r
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ public enum JobRouterServiceVersion implements ServiceVersion {
/**
* Enum value 2023-11-01.
*/
V2023_11_01("2023-11-01");
V2023_11_01("2023-11-01"),

/**
* Enum value 2024-01-18-preview.
*/
V2024_01_18_PREVIEW("2024-01-18-preview");

private final String version;

Expand All @@ -35,6 +40,6 @@ public String getVersion() {
* @return The latest {@link JobRouterServiceVersion}.
*/
public static JobRouterServiceVersion getLatest() {
return V2023_11_01;
return V2024_01_18_PREVIEW;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2373,6 +2373,7 @@ public Response<BinaryData> getQueueStatisticsWithResponse(String queueId, Reque
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
* <p>
Expand Down Expand Up @@ -2419,6 +2420,7 @@ public Response<BinaryData> getQueueStatisticsWithResponse(String queueId, Reque
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -2511,6 +2513,7 @@ public Mono<Response<BinaryData>> upsertWorkerWithResponseAsync(String workerId,
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
* <p>
Expand Down Expand Up @@ -2557,6 +2560,7 @@ public Mono<Response<BinaryData>> upsertWorkerWithResponseAsync(String workerId,
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -2624,6 +2628,7 @@ public Response<BinaryData> upsertWorkerWithResponse(String workerId, BinaryData
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -2688,6 +2693,7 @@ public Mono<Response<BinaryData>> getWorkerWithResponseAsync(String workerId, Re
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -2833,6 +2839,7 @@ public Response<Void> deleteWorkerWithResponse(String workerId, RequestOptions r
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -2945,6 +2952,7 @@ private Mono<PagedResponse<BinaryData>> listWorkersSinglePageAsync(RequestOption
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -3075,6 +3083,7 @@ public PagedFlux<BinaryData> listWorkersAsync(RequestOptions requestOptions) {
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -3185,6 +3194,7 @@ private PagedResponse<BinaryData> listWorkersSinglePage(RequestOptions requestOp
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -3432,6 +3442,7 @@ private PagedResponse<BinaryData> listJobsNextSinglePage(String nextLink, Reques
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down Expand Up @@ -3505,6 +3516,7 @@ private Mono<PagedResponse<BinaryData>> listWorkersNextSinglePageAsync(String ne
* ]
* loadRatio: Double (Optional)
* availableForOffers: Boolean (Optional)
* maxConcurrentOffers: Integer (Optional)
* }
* }</pre>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public static RouterWorkerInternal convertCreateWorkerOptionsToRouterWorker(Crea
.setTags(tags)
.setAvailableForOffers(createWorkerOptions.isAvailableForOffers())
.setChannels(createWorkerOptions.getChannels())
.setCapacity(createWorkerOptions.getCapacity());
.setCapacity(createWorkerOptions.getCapacity())
.setMaxConcurrentOffers(createWorkerOptions.getMaxConcurrentOffers());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -311,4 +311,35 @@ public RouterWorkerInternal setAvailableForOffers(Boolean availableForOffers) {
this.availableForOffers = availableForOffers;
return this;
}

/*
* If this is set, the worker will only receive up to this many new offers at a time.
*/
@Generated
@JsonProperty(value = "maxConcurrentOffers")
private Integer maxConcurrentOffers;

/**
* Get the maxConcurrentOffers property: If this is set, the worker will only receive up to this many new offers at
* a time.
*
* @return the maxConcurrentOffers value.
*/
@Generated
public Integer getMaxConcurrentOffers() {
return this.maxConcurrentOffers;
}

/**
* Set the maxConcurrentOffers property: If this is set, the worker will only receive up to this many new offers at
* a time.
*
* @param maxConcurrentOffers the maxConcurrentOffers value to set.
* @return the RouterWorkerInternal object itself.
*/
@Generated
public RouterWorkerInternal setMaxConcurrentOffers(Integer maxConcurrentOffers) {
this.maxConcurrentOffers = maxConcurrentOffers;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public final class CreateWorkerOptions {
*/
private Boolean availableForOffers;

/*
* If this is set, the worker will only receive up to this many new offers at a time.
*/
private Integer maxConcurrentOffers;

/**
* Constructor for CreateWorkerOptions.
* @param workerId The id property.
Expand Down Expand Up @@ -116,6 +121,18 @@ public CreateWorkerOptions setAvailableForOffers(Boolean availableForOffers) {
return this;
}

/**
* Set the maxConcurrentOffers property: If this is set, the worker will only receive up to this many new offers at
* a time.
*
* @param maxConcurrentOffers the maxConcurrentOffers value to set.
* @return this
*/
public CreateWorkerOptions setMaxConcurrentOffers(Integer maxConcurrentOffers) {
this.maxConcurrentOffers = maxConcurrentOffers;
return this;
}

/**
* Returns id.
* @return id
Expand Down Expand Up @@ -171,4 +188,14 @@ public List<RouterChannel> getChannels() {
public Boolean isAvailableForOffers() {
return this.availableForOffers;
}

/**
* Get the maxConcurrentOffers property: If this is set, the worker will only receive up to this many new offers at
* a time.
*
* @return the maxConcurrentOffers value.
*/
public Integer getMaxConcurrentOffers() {
return this.maxConcurrentOffers;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public RouterWorker() {}
setAvailableForOffers(internal.isAvailableForOffers());
setChannels(internal.getChannels());
setCapacity(internal.getCapacity());
setMaxConcurrentOffers(internal.getMaxConcurrentOffers());
}

static {
Expand Down Expand Up @@ -248,6 +249,12 @@ public RouterWorker setAvailableForOffers(Boolean availableForOffers) {
@JsonProperty(value = "channels")
private List<RouterChannel> channels;

/*
* If this is set, the worker will only receive up to this many new offers at a time.
*/
@JsonProperty(value = "maxConcurrentOffers")
private Integer maxConcurrentOffers;

/**
* Get the etag property: Concurrency Token.
*
Expand Down Expand Up @@ -323,4 +330,26 @@ public RouterWorker setChannels(List<RouterChannel> channels) {
this.channels = channels;
return this;
}

/**
* Get the maxConcurrentOffers property: If this is set, the worker will only receive up to this many new offers at
* a time.
*
* @return the maxConcurrentOffers value.
*/
public Integer getMaxConcurrentOffers() {
return this.maxConcurrentOffers;
}

/**
* Set the maxConcurrentOffers property: If this is set, the worker will only receive up to this many new offers at
* a time.
*
* @param maxConcurrentOffers the maxConcurrentOffers value to set.
* @return the RouterWorkerInternal object itself.
*/
public RouterWorker setMaxConcurrentOffers(Integer maxConcurrentOffers) {
this.maxConcurrentOffers = maxConcurrentOffers;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class JobRouterTestBase extends TestProxyTestBase {
protected String getConnectionString() {
String connectionString = interceptorManager.isPlaybackMode()
? "endpoint=https://REDACTED.int.communication.azure.net;accessKey=secret"
: Configuration.getGlobalConfiguration().get("AZURE_TEST_JOBROUTER_CONNECTION_STRING");
: Configuration.getGlobalConfiguration().get("COMMUNICATION_LIVETEST_DYNAMIC_CONNECTION_STRING");
Objects.requireNonNull(connectionString);
return connectionString;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,15 @@ public void createWorker(HttpClient httpClient) {
.setTags(tags)
.setAvailableForOffers(false)
.setChannels(channels)
.setQueues(queues);
.setQueues(queues)
.setMaxConcurrentOffers(1);

// Action
RouterWorker result = routerAsyncClient.createWorker(createWorkerOptions).block();

// Verify
assertEquals(workerId, result.getId());
assertEquals(1, result.getMaxConcurrentOffers());

// Cleanup
routerAsyncClient.deleteWorker(workerId).block();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,15 @@ public void createWorker(HttpClient httpClient) {
.setTags(tags)
.setAvailableForOffers(false)
.setChannels(channels)
.setQueues(queues);
.setQueues(queues)
.setMaxConcurrentOffers(1);

// Action
RouterWorker result = jobRouterClient.createWorker(createWorkerOptions);

// Verify
assertEquals(workerId, result.getId());
assertEquals(1, result.getMaxConcurrentOffers());

// Cleanup
jobRouterClient.deleteWorker(workerId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
commit: 12de39b01089f0de0a46d93081d3361712ff1164
commit: 1c04f51cbfa195fe177239cf63d00d3539006800
directory: specification/communication/Communication.JobRouter
additionalDirectories: []
repo: Azure/azure-rest-api-specs

0 comments on commit 370d14d

Please sign in to comment.