From ab7f33dcda325a0cd5ae9c6c99cec88ca83d1e1a Mon Sep 17 00:00:00 2001 From: a <a@tuxpa.in> Date: Sat, 11 Nov 2023 05:45:54 -0600 Subject: [PATCH] ok --- contrib/client/reconnecting.go | 10 +++++----- contrib/extension/subscription/client.go | 8 ++++---- exports.go | 5 ----- pkg/jrpctest/suites.go | 2 +- pkg/jsonrpc/conn.go | 2 +- 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/contrib/client/reconnecting.go b/contrib/client/reconnecting.go index 162df40..e1b2662 100644 --- a/contrib/client/reconnecting.go +++ b/contrib/client/reconnecting.go @@ -8,11 +8,11 @@ import ( "gfx.cafe/open/jrpc/pkg/jsonrpc" ) -var _ jrpc.StreamingConn = (*Reconnecting)(nil) +var _ jrpc.Conn = (*Reconnecting)(nil) type Reconnecting struct { - dialer func(ctx context.Context) (jrpc.StreamingConn, error) - base jsonrpc.StreamingConn + dialer func(ctx context.Context) (jrpc.Conn, error) + base jsonrpc.Conn alive bool middleware []jsonrpc.Middleware @@ -23,14 +23,14 @@ func (r *Reconnecting) Notify(ctx context.Context, method string, params any) er return r.base.Notify(ctx, method, params) } -func NewReconnecting(dialer func(ctx context.Context) (jrpc.StreamingConn, error)) *Reconnecting { +func NewReconnecting(dialer func(ctx context.Context) (jrpc.Conn, error)) *Reconnecting { r := &Reconnecting{ dialer: dialer, } return r } -func (r *Reconnecting) getClient(ctx context.Context) (jrpc.StreamingConn, error) { +func (r *Reconnecting) getClient(ctx context.Context) (jrpc.Conn, error) { reconnect := func() error { conn, err := r.dialer(ctx) if err != nil { diff --git a/contrib/extension/subscription/client.go b/contrib/extension/subscription/client.go index 22d65d7..a2494c4 100644 --- a/contrib/extension/subscription/client.go +++ b/contrib/extension/subscription/client.go @@ -11,12 +11,12 @@ import ( "gfx.cafe/open/jrpc/pkg/jsonrpc" ) -var _ jsonrpc.StreamingConn = (*WrapClient)(nil) +var _ jsonrpc.Conn = (*WrapClient)(nil) type WrapClient struct { subs map[string]*clientSub - conn jsonrpc.StreamingConn + conn jsonrpc.Conn mu sync.RWMutex } @@ -24,7 +24,7 @@ func (w *WrapClient) Closed() <-chan struct{} { return w.conn.Closed() } -func NewWrapClient(conn jsonrpc.StreamingConn) *WrapClient { +func NewWrapClient(conn jsonrpc.Conn) *WrapClient { return &WrapClient{ subs: map[string]*clientSub{}, conn: conn, @@ -148,7 +148,7 @@ func (c *WrapClient) Notify(ctx context.Context, method string, params any) erro type clientSub struct { engine *WrapClient - conn jsonrpc.StreamingConn + conn jsonrpc.Conn namespace string id string channel reflect.Value diff --git a/exports.go b/exports.go index 7d1953d..f88a121 100644 --- a/exports.go +++ b/exports.go @@ -15,11 +15,6 @@ type Conn interface { jsonrpc.Conn } -// StreamingConn is a conn that supports streaming methods -type StreamingConn interface { - jsonrpc.StreamingConn -} - // Handler is the equivalent of http.Handler, but for jsonrpc. type Handler = jsonrpc.Handler diff --git a/pkg/jrpctest/suites.go b/pkg/jrpctest/suites.go index 2630d2c..a36dacb 100644 --- a/pkg/jrpctest/suites.go +++ b/pkg/jrpctest/suites.go @@ -166,7 +166,7 @@ func RunBasicTestSuite(t *testing.T, args BasicTestSuiteArgs) { } }) makeTest("Notify", func(t *testing.T, server *server.Server, client jsonrpc.Conn) { - if c, ok := client.(jsonrpc.StreamingConn); ok { + if c, ok := client.(jsonrpc.Conn); ok { if err := c.Notify(context.Background(), "test_echo", []any{"hello", 10, &EchoArgs{"world"}}); err != nil { t.Fatal(err) } diff --git a/pkg/jsonrpc/conn.go b/pkg/jsonrpc/conn.go index f0519fe..1c54ac4 100644 --- a/pkg/jsonrpc/conn.go +++ b/pkg/jsonrpc/conn.go @@ -29,5 +29,5 @@ type Notifier interface { } type Mounter interface { - Mount(Handler) + Mount(Middleware) } -- GitLab