-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support lettuce cluster (#368)
* feat: support lettuce cluster * feat: support lettuce cluster --------- Co-authored-by: lucas-myx <[email protected]> Co-authored-by: mr3 <[email protected]>
- Loading branch information
1 parent
664afac
commit c5c1b1e
Showing
66 changed files
with
8,668 additions
and
3,893 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
10 changes: 5 additions & 5 deletions
10
...va/io/arex/inst/common/util/FluxUtil.java → ...arex/inst/common/util/FluxReplayUtil.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
32 changes: 32 additions & 0 deletions
32
...ntation/common/arex-common/src/main/java/io/arex/inst/common/util/MonoRecordFunction.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,32 @@ | ||
package io.arex.inst.common.util; | ||
|
||
import io.arex.agent.bootstrap.ctx.TraceTransmitter; | ||
import java.util.function.Function; | ||
import java.util.function.UnaryOperator; | ||
import reactor.core.publisher.Mono; | ||
|
||
public class MonoRecordFunction implements UnaryOperator<Mono<?>> { | ||
|
||
private final Function<Object, Void> executor; | ||
private final TraceTransmitter traceTransmitter; | ||
|
||
public MonoRecordFunction(Function<Object, Void> executor) { | ||
this.traceTransmitter = TraceTransmitter.create(); | ||
this.executor = executor; | ||
} | ||
|
||
@Override | ||
public Mono<?> apply(Mono<?> responseMono) { | ||
return responseMono | ||
.doOnSuccess(result -> { | ||
try (TraceTransmitter tm = traceTransmitter.transmit()) { | ||
executor.apply(result); | ||
} | ||
}) | ||
.doOnError(error -> { | ||
try (TraceTransmitter tm = traceTransmitter.transmit()) { | ||
executor.apply(error); | ||
} | ||
}); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
...tion/common/arex-common/src/test/java/io/arex/inst/common/util/MonoRecordFuntionTest.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,38 @@ | ||
package io.arex.inst.common.util; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import java.util.function.Function; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import reactor.core.publisher.Mono; | ||
|
||
public class MonoRecordFuntionTest { | ||
|
||
static Function<Object, Void> executor; | ||
|
||
@BeforeAll | ||
static void setUp() { | ||
executor = Mockito.mock(Function.class); | ||
} | ||
|
||
@AfterAll | ||
static void tearDown() { | ||
executor = null; | ||
Mockito.clearAllCaches(); | ||
} | ||
|
||
@Test | ||
void monoConsumer() { | ||
Mono<String> mono = Mono.just("test"); | ||
Mono<String> monoResult = (Mono<String>) new MonoRecordFunction(executor).apply(mono); | ||
assertEquals("test", monoResult.block()); | ||
|
||
Mono<Exception> mono2 = Mono.error(new Exception("exception")); | ||
Mono<String> monoResult2 = (Mono<String>) new MonoRecordFunction(executor).apply(mono2); | ||
assertThrows(Exception.class, () -> monoResult2.block()); | ||
} | ||
|
||
} |
Oops, something went wrong.