Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make it easy to use protobuf serializer #23

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions cmd/xconn/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"golang.org/x/exp/slices"
"gopkg.in/yaml.v3"

"github.com/xconnio/wampproto-protobuf/go"
"github.com/xconnio/xconn-go"
)

Expand All @@ -25,8 +24,6 @@ const (

ConfigDir = ".xconn"
ConfigFile = ConfigDir + "/config.yaml"

ProtobufSubProtocol = "wamp.2.protobuf"
)

type cmd struct {
Expand Down Expand Up @@ -96,10 +93,7 @@ func Run(args []string) error {

for _, transport := range config.Transports {
if slices.Contains(transport.Serializers, "protobuf") {
serializer := &wampprotobuf.ProtobufSerializer{}
protobufSpec := xconn.NewWSSerializerSpec(ProtobufSubProtocol, serializer)

if err := server.RegisterSpec(protobufSpec); err != nil {
if err := server.RegisterSpec(xconn.ProtobufSerializerSpec); err != nil {
return err
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require (
github.com/gobwas/ws v1.4.0
github.com/stretchr/testify v1.8.4
github.com/xconnio/wampproto-go v0.0.0-20240630150305-316020c30fb7
github.com/xconnio/wampproto-protobuf/go v0.0.0-20240611092706-1e859744b5a2
github.com/xconnio/wampproto-protobuf/go v0.0.0-20240701141955-e9a1025ec125
golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ 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-20240630150305-316020c30fb7 h1:DrQEqUq14XFZCHXpErCeuOxmCRpFW9Z1hnIb/8Avpk8=
github.com/xconnio/wampproto-go v0.0.0-20240630150305-316020c30fb7/go.mod h1:/b7EyR1X9EkOHPQBJGz1KvdjClo1GsalBGIzjQU5+i4=
github.com/xconnio/wampproto-protobuf/go v0.0.0-20240611092706-1e859744b5a2 h1:1WkQ68ICoin0wTerMn5FrWl+ZbK4XS3/W2Wr86jS9K8=
github.com/xconnio/wampproto-protobuf/go v0.0.0-20240611092706-1e859744b5a2/go.mod h1:SZAkbKSDucIUBrPgcKlT0SzVmktfrsD7OdP1chFR+vw=
github.com/xconnio/wampproto-protobuf/go v0.0.0-20240701141955-e9a1025ec125 h1:JorTUNYHzmMslyT03aJhHFQ+KnnvFaMGT5XB6K1oLLk=
github.com/xconnio/wampproto-protobuf/go v0.0.0-20240701141955-e9a1025ec125/go.mod h1:SZAkbKSDucIUBrPgcKlT0SzVmktfrsD7OdP1chFR+vw=
github.com/xhit/go-str2duration/v2 v2.1.0 h1:lxklc02Drh6ynqX+DdPyp5pCKLUQpRT8bp8Ydu2Bstc=
github.com/xhit/go-str2duration/v2 v2.1.0/go.mod h1:ohY8p+0f07DiV6Em5LKB0s2YpLtXVyJfNt1+BlmyAsU=
go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
Expand Down
3 changes: 3 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/xconnio/wampproto-go/messages"
"github.com/xconnio/wampproto-go/serializers"
wampprotobuf "github.com/xconnio/wampproto-protobuf/go"
)

type (
Expand All @@ -27,6 +28,8 @@ var (
CborWebsocketProtocol, &serializers.CBORSerializer{})
MsgPackSerializerSpec = NewWSSerializerSpec( //nolint:gochecknoglobals
MsgpackWebsocketProtocol, &serializers.MsgPackSerializer{})
ProtobufSerializerSpec = NewWSSerializerSpec( //nolint:gochecknoglobals
ProtobufSubProtocol, &wampprotobuf.ProtobufSerializer{})
)

type BaseSession interface {
Expand Down
1 change: 1 addition & 0 deletions wamp.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ const (
JsonWebsocketProtocol = "wamp.2.json"
MsgpackWebsocketProtocol = "wamp.2.msgpack"
CborWebsocketProtocol = "wamp.2.cbor"
ProtobufSubProtocol = "wamp.2.protobuf"
)
Loading