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
// reactor-fsm: github.com/jbrisbin/reactor-fsm | |
// reactor: github.com/reactor/reactor | |
StateMachine ioMachine = new StateMachine.Spec(). | |
sync(). | |
using('idle', 'wait', 'send-request', 'response-ready'). | |
when('send-request') { prev -> | |
def msg = requests.peek() | |
send(msg) | |
'wait' |
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
package reactor.spring.webmvc; | |
import org.springframework.core.MethodParameter; | |
import org.springframework.web.context.request.NativeWebRequest; | |
import org.springframework.web.context.request.async.DeferredResult; | |
import org.springframework.web.context.request.async.WebAsyncUtils; | |
import org.springframework.web.method.support.HandlerMethodReturnValueHandler; | |
import org.springframework.web.method.support.ModelAndViewContainer; | |
import reactor.core.composable.Promise; | |
import reactor.function.Consumer; |
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
// Create a Reactor Environment (1 per JVM). | |
static final Environment env = new Environment(); | |
// Create a Reactor to handle IO events that's backed by a ThreadPoolExecutorDispatcher. | |
// To increase concurrent thread count, copy META-INF/reactor/default.properties from | |
// GitHub repo and put it into your own project, adjusting number of threads from 0 (1 per CPU) | |
// to whatever you want. | |
Reactor ioReactor = Reactors.reactor() | |
.env(env) | |
.dispatcher(Environment.THREAD_POOL) |
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
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.stereotype.Component; | |
import org.springframework.stereotype.Service; | |
import reactor.core.Environment; | |
import reactor.core.Reactor; | |
import reactor.core.spec.Reactors; |
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
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':data-spring:test'. | |
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69) | |
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) | |
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) | |
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) | |
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) | |
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) | |
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) | |
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.j |
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
@Controller | |
public class TradeController { | |
@Autowired | |
private ClientComposableRepository clients; | |
@RequestMapping(value = "/{clientId}", method = RequestMethod.POST) | |
@ResponseBody | |
public DeferredResult<String> trade(@PathVariable Long clientId) { | |
final DeferredResult<String> d = new DeferredResult<String>(); |
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
import reactor.core.Environment; | |
import reactor.core.composable.Deferred; | |
import reactor.core.composable.Stream; | |
import reactor.core.composable.spec.Streams; | |
import reactor.function.Consumer; | |
import reactor.function.Function; | |
import reactor.tuple.Tuple2; | |
/** | |
* @author Jon Brisbin |
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
public interface ComposableEventRepository<V, K extends Serializable> extends ComposableMessagingRepository<Event<V>, K> { | |
Stream<Event<V>> receive(Selector sel); | |
} |
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
public class NettyHttpServerSocketOptions extends NettyServerSocketOptions { | |
@Override | |
public final Consumer<ChannelPipeline> pipelineConfigurer() { | |
return new Consumer<ChannelPipeline>() { | |
@Override | |
public void accept(ChannelPipeline pipeline) { | |
pipeline.addLast(new HttpRequestDecoder()); | |
pipeline.addLast(new HttpObjectAggregator(Integer.MAX_VALUE)); | |
pipeline.addLast(new HttpResponseEncoder()); | |
} |
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
import static reactor.event.selector.Selectors.*; | |
import reactor.core.Environment; | |
import reactor.core.Reactor; | |
import reactor.core.spec.Reactors; | |
import reactor.event.Event; | |
import reactor.function.Function; | |
/** | |
* Example of Reactor usage with JDK 8 Lambdas. |