Skip to content

Commit

Permalink
Update demo to use coherence-go-client v2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiddlet2666 committed Dec 24, 2024
1 parent 4313446 commit 57825c1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
8 changes: 4 additions & 4 deletions clients/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ go 1.20

require (
github.com/google/uuid v1.3.0
github.com/oracle/coherence-go-client v1.2.2
github.com/oracle/coherence-go-client/v2 v2.0.0
)

require (
github.com/golang/protobuf v1.5.3 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.33.0 // indirect
golang.org/x/sys v0.28.0 // indirect
golang.org/x/text v0.21.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/grpc v1.58.3 // indirect
google.golang.org/protobuf v1.33.0 // indirect
Expand Down
8 changes: 8 additions & 0 deletions clients/go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
github.com/oracle/coherence-go-client v1.2.2 h1:TGK87WhV8MWeCiZKk0rC+aZbt40p2nRVvxDUbF+2gX8=
github.com/oracle/coherence-go-client v1.2.2/go.mod h1:8wy6v4KvDGJv6iIiCD95aU0g8UL34DaKRHs3zqQN/Bg=
github.com/oracle/coherence-go-client/v2 v2.0.0 h1:epRtq50pHgW0Wbl7piSPdDbwE3JVe+9XFyTS+j0YmEI=
github.com/oracle/coherence-go-client/v2 v2.0.0/go.mod h1:tiCK6dVyBf/GVabOPY73Cl6+eKoLtStx/uWEEdJfpKg=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 h1:bVf09lpb+OJbByTj913DRJioFFAjf/ZGxEz7MajTp2U=
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM=
Expand Down
12 changes: 6 additions & 6 deletions clients/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"errors"
"fmt"
"github.com/google/uuid"
"github.com/oracle/coherence-go-client/coherence"
"github.com/oracle/coherence-go-client/coherence/extractors"
"github.com/oracle/coherence-go-client/coherence/filters"
"github.com/oracle/coherence-go-client/coherence/processors"
"github.com/oracle/coherence-go-client/v2/coherence"
"github.com/oracle/coherence-go-client/v2/coherence/extractors"
"github.com/oracle/coherence-go-client/v2/coherence/filters"
"github.com/oracle/coherence-go-client/v2/coherence/processors"
"log"
"math/rand"
"os"
Expand Down Expand Up @@ -254,7 +254,7 @@ func stockSplit(trades coherence.NamedCache[string, Trade], prices coherence.Nam

symbolExtractor := extractors.Extract[string]("symbol")

ch := coherence.InvokeAllFilter[string, Trade, string](ctx, trades, filters.Equal(symbolExtractor, symbol),
ch := coherence.InvokeAllFilter[string, Trade, int64](ctx, trades, filters.Equal(symbolExtractor, symbol),
processors.Multiply("quantity", factor))

count := 0
Expand All @@ -268,7 +268,7 @@ func stockSplit(trades coherence.NamedCache[string, Trade], prices coherence.Nam
log.Printf("Updated quantity for %d trades", count)

count = 0
ch2 := coherence.InvokeAllFilter[string, Trade, string](ctx, trades, filters.Equal(symbolExtractor, symbol),
ch2 := coherence.InvokeAllFilter[string, Trade, float64](ctx, trades, filters.Equal(symbolExtractor, symbol),
processors.Multiply("price", float32(1)/float32(factor)))

for v := range ch2 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ public void onEvent(LifecycleEvent event) {

// check to see if the data is loaded already if we are in Kubernetes
if (Utilities.isRunningInKubernetes()) {
if (pricesCache.size() == 0) {
if (pricesCache.isEmpty()) {
// wait for a short while in case the two storage members start at exact same time
// and if the prices cache is still zero then load
Base.sleep(new Random().nextInt(4000) + 1000L);
if (pricesCache.size() == 0) {
if (pricesCache.isEmpty()) {
loadData = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,12 @@ private Launcher() {
* @param args unused
*/
public static void main(String[] args) {
// set JVisualVM refresh time to 5 seconds for demo purposes only
System.setProperty("com.oracle.coherence.jvisualvm.refreshtime", "5");

// set the cache configuration
System.setProperty("coherence.cacheconfig", "cache-config.xml");

System.setProperty("coherence.role", "CoherenceDemoLauncher");

// specify to ignore new 2server SE strategy
System.setProperty("coherence.distribution.2server", "false");

// use WKA
System.setProperty("coherence.wka", "127.0.0.1");
System.setProperty("coherence.ttl", "0");

// enable http serving
System.setProperty("with.http", "true");

Expand Down

0 comments on commit 57825c1

Please sign in to comment.