peer.DoDrpc method
This commit is contained in:
parent
1206071dd6
commit
e9f23e2dd9
@ -41,6 +41,7 @@ type Peer interface {
|
|||||||
|
|
||||||
AcquireDrpcConn(ctx context.Context) (drpc.Conn, error)
|
AcquireDrpcConn(ctx context.Context) (drpc.Conn, error)
|
||||||
ReleaseDrpcConn(conn drpc.Conn)
|
ReleaseDrpcConn(conn drpc.Conn)
|
||||||
|
DoDrpc(ctx context.Context, do func(conn drpc.Conn) error) error
|
||||||
|
|
||||||
IsClosed() bool
|
IsClosed() bool
|
||||||
|
|
||||||
@ -95,6 +96,15 @@ func (p *peer) ReleaseDrpcConn(conn drpc.Conn) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *peer) DoDrpc(ctx context.Context, do func(conn drpc.Conn) error) error {
|
||||||
|
conn, err := p.AcquireDrpcConn(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer p.ReleaseDrpcConn(conn)
|
||||||
|
return do(conn)
|
||||||
|
}
|
||||||
|
|
||||||
func (p *peer) acceptLoop() {
|
func (p *peer) acceptLoop() {
|
||||||
var exitErr error
|
var exitErr error
|
||||||
defer func() {
|
defer func() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user