This file contains hidden or 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
| def stream1 = AmqpStreams.fromQueue(Queue.lookup('test') | |
| .durable(true) | |
| .bind('test')) | |
| def stream2 = AmqpStreams.fromQueue('test') | |
| Streams.merge(stream1, stream2) | |
| .dispatchOn(environment) |
This file contains hidden or 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
| @Bean | |
| public Renderer<Stream> personRenderer() { | |
| return new RendererSupport<Stream>() { | |
| @Override | |
| public void render(Context ctx, Stream s) throws Exception { | |
| ctx.promise(f -> s.consume(f::success)) | |
| .then(o -> ctx.render(json(o))); | |
| } | |
| }; | |
| } |
This file contains hidden or 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
| @Bean | |
| public Action<Chain> handlers(PersonRepository persons, | |
| HotStream<Person> personStream, | |
| ObjectMapper jsonMapper, | |
| ModelMapper beanMapper) { | |
| return (chain) -> { | |
| chain.handler("person", ctx -> | |
| ctx.byMethod(spec -> | |
| spec | |
| .get(c -> { |
This file contains hidden or 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
| public interface PersonStream extends ReactiveStream<Person> { | |
| @MapAction("@personRepo.merge($1, $2)") | |
| ReactivePromise<Person> merge(String id, Person p); | |
| } | |
| @ReactiveRestController | |
| public class MyController { |
This file contains hidden or 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
| static { | |
| // Only done once, statically, and shared across this classloader | |
| Environment.initialize(); | |
| } | |
| // Create a Stream subclass we can sink values into | |
| Broadcaster<String> b = Broadcaster.create(); | |
| b | |
| // dispatch onto a Thread other than 'main' |
This file contains hidden or 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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project xmlns="http://maven.apache.org/POM/4.0.0" | |
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| <modelVersion>4.0.0</modelVersion> | |
| <groupId>com.mycompany</groupId> | |
| <artifactId>my-project</artifactId> | |
| <version>1.0.0.BUILD-SNAPSHOT</version> |
This file contains hidden or 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
| import org.apache.commons.lang.time.StopWatch; | |
| import reactor.Environment; | |
| import reactor.fn.BiFunction; | |
| import reactor.rx.Streams; | |
| import java.util.concurrent.TimeUnit; | |
| /** | |
| * Demo class for calculating Pi using Reactor. | |
| */ |
This file contains hidden or 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
| interface Channel<IN, OUT> extends Publisher<IN> { | |
| Publisher<Boolean> write(Publisher<? extends OUT> data); | |
| } | |
| interface ClientSocketOptions { | |
| SocketAddress connectAddress(); |
This file contains hidden or 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
| public interface TcpConnection<R, W> { | |
| Reader<R> reader(); | |
| Writer<W> writer(); | |
| public interface Reader<R> extends Publisher<R> { | |
| <NEWR> Reader<NEWR> intercept(Interceptor<R, NEWR> interceptor); | |
| } |
This file contains hidden or 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
| ReactorTcpServer.listen(3000, ByteBuf.class) | |
| .log("connection") | |
| .consume(conn -> conn.out(conn.in().log("in")) | |
| .log("confirmation") | |
| .consume(buf -> LOG.info("write confirmed: {}", buf))); |