MCPcopy Create free account
hub / github.com/dadgar/onecache / RPC

Method RPC

onecache/pool.go:325–344  ·  view source on GitHub ↗

RPC is used to make an RPC call to a remote host

(addr net.Addr, method string, args interface{}, reply interface{})

Source from the content-addressed store, hash-verified

323
324// RPC is used to make an RPC call to a remote host
325func (p *connPool) RPC(addr net.Addr, method string, args interface{}, reply interface{}) error {
326 // Get a usable client
327 conn, sc, err := p.getClient(addr)
328 if err != nil {
329 return fmt.Errorf("rpc error: %v", err)
330 }
331
332 // Make the RPC call
333 err = msgpackrpc.CallWithCodec(sc.codec, method, args, reply)
334 if err != nil {
335 sc.Close()
336 p.releaseConn(conn)
337 return fmt.Errorf("rpc error: %v", err)
338 }
339
340 // Done with the connection
341 conn.returnClient(sc)
342 p.releaseConn(conn)
343 return nil
344}
345
346// Reap is used to close conns open over maxTime
347func (p *connPool) reap() {

Callers 1

forwardMethod · 0.80

Calls 4

getClientMethod · 0.95
releaseConnMethod · 0.95
returnClientMethod · 0.80
CloseMethod · 0.45

Tested by

no test coverage detected