forked from eclipse-vertx/vert.x
-
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.
Merge pull request eclipse-vertx#1192 from eclipse/flow_control
Event bus flow control / interceptors
- Loading branch information
Showing
22 changed files
with
766 additions
and
218 deletions.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
src/main/java/io/vertx/core/eventbus/BridgeInterceptor.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,16 @@ | ||
package io.vertx.core.eventbus; | ||
|
||
/** | ||
* @author <a href="http://tfox.org">Tim Fox</a> | ||
*/ | ||
public class BridgeInterceptor extends FilteringInterceptor { | ||
|
||
public BridgeInterceptor(String startsWith) { | ||
super(startsWith); | ||
} | ||
|
||
@Override | ||
protected void handleContext(SendContext sendContext) { | ||
|
||
} | ||
} |
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
29 changes: 29 additions & 0 deletions
29
src/main/java/io/vertx/core/eventbus/FilteringInterceptor.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,29 @@ | ||
package io.vertx.core.eventbus; | ||
|
||
import io.vertx.core.Handler; | ||
|
||
/** | ||
* @author <a href="http://tfox.org">Tim Fox</a> | ||
*/ | ||
public abstract class FilteringInterceptor implements Handler<SendContext> { | ||
|
||
private final String startsWith; | ||
|
||
public FilteringInterceptor(String startsWith) { | ||
this.startsWith = startsWith; | ||
} | ||
|
||
// TODO regex | ||
|
||
@Override | ||
public void handle(SendContext sendContext) { | ||
if (sendContext.message().address().startsWith(startsWith)) { | ||
handleContext(sendContext); | ||
} else { | ||
sendContext.next(); | ||
} | ||
} | ||
|
||
protected abstract void handleContext(SendContext sendContext); | ||
|
||
} |
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
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,29 @@ | ||
package io.vertx.core.eventbus; | ||
|
||
import io.vertx.codegen.annotations.VertxGen; | ||
|
||
/** | ||
* | ||
* Encapsulates a message being sent from Vert.x. Used with event bus interceptors | ||
* | ||
* @author <a href="http://tfox.org">Tim Fox</a> | ||
*/ | ||
@VertxGen | ||
public interface SendContext<T> { | ||
|
||
/** | ||
* @return The message being sent | ||
*/ | ||
Message<T> message(); | ||
|
||
/** | ||
* Call the next interceptor | ||
*/ | ||
void next(); | ||
|
||
/** | ||
* | ||
* @return true if the message is being sent (point to point) or False if the message is being published | ||
*/ | ||
boolean send(); | ||
} |
27 changes: 0 additions & 27 deletions
27
src/main/java/io/vertx/core/eventbus/impl/EventBusFactoryImpl.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.