-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
45 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
lavender-brokers/lavender-broker-common/src/dev/shiza/lavender/broker/PacketBaseBroker.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,19 @@ | ||
package dev.shiza.lavender.broker; | ||
|
||
import dev.shiza.lavender.codec.Packet; | ||
import org.jetbrains.annotations.ApiStatus.Internal; | ||
|
||
@Internal | ||
public abstract class PacketBaseBroker<T> implements PacketBroker<T> { | ||
|
||
@Override | ||
public void delegateToPacketBroker(final Packet request, final Packet response) | ||
throws PacketOrchestrationException { | ||
if (request.getTarget() == null) { | ||
throw new PacketOrchestrationException( | ||
"Could not delegate packet to packet broker due to missing target."); | ||
} | ||
|
||
publish(request.getTarget(), response); | ||
} | ||
} |
12 changes: 6 additions & 6 deletions
12
...nder-brokers/lavender-broker-common/src/dev/shiza/lavender/broker/PacketOrchestrator.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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package dev.shiza.lavender.broker; | ||
|
||
import dev.shiza.lavender.codec.Packet; | ||
import java.util.function.BiConsumer; | ||
import java.util.function.Consumer; | ||
|
||
public interface PacketOrchestrator<T> { | ||
|
||
/** | ||
* Delegates packet to event bus. | ||
* | ||
* @return consumer for packet delegation | ||
* @param message message to be delegated | ||
* @throws PacketOrchestrationException if packet could not be delegated to event bus | ||
*/ | ||
Consumer<T> delegateToEventBus() throws PacketOrchestrationException; | ||
void delegateToEventBus(final T message) throws PacketOrchestrationException; | ||
|
||
/** | ||
* Delegates packet to packet broker. | ||
* | ||
* @return consumer for packet delegation | ||
* @param request packet sent as a request | ||
* @param response packet to be sent as a response | ||
* @throws PacketOrchestrationException if packet could not be delegated to packet broker | ||
*/ | ||
BiConsumer<Packet, Packet> delegateToPacketBroker() throws PacketOrchestrationException; | ||
void delegateToPacketBroker(final Packet request, final Packet response) | ||
throws PacketOrchestrationException; | ||
} |
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