diff --git a/client_test.go b/client_test.go index 9041c7a..19b03b1 100644 --- a/client_test.go +++ b/client_test.go @@ -7,6 +7,7 @@ import ( "log" "testing" + "github.com/gammazero/workerpool" "github.com/stretchr/testify/require" "github.com/xconnio/xconn-go" @@ -17,7 +18,9 @@ func connect(t *testing.T) *xconn.Session { defer func() { _ = listener.Close() }() address := fmt.Sprintf("ws://%s/ws", listener.Addr().String()) - client := &xconn.Client{} + client := &xconn.Client{ + SerializerSpec: xconn.JSONSerializerSpec, + } session, err := client.Connect(context.Background(), address, "realm1") require.NoError(t, err) @@ -54,11 +57,17 @@ func TestRegisterCall(t *testing.T) { require.NotNil(t, reg) t.Run("Call", func(t *testing.T) { - result, err := session.Call(context.Background(), "foo.bar", nil, nil, nil) - require.NoError(t, err) - require.NotNil(t, result) + wp := workerpool.New(10) + for i := 0; i < 100; i++ { + wp.Submit(func() { + result, err := session.Call(context.Background(), "foo.bar", nil, nil, nil) + require.NoError(t, err) + require.NotNil(t, result) + require.Equal(t, "hello", result.Args[0]) + }) + } - require.Equal(t, "hello", result.Args[0]) + wp.StopWait() }) } diff --git a/go.mod b/go.mod index a04de23..6e61729 100644 --- a/go.mod +++ b/go.mod @@ -4,14 +4,16 @@ go 1.20 require ( github.com/gammazero/nexus/v3 v3.2.2 + github.com/gammazero/workerpool v1.1.3 github.com/gobwas/ws v1.4.0 github.com/stretchr/testify v1.8.4 - github.com/xconnio/wampproto-go v0.0.0-20240530132134-a9a2ca11944a + github.com/xconnio/wampproto-go v0.0.0-20240530202948-a758eb534226 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/fxamacker/cbor/v2 v2.6.0 // indirect + github.com/gammazero/deque v0.2.0 // indirect github.com/gobwas/httphead v0.1.0 // indirect github.com/gobwas/pool v0.2.1 // indirect github.com/gorilla/websocket v1.5.0 // indirect diff --git a/go.sum b/go.sum index 85e1e7d..08a80c3 100644 --- a/go.sum +++ b/go.sum @@ -2,8 +2,12 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fxamacker/cbor/v2 v2.6.0 h1:sU6J2usfADwWlYDAFhZBQ6TnLFBHxgesMrQfQgk1tWA= github.com/fxamacker/cbor/v2 v2.6.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= +github.com/gammazero/deque v0.2.0 h1:SkieyNB4bg2/uZZLxvya0Pq6diUlwx7m2TeT7GAIWaA= +github.com/gammazero/deque v0.2.0/go.mod h1:LFroj8x4cMYCukHJDbxFCkT+r9AndaJnFMuZDV34tuU= github.com/gammazero/nexus/v3 v3.2.2 h1:uEBe4rKIcbBcbdP6XuyKUhnWBXxT0BnJrecG9+yZSTs= github.com/gammazero/nexus/v3 v3.2.2/go.mod h1:55oZwPZFgRFCEjpMj1kdzffiPORKKmRsipSY8BeKRvY= +github.com/gammazero/workerpool v1.1.3 h1:WixN4xzukFoN0XSeXF6puqEqFTl2mECI9S6W44HWy9Q= +github.com/gammazero/workerpool v1.1.3/go.mod h1:wPjyBLDbyKnUn2XwwyD3EEwo9dHutia9/fwNmSHWACc= github.com/gobwas/httphead v0.1.0 h1:exrUm0f4YX0L7EBwZHuCF4GDp8aJfVeBrlLQrs6NqWU= github.com/gobwas/httphead v0.1.0/go.mod h1:O/RXo79gxV8G+RqlR/otEwx4Q36zl9rqC5u12GKvMCM= github.com/gobwas/pool v0.2.1 h1:xfeeEhW7pwmX8nuLVlqbzVc7udMDrwetjEv+TZIz1og= @@ -24,8 +28,8 @@ github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAh github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM= github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg= -github.com/xconnio/wampproto-go v0.0.0-20240530132134-a9a2ca11944a h1:0Vb6+/sNho0zn7kjRsdBvdGylFkz9uZZzeT1RrgKHIU= -github.com/xconnio/wampproto-go v0.0.0-20240530132134-a9a2ca11944a/go.mod h1:BH0AFRLJ9POvVfxsFd9GyvA15U9o0XYQfq8TdkqO2vQ= +github.com/xconnio/wampproto-go v0.0.0-20240530202948-a758eb534226 h1:1UFs+1ev6G1qDVgf5tGqnhsm5e9btuon41ogyrR1QD4= +github.com/xconnio/wampproto-go v0.0.0-20240530202948-a758eb534226/go.mod h1:BH0AFRLJ9POvVfxsFd9GyvA15U9o0XYQfq8TdkqO2vQ= go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI= golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=