good morning!!!!

Skip to content
Snippets Groups Projects
Verified Commit ab7f33dc authored by a's avatar a
Browse files

ok

parent 9e0a8336
No related branches found
No related tags found
No related merge requests found
Pipeline #30862 passed
...@@ -8,11 +8,11 @@ import ( ...@@ -8,11 +8,11 @@ import (
"gfx.cafe/open/jrpc/pkg/jsonrpc" "gfx.cafe/open/jrpc/pkg/jsonrpc"
) )
var _ jrpc.StreamingConn = (*Reconnecting)(nil) var _ jrpc.Conn = (*Reconnecting)(nil)
type Reconnecting struct { type Reconnecting struct {
dialer func(ctx context.Context) (jrpc.StreamingConn, error) dialer func(ctx context.Context) (jrpc.Conn, error)
base jsonrpc.StreamingConn base jsonrpc.Conn
alive bool alive bool
middleware []jsonrpc.Middleware middleware []jsonrpc.Middleware
...@@ -23,14 +23,14 @@ func (r *Reconnecting) Notify(ctx context.Context, method string, params any) er ...@@ -23,14 +23,14 @@ func (r *Reconnecting) Notify(ctx context.Context, method string, params any) er
return r.base.Notify(ctx, method, params) 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{ r := &Reconnecting{
dialer: dialer, dialer: dialer,
} }
return r 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 { reconnect := func() error {
conn, err := r.dialer(ctx) conn, err := r.dialer(ctx)
if err != nil { if err != nil {
......
...@@ -11,12 +11,12 @@ import ( ...@@ -11,12 +11,12 @@ import (
"gfx.cafe/open/jrpc/pkg/jsonrpc" "gfx.cafe/open/jrpc/pkg/jsonrpc"
) )
var _ jsonrpc.StreamingConn = (*WrapClient)(nil) var _ jsonrpc.Conn = (*WrapClient)(nil)
type WrapClient struct { type WrapClient struct {
subs map[string]*clientSub subs map[string]*clientSub
conn jsonrpc.StreamingConn conn jsonrpc.Conn
mu sync.RWMutex mu sync.RWMutex
} }
...@@ -24,7 +24,7 @@ func (w *WrapClient) Closed() <-chan struct{} { ...@@ -24,7 +24,7 @@ func (w *WrapClient) Closed() <-chan struct{} {
return w.conn.Closed() return w.conn.Closed()
} }
func NewWrapClient(conn jsonrpc.StreamingConn) *WrapClient { func NewWrapClient(conn jsonrpc.Conn) *WrapClient {
return &WrapClient{ return &WrapClient{
subs: map[string]*clientSub{}, subs: map[string]*clientSub{},
conn: conn, conn: conn,
...@@ -148,7 +148,7 @@ func (c *WrapClient) Notify(ctx context.Context, method string, params any) erro ...@@ -148,7 +148,7 @@ func (c *WrapClient) Notify(ctx context.Context, method string, params any) erro
type clientSub struct { type clientSub struct {
engine *WrapClient engine *WrapClient
conn jsonrpc.StreamingConn conn jsonrpc.Conn
namespace string namespace string
id string id string
channel reflect.Value channel reflect.Value
......
...@@ -15,11 +15,6 @@ type Conn interface { ...@@ -15,11 +15,6 @@ type Conn interface {
jsonrpc.Conn 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. // Handler is the equivalent of http.Handler, but for jsonrpc.
type Handler = jsonrpc.Handler type Handler = jsonrpc.Handler
......
...@@ -166,7 +166,7 @@ func RunBasicTestSuite(t *testing.T, args BasicTestSuiteArgs) { ...@@ -166,7 +166,7 @@ func RunBasicTestSuite(t *testing.T, args BasicTestSuiteArgs) {
} }
}) })
makeTest("Notify", func(t *testing.T, server *server.Server, client jsonrpc.Conn) { 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 { if err := c.Notify(context.Background(), "test_echo", []any{"hello", 10, &EchoArgs{"world"}}); err != nil {
t.Fatal(err) t.Fatal(err)
} }
......
...@@ -29,5 +29,5 @@ type Notifier interface { ...@@ -29,5 +29,5 @@ type Notifier interface {
} }
type Mounter interface { type Mounter interface {
Mount(Handler) Mount(Middleware)
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment