Skip to content

Commit

Permalink
some cleanups in proxy code (#944)
Browse files Browse the repository at this point in the history
  • Loading branch information
FZambia authored Feb 17, 2025
1 parent b92f578 commit 8547567
Show file tree
Hide file tree
Showing 11 changed files with 8 additions and 56 deletions.
2 changes: 1 addition & 1 deletion internal/proxy/connect_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ func (p *GRPCConnectProxy) UseBase64() bool {
func (p *GRPCConnectProxy) ProxyConnect(ctx context.Context, req *proxyproto.ConnectRequest) (*proxyproto.ConnectResponse, error) {
ctx, cancel := context.WithTimeout(ctx, p.config.Timeout.ToDuration())
defer cancel()
return p.client.Connect(grpcRequestContext(ctx, p.config), req, grpc.ForceCodec(grpcCodec))
return p.client.Connect(grpcRequestContext(ctx, p.config), req)
}
3 changes: 0 additions & 3 deletions internal/proxy/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

"github.com/centrifugal/centrifugo/v6/internal/clientcontext"
"github.com/centrifugal/centrifugo/v6/internal/middleware"
"github.com/centrifugal/centrifugo/v6/internal/proxyproto"

"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
Expand All @@ -18,8 +17,6 @@ import (
"google.golang.org/grpc/metadata"
)

var grpcCodec = proxyproto.Codec{}

type rpcCredentials struct {
key string
value string
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/publish_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewGRPCPublishProxy(name string, p Config) (*GRPCPublishProxy, error) {
func (p *GRPCPublishProxy) ProxyPublish(ctx context.Context, req *proxyproto.PublishRequest) (*proxyproto.PublishResponse, error) {
ctx, cancel := context.WithTimeout(ctx, p.config.Timeout.ToDuration())
defer cancel()
return p.client.Publish(grpcRequestContext(ctx, p.config), req, grpc.ForceCodec(grpcCodec))
return p.client.Publish(grpcRequestContext(ctx, p.config), req)
}

// Protocol ...
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/refresh_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewGRPCRefreshProxy(name string, p Config) (*GRPCRefreshProxy, error) {
func (p *GRPCRefreshProxy) ProxyRefresh(ctx context.Context, req *proxyproto.RefreshRequest) (*proxyproto.RefreshResponse, error) {
ctx, cancel := context.WithTimeout(ctx, p.config.Timeout.ToDuration())
defer cancel()
return p.client.Refresh(grpcRequestContext(ctx, p.config), req, grpc.ForceCodec(grpcCodec))
return p.client.Refresh(grpcRequestContext(ctx, p.config), req)
}

// Name ...
Expand Down
7 changes: 0 additions & 7 deletions internal/proxy/refresh_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ import (
"github.com/centrifugal/centrifugo/v6/internal/proxyproto"
)

// RefreshRequestHTTP ...
type RefreshRequestHTTP struct {
baseRequestHTTP

UserID string `json:"user"`
}

// HTTPRefreshProxy ...
type HTTPRefreshProxy struct {
config Config
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/rpc_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewGRPCRPCProxy(name string, p Config) (*GRPCRPCProxy, error) {
func (p *GRPCRPCProxy) ProxyRPC(ctx context.Context, req *proxyproto.RPCRequest) (*proxyproto.RPCResponse, error) {
ctx, cancel := context.WithTimeout(ctx, p.config.Timeout.ToDuration())
defer cancel()
return p.client.RPC(grpcRequestContext(ctx, p.config), req, grpc.ForceCodec(grpcCodec))
return p.client.RPC(grpcRequestContext(ctx, p.config), req)
}

// Protocol ...
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/sub_refresh_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewGRPCSubRefreshProxy(name string, p Config) (*GRPCSubRefreshProxy, error)
func (p *GRPCSubRefreshProxy) ProxySubRefresh(ctx context.Context, req *proxyproto.SubRefreshRequest) (*proxyproto.SubRefreshResponse, error) {
ctx, cancel := context.WithTimeout(ctx, p.config.Timeout.ToDuration())
defer cancel()
return p.client.SubRefresh(grpcRequestContext(ctx, p.config), req, grpc.ForceCodec(grpcCodec))
return p.client.SubRefresh(grpcRequestContext(ctx, p.config), req)
}

// Protocol ...
Expand Down
8 changes: 0 additions & 8 deletions internal/proxy/sub_refresh_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,6 @@ import (
"github.com/centrifugal/centrifugo/v6/internal/proxyproto"
)

// SubRefreshRequestHTTP ...
type SubRefreshRequestHTTP struct {
baseRequestHTTP

UserID string `json:"user"`
Channel string `json:"channel"`
}

// HTTPSubRefreshProxy ...
type HTTPSubRefreshProxy struct {
config Config
Expand Down
2 changes: 1 addition & 1 deletion internal/proxy/subscribe_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func NewGRPCSubscribeProxy(name string, p Config) (*GRPCSubscribeProxy, error) {
func (p *GRPCSubscribeProxy) ProxySubscribe(ctx context.Context, req *proxyproto.SubscribeRequest) (*proxyproto.SubscribeResponse, error) {
ctx, cancel := context.WithTimeout(ctx, p.config.Timeout.ToDuration())
defer cancel()
return p.client.Subscribe(grpcRequestContext(ctx, p.config), req, grpc.ForceCodec(grpcCodec))
return p.client.Subscribe(grpcRequestContext(ctx, p.config), req)
}

// Protocol ...
Expand Down
4 changes: 2 additions & 2 deletions internal/proxy/subscribe_stream_grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ func NewSubscribeStreamProxy(name string, p Config) (*SubscribeStreamProxy, erro

// SubscribeUnidirectional ...
func (p *SubscribeStreamProxy) SubscribeUnidirectional(ctx context.Context, req *proxyproto.SubscribeRequest) (proxyproto.CentrifugoProxy_SubscribeUnidirectionalClient, error) {
return p.client.SubscribeUnidirectional(grpcRequestContext(ctx, p.config), req, grpc.ForceCodec(grpcCodec))
return p.client.SubscribeUnidirectional(grpcRequestContext(ctx, p.config), req)
}

// SubscribeBidirectional ...
func (p *SubscribeStreamProxy) SubscribeBidirectional(ctx context.Context) (proxyproto.CentrifugoProxy_SubscribeBidirectionalClient, error) {
return p.client.SubscribeBidirectional(grpcRequestContext(ctx, p.config), grpc.ForceCodec(grpcCodec))
return p.client.SubscribeBidirectional(grpcRequestContext(ctx, p.config))
}
30 changes: 0 additions & 30 deletions internal/proxyproto/codec.go

This file was deleted.

0 comments on commit 8547567

Please sign in to comment.