diff --git a/contrib/client/reconnecting.go b/contrib/client/reconnecting.go index 162df40c0790c51c99b09a897bed0d8c03a40cd9..e1b2662d766016d262a8191b0c061a933d079961 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 22d65d703f28e0ec73530b8c757b9d080d85e662..a2494c460f4c34cea3088568901a81c40c08d316 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 7d1953d0b7f1ce9865f2fef98bbbc72141ee73e1..f88a121351969fc5b01fa07d9bf4a966db342151 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 2630d2cf775dec4163211e9bcf3f1a186e00ae66..a36dacb297c8514fd7b68c6f08e26340cd5b10d3 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 f0519feacb4e55f26caf7d22b21df405da6895ca..1c54ac4ebb7275c1aa8d6d3707dac2bce4972edc 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) }