Lines Matching refs:Client
37 // Client represents an RPC Client.
39 // with a single Client, and a Client may be used by
41 type Client struct {
55 // reading of RPC responses for the client side of an RPC session.
56 // The client calls WriteRequest to write a request to the connection
58 // to read responses. The client calls Close when finished with the
71 func (client *Client) send(call *Call) {
72 client.reqMutex.Lock()
73 defer client.reqMutex.Unlock()
76 client.mutex.Lock()
77 if client.shutdown || client.closing {
79 client.mutex.Unlock()
83 seq := client.seq
84 client.seq++
85 client.pending[seq] = call
86 client.mutex.Unlock()
89 client.request.Seq = seq
90 client.request.ServiceMethod = call.ServiceMethod
91 err := client.codec.WriteRequest(&client.request, call.Args)
93 client.mutex.Lock()
94 call = client.pending[seq]
95 delete(client.pending, seq)
96 client.mutex.Unlock()
104 func (client *Client) input() {
109 err = client.codec.ReadResponseHeader(&response)
114 client.mutex.Lock()
115 call := client.pending[seq]
116 delete(client.pending, seq)
117 client.mutex.Unlock()
126 err = client.codec.ReadResponseBody(nil)
135 err = client.codec.ReadResponseBody(nil)
141 err = client.codec.ReadResponseBody(call.Reply)
149 client.reqMutex.Lock()
150 client.mutex.Lock()
151 client.shutdown = true
152 closing := client.closing
160 for _, call := range client.pending {
164 client.mutex.Unlock()
165 client.reqMutex.Unlock()
167 log.Println("rpc: client protocol error:", err)
184 // NewClient returns a new Client to handle requests to the
188 func NewClient(conn io.ReadWriteCloser) *Client {
190 client := &gobClientCodec{conn, gob.NewDecoder(conn), gob.NewEncoder(encBuf), encBuf}
191 return NewClientWithCodec(client)
196 func NewClientWithCodec(codec ClientCodec) *Client {
197 client := &Client{
201 go client.input()
202 return client
236 func DialHTTP(network, address string) (*Client, error) {
242 func DialHTTPPath(network, address, path string) (*Client, error) {
269 func Dial(network, address string) (*Client, error) {
279 func (client *Client) Close() error {
280 client.mutex.Lock()
281 if client.closing {
282 client.mutex.Unlock()
285 client.closing = true
286 client.mutex.Unlock()
287 return client.codec.Close()
294 func (client *Client) Go(serviceMethod string, args interface{}, reply interface{}, done chan *Call) *Call {
311 client.send(call)
316 func (client *Client) Call(serviceMethod string, args interface{}, reply interface{}) error {
317 call := <-client.Go(serviceMethod, args, reply, make(chan *Call, 1)).Done