Skip to content

Commit 4ce6ca4

Browse files
Release (#9)
* Updated version in readme, added mvn central badge, fix typo * Added multiply example * Optimized all imports * Log errors thrown by implementations (#8) * Version bump --------- Co-authored-by: Duckelekuuk <[email protected]> Co-authored-by: Duckelekuuk <[email protected]>
1 parent b4cb9b6 commit 4ce6ca4

File tree

16 files changed

+34
-24
lines changed

16 files changed

+34
-24
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<img height="150" src="https://github.com/pixelib/Meteor/assets/10709682/d2a36e0a-38d5-43b7-a33b-600834559e46" />
33
</p>
44

5-
# Meteor ![branches](.github/badges/branches.svg) ![jacoco coverage](.github/badges/jacoco.svg)
5+
# Meteor ![Maven Central](https://img.shields.io/maven-central/v/dev.pixelib.meteor/meteor-parent) ![branches](.github/badges/branches.svg) ![jacoco coverage](.github/badges/jacoco.svg)
66
> A general-purpose Java RPC library that plugs in like magic
77
88
Meteor is designed to fill the (physical) gap between application instances and remote services where applications need to interface with a service that may be available locally or be provided by a remote JVM instance.
@@ -12,7 +12,7 @@ It allows you to write your application against your interface as if it's local
1212
<img src=".github/assets/flow.png" />
1313
</p>
1414

15-
> *Note that this diagram ommits certain parts, like scheduling/threading and abstracted serailization layers to make it more readable.*
15+
> *Note that this diagram omits certain parts, like scheduling/threading and abstracted serialization layers to make it more readable.*
1616
1717
# Installation
1818
Meteor comes by default with a local loopback transport.
@@ -21,7 +21,7 @@ Meteor is available on Maven Central, and can be installed by adding the followi
2121
<dependency>
2222
<groupId>dev.pixelib.meteor</groupId>
2323
<artifactId>meteor-core</artifactId>
24-
<version>1.0.0</version>
24+
<version>1.0.2</version>
2525
</dependency>
2626
```
2727

@@ -32,7 +32,7 @@ You can install the Redis transport by adding the following dependency to your `
3232
<dependency>
3333
<groupId>dev.pixelib.meteor.transport</groupId>
3434
<artifactId>meteor-jedis</artifactId>
35-
<version>1.0.0</version>
35+
<version>1.0.2</version>
3636
</dependency>
3737
```
3838

@@ -105,7 +105,7 @@ A full performance analysis can be found [here](PERFORMANCE.md)
105105

106106
# Design considerations
107107
### To queue or not to queue
108-
The library itself is unopinionated about transport and thus execution.
108+
The library itself is un opinionated about transport and thus execution.
109109
It's up to the specific transport implementation to decide whether a fan-out or queueing strategy is appropriate. The default Redis implementation uses a normal broadcast, meaning that all invocations will be executed on all nodes which provide an implementation (but only the first return value is returned to the invoker function). Other implementations may use a more sophisticated queueing mechanism, allowing implementation instances to only process a subset of the invocations.
110110

111111
### Error handling
@@ -115,5 +115,5 @@ Invocations leading to an exception on the implementation are considered as not
115115
Each Meteor instance uses its own internal thread pool for invocations against implementations. Invocations are queued up (in order of invocation time) if an implementation is busy. The thread pool size can be configured through the `RpcOptions`, and defaults to `1`.
116116

117117
### To serialize or not to serialize
118-
The library itself is unopinionated about serialization.
118+
The library itself is un opinionated about serialization.
119119
GSON gets used by default, but you can use any other serialization library you want, as long as it can serialize and deserialize generic types with another fallback method for unknown types.

examples/src/main/java/dev/pixelib/meteor/sender/SendingUpdateMethod.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public static void main(String[] args) throws Exception{
1010

1111
MathAdd mathAdd = meteor.registerProcedure(MathAdd.class);
1212
MathSubstract mathSubstract = meteor.registerProcedure(MathSubstract.class);
13+
MathMultiply mathMultiply = meteor.registerProcedure(MathMultiply.class);
1314

1415
// register an implementation, invocations will be dispatched to this object.
1516
// implementations will be registered under all interfaces they implement
@@ -21,6 +22,9 @@ public static void main(String[] args) throws Exception{
2122
int addResult = mathAdd.add(1, 2, 3, 4, 5);
2223
System.out.println("1 + 2 + 3 + 4 + 5 = " + addResult);
2324

25+
int multiResult = mathMultiply.multiply(5, 5);
26+
System.out.println("5 * 5 = " + multiResult);
27+
2428
meteor.stop();
2529
}
2630

examples/src/main/java/dev/pixelib/meteor/sender/SendingUpdateMethodRedis.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public static void main(String[] args) throws Exception{
1010

1111
MathAdd mathAdd = meteor.registerProcedure(MathAdd.class);
1212
MathSubstract mathSubstract = meteor.registerProcedure(MathSubstract.class);
13+
MathMultiply mathMultiply = meteor.registerProcedure(MathMultiply.class);
1314

1415
// register an implementation, invocations will be dispatched to this object.
1516
// implementations will be registered under all interfaces they implement
@@ -22,6 +23,9 @@ public static void main(String[] args) throws Exception{
2223
int addResult = mathAdd.add(1, 2, 3, 4, 5);
2324
System.out.println("1 + 2 + 3 + 4 + 5 = " + addResult);
2425

26+
int multiResult = mathMultiply.multiply(5, 5);
27+
System.out.println("5 * 5 = " + multiResult);
28+
2529
meteor.stop();
2630
}
2731

meteor-common/src/main/java/dev/pixelib/meteor/base/RpcTransport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.pixelib.meteor.base;
22

3-
import dev.pixelib.meteor.base.interfaces.SubscriptionHandler;
43
import dev.pixelib.meteor.base.enums.Direction;
4+
import dev.pixelib.meteor.base.interfaces.SubscriptionHandler;
55

66
import java.io.Closeable;
77

meteor-common/src/main/java/dev/pixelib/meteor/base/defaults/LoopbackTransport.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66

77
import java.io.IOException;
88
import java.util.ArrayList;
9-
import java.util.HashMap;
9+
import java.util.EnumMap;
1010
import java.util.List;
1111
import java.util.Map;
1212

1313
public class LoopbackTransport implements RpcTransport {
1414

15-
private final Map<Direction, List<SubscriptionHandler>> onReceiveFunctions = new HashMap<>();
15+
private final Map<Direction, List<SubscriptionHandler>> onReceiveFunctions = new EnumMap<>(Direction.class);
1616

1717
/**
1818
* @param bytes the bytes to send
19-
* bytes given should already been considered as a packet, and should not be further processed by the transport implementation
19+
* bytes given should already been considered as a packet, and should1not be further processed by the transport implementation
2020
* this particular implementation will call all the onReceive functions, and stop if one of them returns HANDLED
2121
* no actual sending is done, as this is a loopback transport meant for testing
2222
*/

meteor-core/src/main/java/dev/pixelib/meteor/core/Meteor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import dev.pixelib.meteor.base.RpcSerializer;
55
import dev.pixelib.meteor.base.RpcTransport;
66
import dev.pixelib.meteor.base.defaults.GsonSerializer;
7-
import dev.pixelib.meteor.core.proxy.ProxyInvocHandler;
87
import dev.pixelib.meteor.core.proxy.MeteorMock;
8+
import dev.pixelib.meteor.core.proxy.ProxyInvocHandler;
99
import dev.pixelib.meteor.core.trackers.IncomingInvocationTracker;
1010
import dev.pixelib.meteor.core.trackers.OutgoingInvocationTracker;
1111
import dev.pixelib.meteor.core.transport.TransportHandler;

meteor-core/src/main/java/dev/pixelib/meteor/core/proxy/ProxyInvocHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package dev.pixelib.meteor.core.proxy;
22

3-
import dev.pixelib.meteor.core.transport.packets.InvocationDescriptor;
43
import dev.pixelib.meteor.core.trackers.OutgoingInvocationTracker;
4+
import dev.pixelib.meteor.core.transport.packets.InvocationDescriptor;
55

66
import java.lang.reflect.InvocationHandler;
77
import java.lang.reflect.Method;

meteor-core/src/main/java/dev/pixelib/meteor/core/transport/TransportHandler.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@
55
import dev.pixelib.meteor.base.enums.Direction;
66
import dev.pixelib.meteor.core.executor.ImplementationWrapper;
77
import dev.pixelib.meteor.core.trackers.IncomingInvocationTracker;
8+
import dev.pixelib.meteor.core.trackers.OutgoingInvocationTracker;
89
import dev.pixelib.meteor.core.transport.packets.InvocationDescriptor;
910
import dev.pixelib.meteor.core.transport.packets.InvocationResponse;
10-
import dev.pixelib.meteor.core.trackers.OutgoingInvocationTracker;
1111

1212
import java.io.Closeable;
1313
import java.io.IOException;
1414
import java.util.Collection;
1515
import java.util.concurrent.ExecutorService;
1616
import java.util.concurrent.Executors;
17+
import java.util.logging.Level;
18+
import java.util.logging.Logger;
1719

1820
public class TransportHandler implements Closeable {
1921

22+
private final Logger logger = Logger.getLogger(TransportHandler.class.getSimpleName());
2023
private final RpcSerializer serializer;
2124
private final RpcTransport transport;
2225
private final IncomingInvocationTracker incomingInvocationTracker;
@@ -91,8 +94,8 @@ private boolean handleInvocationRequest(byte[] bytes) throws ClassNotFoundExcept
9194
Object response = matchedImplementation.invokeOn(invocationDescriptor, invocationDescriptor.getReturnType());
9295
InvocationResponse invocationResponse = new InvocationResponse(invocationDescriptor.getUniqueInvocationId(), response);
9396
transport.send(Direction.METHOD_PROXY, invocationResponse.toBytes(serializer));
94-
} catch (NoSuchMethodException e) {
95-
e.printStackTrace();
97+
} catch (Throwable e) {
98+
logger.log(Level.SEVERE, "An error occurred while invoking a method", e);
9699
}
97100
});
98101

meteor-core/src/test/java/dev/pixelib/meteor/core/LogicTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import dev.pixelib.meteor.core.transport.packets.InvocationDescriptor;
99
import org.junit.jupiter.api.Test;
1010

11-
import static org.junit.jupiter.api.Assertions.*;
11+
import static org.junit.jupiter.api.Assertions.assertEquals;
1212

1313
public class LogicTest {
1414

meteor-core/src/test/java/dev/pixelib/meteor/core/MeteorTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package dev.pixelib.meteor.core;
22

33
import dev.pixelib.meteor.base.defaults.LoopbackTransport;
4-
import org.junit.jupiter.api.Test;
54
import dev.pixelib.meteor.core.utils.MathFunctions;
5+
import org.junit.jupiter.api.Test;
66

77
import java.lang.reflect.Proxy;
88

0 commit comments

Comments
 (0)