Created
December 31, 2014 15:05
-
-
Save jbrisbin/3480e7d910e19978cf47 to your computer and use it in GitHub Desktop.
Sketch of ReactiveStream interface-based API
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 { | |
private final EventBus events; | |
private final MyService service; | |
@Inject | |
public MyController(EventBus events, MyService service) { | |
this.events = events; | |
this.service = service; | |
} | |
@RequestMapping(value="/person/{id}", method=HttpMethod.PATCH) | |
public void update(HttpExchange xchng, @RequestBody Person p, @PathParam("id") String id) { | |
ReactiveStreams.just(PersonStream.class, body) | |
.observe(service::firePreMergeAction) | |
.merge(id, p) | |
.onSuccess(p -> { | |
events.notify("some.topic", Event.wrap(p)); | |
xchng.redirect(xchng.getRequestUri()); | |
}) | |
.onError(xchng::internalServerError); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Unsure what
ReactiveStream
is here, but could you not use RS'sPublisher
or something likeSource
?