-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding safety to Amqp Session operations, SessionCache to cache React…
…orSession instances and integrating RequestResponseChannelCache
- Loading branch information
Showing
35 changed files
with
2,106 additions
and
270 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
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
62 changes: 62 additions & 0 deletions
62
...azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ChannelCacheWrapper.java
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,62 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.core.amqp.implementation; | ||
|
||
import reactor.core.publisher.Mono; | ||
|
||
import java.util.Objects; | ||
|
||
/** | ||
* A temporary type to side by side support {@link RequestResponseChannel} caching that | ||
* <ul> | ||
* <li>uses {@link AmqpChannelProcessor} in v2 mode without "com.azure.core.amqp.internal.session-channel-cache.v2" | ||
* opt-in or in v1 mode,</li> | ||
* <li>or uses {@link RequestResponseChannelCache} when "com.azure.core.amqp.internal.session-channel-cache.v2" | ||
* is explicitly opted-in in v2 mode.</li> | ||
* </ul> | ||
* <p> | ||
* TODO (anu): remove this temporary type when removing v1 and 'RequestResponseChannelCache' is no longer opt-in for v2. | ||
* </p> | ||
*/ | ||
final class ChannelCacheWrapper { | ||
private final AmqpChannelProcessor<RequestResponseChannel> channelProcessor; | ||
private final RequestResponseChannelCache channelCache; | ||
|
||
/** | ||
* Creates channel cache for V1 client or V2 client without "com.azure.core.amqp.internal.session-channel-cache.v2" | ||
* opted-in. | ||
* | ||
* @param channelProcessor the channel processor for caching {@link RequestResponseChannel}. | ||
*/ | ||
ChannelCacheWrapper(AmqpChannelProcessor<RequestResponseChannel> channelProcessor) { | ||
this.channelProcessor = Objects.requireNonNull(channelProcessor, "'channelProcessor' cannot be null."); | ||
this.channelCache = null; | ||
} | ||
|
||
/** | ||
* Creates channel cache for V1 client with "com.azure.core.amqp.internal.session-channel-cache.v2" opted-in. | ||
* | ||
* @param channelCache the cache for {@link RequestResponseChannel}. | ||
*/ | ||
ChannelCacheWrapper(RequestResponseChannelCache channelCache) { | ||
this.channelCache = Objects.requireNonNull(channelCache, "'channelCache' cannot be null."); | ||
this.channelProcessor = null; | ||
} | ||
|
||
Mono<RequestResponseChannel> get() { | ||
if (channelCache != null) { | ||
return channelCache.get(); | ||
} else { | ||
return channelProcessor; | ||
} | ||
} | ||
|
||
Mono<Void> closeAsync() { | ||
if (channelCache != null) { | ||
return channelCache.closeAsync(); | ||
} else { | ||
return channelProcessor.flatMap(RequestResponseChannel::closeAsync); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.