|
18 | 18 |
|
19 | 19 | import java.util.function.Function;
|
20 | 20 |
|
21 |
| -public abstract class RequestHandler { |
22 |
| - private static final Function<Payload, Publisher<Payload>> NO_REQUEST_RESPONSE_HANDLER = |
| 21 | +public interface RequestHandler { |
| 22 | + Function<Payload, Publisher<Payload>> NO_REQUEST_RESPONSE_HANDLER = |
23 | 23 | payload -> PublisherUtils.errorPayload(new RuntimeException("No 'requestResponse' handler"));
|
24 | 24 |
|
25 |
| - private static final Function<Payload, Publisher<Payload>> NO_REQUEST_STREAM_HANDLER = |
| 25 | + Function<Payload, Publisher<Payload>> NO_REQUEST_STREAM_HANDLER = |
26 | 26 | payload -> PublisherUtils.errorPayload(new RuntimeException("No 'requestStream' handler"));
|
27 | 27 |
|
28 |
| - private static final Function<Payload, Publisher<Payload>> NO_REQUEST_SUBSCRIPTION_HANDLER = |
| 28 | + Function<Payload, Publisher<Payload>> NO_REQUEST_SUBSCRIPTION_HANDLER = |
29 | 29 | payload -> PublisherUtils.errorPayload(new RuntimeException("No 'requestSubscription' handler"));
|
30 | 30 |
|
31 |
| - private static final Function<Payload, Publisher<Void>> NO_FIRE_AND_FORGET_HANDLER = |
| 31 | + Function<Payload, Publisher<Void>> NO_FIRE_AND_FORGET_HANDLER = |
32 | 32 | payload -> Publishers.error(new RuntimeException("No 'fireAndForget' handler"));
|
33 | 33 |
|
34 |
| - private static final Function<Publisher<Payload>, Publisher<Payload>> NO_REQUEST_CHANNEL_HANDLER = |
| 34 | + Function<Publisher<Payload>, Publisher<Payload>> NO_REQUEST_CHANNEL_HANDLER = |
35 | 35 | payloads -> PublisherUtils.errorPayload(new RuntimeException("No 'requestChannel' handler"));
|
36 | 36 |
|
37 |
| - private static final Function<Payload, Publisher<Void>> NO_METADATA_PUSH_HANDLER = |
| 37 | + Function<Payload, Publisher<Void>> NO_METADATA_PUSH_HANDLER = |
38 | 38 | payload -> Publishers.error(new RuntimeException("No 'metadataPush' handler"));
|
39 | 39 |
|
40 |
| - public abstract Publisher<Payload> handleRequestResponse(final Payload payload); |
| 40 | + Publisher<Payload> handleRequestResponse(final Payload payload); |
41 | 41 |
|
42 |
| - public abstract Publisher<Payload> handleRequestStream(final Payload payload); |
| 42 | + Publisher<Payload> handleRequestStream(final Payload payload); |
43 | 43 |
|
44 |
| - public abstract Publisher<Payload> handleSubscription(final Payload payload); |
| 44 | + Publisher<Payload> handleSubscription(final Payload payload); |
45 | 45 |
|
46 |
| - public abstract Publisher<Void> handleFireAndForget(final Payload payload); |
| 46 | + Publisher<Void> handleFireAndForget(final Payload payload); |
47 | 47 |
|
48 | 48 | /**
|
49 | 49 | * @note The initialPayload will also be part of the inputs publisher.
|
50 | 50 | * It is there to simplify routing logic.
|
51 | 51 | */
|
52 |
| - public abstract Publisher<Payload> handleChannel(Payload initialPayload, final Publisher<Payload> inputs); |
| 52 | + Publisher<Payload> handleChannel(final Payload initialPayload, final Publisher<Payload> inputs); |
53 | 53 |
|
54 |
| - public abstract Publisher<Void> handleMetadataPush(final Payload payload); |
| 54 | + Publisher<Void> handleMetadataPush(final Payload payload); |
55 | 55 |
|
56 |
| - public static class Builder { |
| 56 | + class Builder { |
57 | 57 | private Function<Payload, Publisher<Payload>> handleRequestResponse = NO_REQUEST_RESPONSE_HANDLER;
|
58 | 58 | private Function<Payload, Publisher<Payload>> handleRequestStream = NO_REQUEST_STREAM_HANDLER;
|
59 | 59 | private Function<Payload, Publisher<Payload>> handleRequestSubscription = NO_REQUEST_SUBSCRIPTION_HANDLER;
|
|
0 commit comments