Skip to content

Commit dd96aab

Browse files
author
Eugene_Utkin
committed
ISSUE-708 merge with develop
1 parent b57b0d4 commit dd96aab

File tree

3 files changed

+91
-3
lines changed
  • services-api/src/test/java/io/scalecube/services/transport/api
  • services-examples-parent/services-examples/src/main/java/io/scalecube/services/examples

3 files changed

+91
-3
lines changed

services-api/src/test/java/io/scalecube/services/transport/api/JdkCodecTest.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
import java.io.ByteArrayInputStream;
66
import java.io.ByteArrayOutputStream;
77
import java.io.IOException;
8+
import java.io.Serializable;
89
import java.util.Arrays;
10+
import java.util.Objects;
911
import java.util.stream.Stream;
1012
import org.junit.jupiter.params.ParameterizedTest;
1113
import org.junit.jupiter.params.provider.MethodSource;
@@ -22,7 +24,7 @@ void test(Object body) throws IOException {
2224
}
2325

2426
static Stream<Object> provider() {
25-
return Stream.of("hello", Arrays.<Object>asList(1,2,3));
27+
return Stream.of("hello", Arrays.<Object>asList(1, 2, 3), new Greeting("joe"));
2628
}
2729

2830
private Object writeAndRead(Object body) throws IOException {
@@ -34,4 +36,35 @@ private Object writeAndRead(Object body) throws IOException {
3436
}
3537
}
3638
}
37-
}
39+
40+
static class Greeting implements Serializable {
41+
42+
private final String name;
43+
44+
Greeting(String name) {
45+
this.name = name;
46+
}
47+
48+
public String getName() {
49+
return name;
50+
}
51+
52+
@Override
53+
public boolean equals(Object o) {
54+
if (this == o) {
55+
return true;
56+
}
57+
if (o == null || getClass() != o.getClass()) {
58+
return false;
59+
}
60+
Greeting greeting = (Greeting) o;
61+
return Objects.equals(name, greeting.name);
62+
}
63+
64+
@Override
65+
public int hashCode() {
66+
return Objects.hash(name);
67+
}
68+
}
69+
70+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package io.scalecube.services.examples.codecs;
2+
3+
import io.scalecube.net.Address;
4+
import io.scalecube.services.Microservices;
5+
import io.scalecube.services.discovery.ScalecubeServiceDiscovery;
6+
import io.scalecube.services.examples.helloworld.service.GreetingServiceImpl;
7+
import io.scalecube.services.examples.helloworld.service.api.GreetingsService;
8+
import io.scalecube.services.transport.rsocket.RSocketServiceTransport;
9+
10+
public class Example2 {
11+
12+
public static final String CONTENT_TYPE = "application/octet-stream";
13+
14+
/**
15+
* Start the example.
16+
*
17+
* @param args ignored
18+
*/
19+
public static void main(String[] args) {
20+
// ScaleCube Node node with no members
21+
Microservices seed =
22+
Microservices.builder()
23+
.discovery(ScalecubeServiceDiscovery::new)
24+
.transport(RSocketServiceTransport::new)
25+
.contentType(CONTENT_TYPE) // need to send with non-default data format
26+
.startAwait();
27+
28+
final Address seedAddress = seed.discovery().address();
29+
30+
// Construct a ScaleCube node which joins the cluster hosting the Greeting Service
31+
Microservices ms =
32+
Microservices.builder()
33+
.discovery(
34+
endpoint ->
35+
new ScalecubeServiceDiscovery(endpoint)
36+
.membership(cfg -> cfg.seedMembers(seedAddress)))
37+
.transport(RSocketServiceTransport::new)
38+
.services(new GreetingServiceImpl())
39+
.startAwait();
40+
41+
// Create service proxy
42+
GreetingsService service = seed.call().api(GreetingsService.class);
43+
44+
// Execute the services and subscribe to service events
45+
service
46+
.sayHello("joe")
47+
.subscribe(consumer -> System.out.println(consumer.message()));
48+
49+
seed.onShutdown().block();
50+
ms.onShutdown().block();
51+
}
52+
53+
}

services-examples-parent/services-examples/src/main/java/io/scalecube/services/examples/helloworld/service/api/Greeting.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.scalecube.services.examples.helloworld.service.api;
22

3-
public class Greeting {
3+
import java.io.Serializable;
4+
5+
public class Greeting implements Serializable {
46

57
String message;
68

0 commit comments

Comments
 (0)