-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure redis client beans from config if a programmatic injection …
…point exists.
- Loading branch information
1 parent
13f3dce
commit e9ec185
Showing
9 changed files
with
111 additions
and
3 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
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
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
57 changes: 57 additions & 0 deletions
57
...ts/redis-client/src/main/java/io/quarkus/redis/it/RedisWithInstanceInjectionResource.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,57 @@ | ||
package io.quarkus.redis.it; | ||
|
||
import javax.enterprise.context.ApplicationScoped; | ||
import javax.enterprise.inject.Any; | ||
import javax.enterprise.inject.Instance; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.POST; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.PathParam; | ||
|
||
import io.quarkus.redis.client.RedisClientName; | ||
import io.quarkus.redis.datasource.ReactiveRedisDataSource; | ||
import io.quarkus.redis.datasource.RedisDataSource; | ||
import io.quarkus.redis.datasource.value.ReactiveValueCommands; | ||
import io.quarkus.redis.datasource.value.ValueCommands; | ||
import io.smallrye.mutiny.Uni; | ||
|
||
@Path("/quarkus-redis-with-instance") | ||
@ApplicationScoped | ||
public class RedisWithInstanceInjectionResource { | ||
|
||
private final ValueCommands<String, String> blocking; | ||
private final ReactiveValueCommands<String, String> reactive; | ||
|
||
public RedisWithInstanceInjectionResource(@Any Instance<RedisDataSource> ds, | ||
@Any Instance<ReactiveRedisDataSource> reactiveDs) { | ||
blocking = ds.select(RedisClientName.Literal.of("instance-client")).get().value(String.class); | ||
reactive = reactiveDs.select(RedisClientName.Literal.of("instance-client")).get().value(String.class); | ||
} | ||
|
||
// synchronous | ||
@GET | ||
@Path("/sync/{key}") | ||
public String getSync(@PathParam("key") String key) { | ||
return blocking.get(key); | ||
} | ||
|
||
@POST | ||
@Path("/sync/{key}") | ||
public void setSync(@PathParam("key") String key, String value) { | ||
blocking.set(key, value); | ||
} | ||
|
||
// reactive | ||
@GET | ||
@Path("/reactive/{key}") | ||
public Uni<String> getReactive(@PathParam("key") String key) { | ||
return reactive.get(key); | ||
} | ||
|
||
@POST | ||
@Path("/reactive/{key}") | ||
public Uni<Void> setReactive(@PathParam("key") String key, String value) { | ||
return this.reactive.set(key, value); | ||
} | ||
|
||
} |
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