-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable ReactiveRedisTemplate
for multi-tenancy usage
#2145
Comments
ReactiveRedisTemplate
for multi-tenancy usage
|
Thanks a lot. When do you plan to tackle this? |
Having a pull request would improve things in terms of timing so we could integrate it faster. |
I knew you gonna say that 😄 |
I assume you mean in having this in |
Yes, exactly. A |
Something like
|
|
Then how I will be able to pass the context to |
Since the method returns a |
You mean private <T> Publisher<T> doInConnection(ReactiveRedisCallback<T> action, boolean exposeConnection) {
Assert.notNull(action, "Callback object must not be null");
return Flux.usingWhen(getConnection(exposeConnection), conn -> {
Publisher<T> result = action.doInRedis(conn);
return postProcessResult(result, conn, false);
}, ReactiveRedisConnection::closeLater);
}
protected Mono<ReactiveRedisConnection> getConnection(boolean exposeConnection) {
ReactiveRedisConnectionFactory factory = getConnectionFactory();
ReactiveRedisConnection conn = factory.getReactiveConnection();
ReactiveRedisConnection connToUse = preProcessConnection(conn, false);
return Mono.just(exposeConnection ? connToUse : createRedisConnectionProxy(connToUse));
} Then in my overriding class protected Mono<ReactiveRedisConnection> getConnection(boolean exposeConnection) {
return Mono.deferContextual(contextView -> {
// Something that returns Mono<ReactiveRedisConnection> based on the value in the context
}
) |
Yes, exactly. |
@mp911de Please review my PR and let me know if I have to do some changes |
Thanks, we're going to take this PR from here. |
Hi,
I would like to use
ReactiveRedisTemplate
in multitenant environment. In short, the option to use singleReactiveRedisTemplate
which can connect to multiple Redis instances based on tenant values passed in reactive context.Unfortunately, I can not connect the reactive context with the connection factory so I can create different connections (or using different connection pool) based on tenant value in the context.
One option is to override doInConnection, but it has private modifier. Changing it will allow me to provide custom logic about connection creation.
The text was updated successfully, but these errors were encountered: