This commit is contained in:
crusader 2018-04-19 20:58:24 +09:00
parent 5e7c06fad3
commit 19bd7a7b85

View File

@ -20,6 +20,7 @@ type Client struct {
Codec protocol.ClientCodec Codec protocol.ClientCodec
RPCInvoker registry.RPCInvoker RPCInvoker registry.RPCInvoker
Name string Name string
PendingRequests int
stopChan chan struct{} stopChan chan struct{}
stopWg sync.WaitGroup stopWg sync.WaitGroup
@ -47,11 +48,16 @@ func (c *Client) Start() error {
return fmt.Errorf("%s Codec is not valid", c.logHeader()) return fmt.Errorf("%s Codec is not valid", c.logHeader())
} }
if 0 >= c.PendingRequests {
c.PendingRequests = 1024
}
readChan, writeChan, err := c.Connector.Connect() readChan, writeChan, err := c.Connector.Connect()
if nil != err { if nil != err {
return err return err
} }
c.requestQueueChan = make(chan *requestState, c.PendingRequests)
c.stopChan = make(chan struct{}) c.stopChan = make(chan struct{})
c.stopWg.Add(1) c.stopWg.Add(1)