io.lettuce.core.api.reactive.RedisReactiveCommands Java Examples

The following examples show how to use io.lettuce.core.api.reactive.RedisReactiveCommands. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LettuceTest.java    From java-specialagent with Apache License 2.0 6 votes vote down vote up
@Test
public void testReactiveMono(MockTracer tracer) {
  try (final StatefulRedisConnection<String,String> connection = client.connect()) {
    final RedisReactiveCommands<String, String> commands = connection.reactive();
    commands.set("key", "value").subscribe(new Consumer<String>() {
      @Override
      public void accept(final String res) {
        assertEquals("OK", res);
      }
    });
    await().atMost(15, TimeUnit.SECONDS).until(TestUtil.reportedSpansSize(tracer), equalTo(2));
  }

  final List<MockSpan> spans = tracer.finishedSpans();
  assertEquals(2, spans.size());
}
 
Example #2
Source File: Lettuce5InstrumentationTest.java    From apm-agent-java with Apache License 2.0 5 votes vote down vote up
@Test
public void testReactiveLettuce() {
    RedisReactiveCommands<String, String> async = connection.reactive();
    try (Scope scope = tracer.startRootTransaction(getClass().getClassLoader()).withName("transaction").activateInScope()) {
        async.set("foo", "bar").block();
        assertThat(async.get("foo").block()).isEqualTo("bar");
    }
    assertTransactionWithRedisSpans("SET", "GET");
}
 
Example #3
Source File: LettuceTest.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
@Test
public void testReactiveFlux(MockTracer tracer) {
  try (final StatefulRedisConnection<String,String> connection = client.connect()) {
    final RedisReactiveCommands<String, String> commands = connection.reactive();
    commands.command().subscribe();
    await().atMost(15, TimeUnit.SECONDS).until(TestUtil.reportedSpansSize(tracer), equalTo(2));
  }

  final List<MockSpan> spans = tracer.finishedSpans();
  assertEquals(2, spans.size());
}
 
Example #4
Source File: RedisLettuceCacheTest.java    From jetcache with Apache License 2.0 5 votes vote down vote up
private void testUnwrap(AbstractRedisClient client) {
    Assert.assertTrue(cache.unwrap(AbstractRedisClient.class) instanceof AbstractRedisClient);
    if (client instanceof RedisClient) {
        Assert.assertTrue(cache.unwrap(RedisClient.class) instanceof RedisClient);
        Assert.assertTrue(cache.unwrap(RedisCommands.class) instanceof RedisCommands);
        Assert.assertTrue(cache.unwrap(RedisAsyncCommands.class) instanceof RedisAsyncCommands);
        Assert.assertTrue(cache.unwrap(RedisReactiveCommands.class) instanceof RedisReactiveCommands);
    } else {
        Assert.assertTrue(cache.unwrap(RedisClusterClient.class) instanceof RedisClusterClient);
        Assert.assertTrue(cache.unwrap(RedisClusterCommands.class) instanceof RedisClusterCommands);
        Assert.assertTrue(cache.unwrap(RedisClusterAsyncCommands.class) instanceof RedisClusterAsyncCommands);
        Assert.assertTrue(cache.unwrap(RedisClusterReactiveCommands.class) instanceof RedisClusterReactiveCommands);
    }
}
 
Example #5
Source File: RedisLettuceStarterTest.java    From jetcache with Apache License 2.0 5 votes vote down vote up
@Test
public void tests() throws Exception {
    if (RedisLettuceCacheTest.checkOS()) {
        System.setProperty("spring.profiles.active", "redislettuce-cluster");
    } else {
        System.setProperty("spring.profiles.active", "redislettuce");
    }
    context = SpringApplication.run(RedisLettuceStarterTest.class);
    doTest();
    A bean = context.getBean(A.class);
    bean.test();

    RedisClient t1 = (RedisClient) context.getBean("defaultClient");
    RedisClient t2 = (RedisClient) context.getBean("a1Client");
    Assert.assertNotNull(t1);
    Assert.assertNotNull(t2);
    Assert.assertNotSame(t1, t2);

    AutoConfigureBeans acb = context.getBean(AutoConfigureBeans.class);

    String key = "remote.A1";
    Assert.assertTrue(new LettuceFactory(acb, key, StatefulRedisConnection.class).getObject() instanceof StatefulRedisConnection);
    Assert.assertTrue(new LettuceFactory(acb, key, RedisCommands.class).getObject() instanceof RedisCommands);
    Assert.assertTrue(new LettuceFactory(acb, key, RedisAsyncCommands.class).getObject() instanceof RedisAsyncCommands);
    Assert.assertTrue(new LettuceFactory(acb, key, RedisReactiveCommands.class).getObject() instanceof RedisReactiveCommands);

    if (RedisLettuceCacheTest.checkOS()) {
        key = "remote.A2";
        Assert.assertTrue(new LettuceFactory(acb, key, RedisClusterClient.class).getObject() instanceof RedisClusterClient);
        Assert.assertTrue(new LettuceFactory(acb, key, RedisClusterCommands.class).getObject() instanceof RedisClusterCommands);
        Assert.assertTrue(new LettuceFactory(acb, key, RedisClusterAsyncCommands.class).getObject() instanceof RedisClusterAsyncCommands);
        Assert.assertTrue(new LettuceFactory(acb, key, RedisClusterReactiveCommands.class).getObject() instanceof RedisClusterReactiveCommands);

        key = "remote.A2_slave";
        Assert.assertTrue(new LettuceFactory(acb, key, RedisClusterClient.class).getObject() instanceof RedisClusterClient);
    }
}
 
Example #6
Source File: TracingStatefulRedisConnection.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public RedisReactiveCommands<K, V> reactive() {
  return connection.reactive();
}
 
Example #7
Source File: TracingStatefulRedisConnection.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public RedisReactiveCommands<K, V> reactive() {
  return connection.reactive();
}
 
Example #8
Source File: TracingStatefulRedisConnection.java    From java-redis-client with Apache License 2.0 4 votes vote down vote up
@Override
public RedisReactiveCommands<K, V> reactive() {
  return connection.reactive();
}