Skip to content

Commit

Permalink
reference to the example files in the doc page
Browse files Browse the repository at this point in the history
  • Loading branch information
semihbkgr committed May 10, 2024
1 parent d39e6c6 commit 7291f7b
Show file tree
Hide file tree
Showing 25 changed files with 12 additions and 104 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,17 @@ The `ADDRESS` column displays the external address of your Hazelcast cluster.

=== Connect Hazelcast Clients to the Cluster

To access all examples (excluding CLC), clone the following repository.
[source,shell]
----
git clone https://github.com/hazelcast-guides/hazelcast-platform-operator-expose-externally.git
cd hazelcast-platform-operator-expose-externally
----

. The sample code(excluding CLC) for this tutorial is in the link:{github-directory}/tree/master/docs/modules/ROOT/examples[`docs/modules/ROOT/examples/`] directory.

Configure the Hazelcast client with the external address and disable smart routing to use the unisocket connection.


[tabs]
====
Expand All @@ -114,9 +115,7 @@ Java::
--
[source, java]
----
ClientConfig config = new ClientConfig();
config.getNetworkConfig().addAddress("<EXTERNAL-IP>")
.setSmartRouting(false);
include::ROOT:example$/java-unisocket/src/main/java/com/hazelcast/Main.java[]
----
--
Expand All @@ -125,17 +124,7 @@ NodeJS::
--
[source, javascript]
----
const { Client } = require('hazelcast-client');
const clientConfig = {
network: {
clusterMembers: [
'<EXTERNAL-IP>'
],
smartRouting: false
}
};
const client = await Client.newHazelcastClient(clientConfig);
include::ROOT:example$/nodejs-unisocket/client.js[]
----
--
Expand All @@ -144,23 +133,7 @@ Go::
--
[source, go]
----
import (
"log"
"github.com/hazelcast/hazelcast-go-client"
)
func main() {
config := hazelcast.Config{}
cc := &config.Cluster
cc.Network.SetAddresses("<EXTERNAL-IP>")
cc.Unisocket = true
ctx := context.TODO()
client, err := hazelcast.StartNewClientWithConfig(ctx, config)
if err != nil {
panic(err)
}
}
include::ROOT:example$/go-unisocket/main.go[]
----
--
Expand All @@ -169,32 +142,15 @@ Python::
--
[source, python]
----
import logging
import hazelcast
logging.basicConfig(level=logging.INFO)
client = hazelcast.HazelcastClient(
cluster_members=["<EXTERNAL-IP>"],
smart_routing=False,
)
include::ROOT:example$/python-unisocket/main.py[]
----
--
.NET::
+
--
[source, cs]
----
var options = new HazelcastOptionsBuilder()
.With(args)
.With((configuration, options) =>
{
options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole());
options.Networking.Addresses.Add("<EXTERNAL-IP>");
options.Networking.SmartRouting = false;
})
.Build();
var client = await HazelcastClientFactory.StartNewClientAsync(options);
include::ROOT:example$/dotnet-unisocket/csharp_example.cs[]
----
--
====
Expand Down Expand Up @@ -435,9 +391,7 @@ Java::
--
[source, java]
----
ClientConfig config = new ClientConfig();
config.getNetworkConfig().addAddress("<EXTERNAL-IP>");
config.getProperties().setProperty(ClientProperty.DISCOVERY_SPI_PUBLIC_IP_ENABLED.toString(), "true");
include::ROOT:example$/java/src/main/java/com/hazelcast/Main.java[]
----
--
Expand All @@ -446,19 +400,7 @@ NodeJS::
--
[source, javascript]
----
const { Client } = require('hazelcast-client');
const clientConfig = {
network: {
clusterMembers: [
'<EXTERNAL-IP>'
]
},
properties: {
['hazelcast.discovery.public.ip.enabled']: true
}
};
const client = await Client.newHazelcastClient(clientConfig);
include::ROOT:example$/nodejs/client.js[]
----
--
Expand All @@ -467,23 +409,7 @@ Go::
--
[source, go]
----
import (
"log"
"github.com/hazelcast/hazelcast-go-client"
)
func main() {
config := hazelcast.Config{}
cc := &config.Cluster
cc.Network.SetAddresses("<EXTERNAL-IP>")
cc.Discovery.UsePublicIP = true
ctx := context.TODO()
client, err := hazelcast.StartNewClientWithConfig(ctx, config)
if err != nil {
panic(err)
}
}
include::ROOT:example$/go/main.go[]
----
--
Expand All @@ -492,33 +418,15 @@ Python::
--
[source, python]
----
import logging
import hazelcast
logging.basicConfig(level=logging.INFO)
client = hazelcast.HazelcastClient(
cluster_members=["<EXTERNAL-IP>"],
use_public_ip=True,
)
include::ROOT:example$/python/main.py[]
----
--
.Net::
+
--
[source, cs]
----
var options = new HazelcastOptionsBuilder()
.With(args)
.With((configuration, options) =>
{
options.LoggerFactory.Creator = () => LoggerFactory.Create(loggingBuilder => loggingBuilder.AddConfiguration(configuration.GetSection("logging")).AddConsole());
options.Networking.Addresses.Add("<EXTERNAL-IP>");
options.Networking.UsePublicAddresses = true;
})
.Build();
var client = await HazelcastClientFactory.StartNewClientAsync(options);
include::ROOT:example$/dotnet/csharp_example.cs[]
----
--
====
Expand Down

0 comments on commit 7291f7b

Please sign in to comment.