Skip to content

Commit 6bd08cc

Browse files
committed
Updated example with metadata
1 parent 6beb91b commit 6bd08cc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,26 @@
33
import io.scalecube.cluster.Cluster;
44
import io.scalecube.cluster.ClusterImpl;
55
import io.scalecube.cluster.metadata.MetadataCodec;
6+
import io.scalecube.transport.netty.websocket.WebsocketTransportFactory;
67
import java.nio.ByteBuffer;
78
import java.util.concurrent.TimeUnit;
89

9-
public class ClusterCustomMetadataEncodingExample {
10+
public class CustomMetadataEncodingExample {
1011

1112
/** Main method. */
1213
public static void main(String[] args) throws Exception {
1314
// Start seed cluster member Alice
1415
Cluster alice =
15-
new ClusterImpl().config(opts -> opts.metadataCodec(new LongMetadataCodec())).startAwait();
16+
new ClusterImpl()
17+
.transportFactory(WebsocketTransportFactory::new)
18+
.config(opts -> opts.metadataCodec(new LongMetadataCodec()))
19+
.startAwait();
1620
System.out.println(
1721
"[" + alice.member().id() + "] Alice's metadata: " + alice.metadata().orElse(null));
1822

1923
Cluster joe =
2024
new ClusterImpl()
25+
.transportFactory(WebsocketTransportFactory::new)
2126
.config(opts -> opts.metadataCodec(new LongMetadataCodec()).metadata(123L))
2227
.membership(opts -> opts.seedMembers(alice.address()))
2328
.startAwait();
@@ -26,6 +31,7 @@ public static void main(String[] args) throws Exception {
2631

2732
Cluster bob =
2833
new ClusterImpl()
34+
.transportFactory(WebsocketTransportFactory::new)
2935
.config(opts -> opts.metadataCodec(new LongMetadataCodec()).metadata(456L))
3036
.membership(opts -> opts.seedMembers(alice.address()))
3137
.startAwait();

0 commit comments

Comments
 (0)