Skip to content

Commit

Permalink
set limit when init client
Browse files Browse the repository at this point in the history
  • Loading branch information
mmsqe committed Feb 16, 2023
1 parent d7c8673 commit 38a859e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 5 additions & 1 deletion rpc/client.go
Expand Up @@ -254,7 +254,7 @@ func newClient(initctx context.Context, connect reconnectFunc) (*Client, error)
return c, nil
}

func initClient(conn ServerCodec, idgen func() ID, services *serviceRegistry) *Client {
func initClientWithBatchLimits(conn ServerCodec, idgen func() ID, services *serviceRegistry, limit int, size int) *Client {
_, isHTTP := conn.(*httpConn)
c := &Client{
isHTTP: isHTTP,
Expand All @@ -277,6 +277,10 @@ func initClient(conn ServerCodec, idgen func() ID, services *serviceRegistry) *C
return c
}

func initClient(conn ServerCodec, idgen func() ID, services *serviceRegistry) *Client {
return initClientWithBatchLimits(conn, idgen, services, 0, 0)
}

// RegisterName creates a service for the given receiver type under the given name. When no
// methods on the given receiver match the criteria to be either a RPC method or a
// subscription an error is returned. Otherwise a new service is created and added to the
Expand Down
3 changes: 1 addition & 2 deletions rpc/server.go
Expand Up @@ -94,8 +94,7 @@ func (s *Server) ServeCodec(codec ServerCodec, options CodecOption) {
}
defer s.untrackCodec(codec)

c := initClient(codec, s.idgen, &s.services)
c.SetBatchLimits(s.batchRequestLimit, s.batchResponseMaxSize)
c := initClientWithBatchLimits(codec, s.idgen, &s.services, s.batchRequestLimit, s.batchResponseMaxSize)
<-codec.closed()
c.Close()
}
Expand Down

0 comments on commit 38a859e

Please sign in to comment.