Skip to content

Commit d241493

Browse files
committed
jsonrpc2: export Handler and Canceler
1 parent c145907 commit d241493

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

jsonrpc2.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ type Canceler func(context.Context, *Conn, *Request)
4949
// Conn is a JSON RPC 2 client server connection.
5050
// Conn is bidirectional; it does not have a designated server or client end.
5151
type Conn struct {
52-
handler Handler
53-
canceler Canceler
52+
Handler Handler
53+
Canceler Canceler
5454
logger *zap.Logger
5555
capacity int
5656
overloaded bool
@@ -71,14 +71,14 @@ type Options func(*Conn)
7171
// WithHandler apply custom hander to Conn.
7272
func WithHandler(h Handler) Options {
7373
return func(c *Conn) {
74-
c.handler = h
74+
c.Handler = h
7575
}
7676
}
7777

7878
// WithCanceler apply custom canceler to Conn.
7979
func WithCanceler(canceler Canceler) Options {
8080
return func(c *Conn) {
81-
c.canceler = canceler
81+
c.Canceler = canceler
8282
}
8383
}
8484

@@ -139,13 +139,13 @@ func NewConn(ctx context.Context, s Stream, options ...Options) *Conn {
139139
opt(conn)
140140
}
141141

142-
if conn.handler == nil {
142+
if conn.Handler == nil {
143143
// the default handler reports a method error
144-
conn.handler = defaultHandler
144+
conn.Handler = defaultHandler
145145
}
146-
if conn.canceler == nil {
146+
if conn.Canceler == nil {
147147
// the default canceller does nothing
148-
conn.canceler = defaultCanceler
148+
conn.Canceler = defaultCanceler
149149
}
150150

151151
go func() {
@@ -234,7 +234,7 @@ func (c *Conn) Call(ctx context.Context, method string, params, result interface
234234
return nil
235235

236236
case <-ctx.Done():
237-
c.canceler(ctx, c, req)
237+
c.Canceler(ctx, c, req)
238238
return ctx.Err()
239239
}
240240
}
@@ -369,7 +369,7 @@ func (c *Conn) Run(ctx context.Context) (err error) {
369369
if e.ctx.Err() != nil {
370370
continue
371371
}
372-
c.handler(e.ctx, e.c, e.r)
372+
c.Handler(e.ctx, e.c, e.r)
373373
}
374374
}()
375375

0 commit comments

Comments
 (0)