many fixes for lint and context.Context usage (#5)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-11-03 02:02:32 +03:00
committed by GitHub
parent 40b0870cf8
commit 8a2b122015
44 changed files with 152 additions and 1175 deletions

View File

@@ -1,6 +1,7 @@
package pool
import (
"context"
"sync"
"time"
@@ -57,7 +58,7 @@ func (p *poolConn) Created() time.Time {
return p.created
}
func (p *pool) Get(addr string, opts ...transport.DialOption) (Conn, error) {
func (p *pool) Get(ctx context.Context, addr string, opts ...transport.DialOption) (Conn, error) {
p.Lock()
conns := p.conns[addr]
@@ -83,7 +84,7 @@ func (p *pool) Get(addr string, opts ...transport.DialOption) (Conn, error) {
p.Unlock()
// create new conn
c, err := p.tr.Dial(addr, opts...)
c, err := p.tr.Dial(ctx, addr, opts...)
if err != nil {
return nil, err
}

View File

@@ -2,6 +2,7 @@
package pool
import (
"context"
"time"
"github.com/unistack-org/micro/v3/network/transport"
@@ -12,7 +13,7 @@ type Pool interface {
// Close the pool
Close() error
// Get a connection
Get(addr string, opts ...transport.DialOption) (Conn, error)
Get(ctx context.Context, addr string, opts ...transport.DialOption) (Conn, error)
// Release the connection
Release(c Conn, status error) error
}