-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start isolating reactor behind internal interfaces.
- Loading branch information
1 parent
b322040
commit 14aa8c2
Showing
13 changed files
with
95 additions
and
17 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
14 changes: 14 additions & 0 deletions
14
muon-core/src/main/java/io/muoncore/channel/Dispatcher.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,14 @@ | ||
package io.muoncore.channel; | ||
|
||
import java.util.function.Consumer; | ||
|
||
public interface Dispatcher { | ||
|
||
<E> void dispatch(E data, | ||
Consumer<E> eventConsumer, | ||
Consumer<Throwable> errorConsumer); | ||
|
||
<E> void tryDispatch(E data, | ||
Consumer<E> eventConsumer, | ||
Consumer<Throwable> errorConsumer); | ||
} |
21 changes: 21 additions & 0 deletions
21
muon-core/src/main/java/io/muoncore/channel/Reactor2Dispatcher.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,21 @@ | ||
package io.muoncore.channel; | ||
|
||
import lombok.AllArgsConstructor; | ||
|
||
import java.util.function.Consumer; | ||
|
||
@AllArgsConstructor | ||
public class Reactor2Dispatcher implements Dispatcher { | ||
|
||
private reactor.core.Dispatcher internal; | ||
|
||
@Override | ||
public <E> void dispatch(E data, Consumer<E> eventConsumer, Consumer<Throwable> errorConsumer) { | ||
internal.dispatch(data, eventConsumer::accept, errorConsumer::accept); | ||
} | ||
|
||
@Override | ||
public <E> void tryDispatch(E data, Consumer<E> eventConsumer, Consumer<Throwable> errorConsumer) { | ||
internal.tryDispatch(data, eventConsumer::accept, errorConsumer::accept); | ||
} | ||
} |
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
muon-core/src/test/groovy/io/muoncore/inmem/IntrospectionSimulationSpec.groovy
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,45 @@ | ||
package io.muoncore.inmem | ||
|
||
import com.google.common.eventbus.EventBus | ||
import io.muoncore.MultiTransportMuon | ||
import io.muoncore.Muon | ||
import io.muoncore.codec.json.JsonOnlyCodecs | ||
import io.muoncore.config.AutoConfiguration | ||
import io.muoncore.memory.discovery.InMemDiscovery | ||
import io.muoncore.memory.seda.InMemSeda | ||
import io.muoncore.memory.transport.InMemTransport | ||
import spock.lang.Ignore | ||
import spock.lang.Specification | ||
import spock.lang.Timeout | ||
|
||
class IntrospectionSimulationSpec extends Specification { | ||
|
||
def eventbus = new EventBus() | ||
|
||
@Timeout(100) | ||
"many services can run and be introspected"() { | ||
|
||
given: "some services" | ||
|
||
def discovery = new InMemDiscovery() | ||
|
||
//TODO, extract this out into the SEDA stack and have a general way of using it that isn't here. | ||
def seda = new InMemSeda(discovery, eventbus); | ||
|
||
def svc1 = createService("mine", discovery) | ||
|
||
when: | ||
def names = svc1.discovery.serviceNames | ||
|
||
then: | ||
names == ["hello"] | ||
|
||
} | ||
|
||
Muon createService(ident, discovery) { | ||
def config = new AutoConfiguration(serviceName: "${ident}") | ||
def transport = new InMemTransport(config, eventbus) | ||
|
||
new MultiTransportMuon(config, discovery, [transport], new JsonOnlyCodecs()) | ||
} | ||
} |