Commit e2481a24 authored by rht's avatar rht
Browse files

Replace ctxgroup.ContextGroup -> goprocess.Process



License: MIT
Signed-off-by: default avatarrht <rhtbot@gmail.com>
parent 8ad672a7
...@@ -5,11 +5,12 @@ import ( ...@@ -5,11 +5,12 @@ import (
"io" "io"
"net" "net"
ctxgroup "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net" manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
reuseport "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-reuseport" reuseport "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-reuseport"
tec "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-temp-err-catcher" tec "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-temp-err-catcher"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
ic "github.com/ipfs/go-ipfs/p2p/crypto" ic "github.com/ipfs/go-ipfs/p2p/crypto"
...@@ -31,7 +32,7 @@ type listener struct { ...@@ -31,7 +32,7 @@ type listener struct {
wrapper ConnWrapper wrapper ConnWrapper
cg ctxgroup.ContextGroup proc goprocess.Process
} }
func (l *listener) teardown() error { func (l *listener) teardown() error {
...@@ -41,7 +42,7 @@ func (l *listener) teardown() error { ...@@ -41,7 +42,7 @@ func (l *listener) teardown() error {
func (l *listener) Close() error { func (l *listener) Close() error {
log.Debugf("listener closing: %s %s", l.local, l.Multiaddr()) log.Debugf("listener closing: %s %s", l.local, l.Multiaddr())
return l.cg.Close() return l.proc.Close()
} }
func (l *listener) String() string { func (l *listener) String() string {
...@@ -157,9 +158,9 @@ func Listen(ctx context.Context, addr ma.Multiaddr, local peer.ID, sk ic.PrivKey ...@@ -157,9 +158,9 @@ func Listen(ctx context.Context, addr ma.Multiaddr, local peer.ID, sk ic.PrivKey
Listener: ml, Listener: ml,
local: local, local: local,
privk: sk, privk: sk,
cg: ctxgroup.WithContext(ctx), proc: goprocessctx.WithContext(ctx),
} }
l.cg.SetTeardown(l.teardown) l.proc.SetTeardown(l.teardown)
log.Debugf("Conn Listener on %s", l.Multiaddr()) log.Debugf("Conn Listener on %s", l.Multiaddr())
log.Event(ctx, "swarmListen", l) log.Event(ctx, "swarmListen", l)
......
...@@ -6,8 +6,8 @@ import ( ...@@ -6,8 +6,8 @@ import (
conn "github.com/ipfs/go-ipfs/p2p/net/conn" conn "github.com/ipfs/go-ipfs/p2p/net/conn"
peer "github.com/ipfs/go-ipfs/p2p/peer" peer "github.com/ipfs/go-ipfs/p2p/peer"
ctxgroup "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
) )
...@@ -80,8 +80,8 @@ type Network interface { ...@@ -80,8 +80,8 @@ type Network interface {
// use the known local interfaces. // use the known local interfaces.
InterfaceListenAddresses() ([]ma.Multiaddr, error) InterfaceListenAddresses() ([]ma.Multiaddr, error)
// CtxGroup returns the network's contextGroup // Process returns the network's Process
CtxGroup() ctxgroup.ContextGroup Process() goprocess.Process
} }
// Dialer represents a service that can dial out to peers // Dialer represents a service that can dial out to peers
......
...@@ -13,8 +13,9 @@ import ( ...@@ -13,8 +13,9 @@ import (
p2putil "github.com/ipfs/go-ipfs/p2p/test/util" p2putil "github.com/ipfs/go-ipfs/p2p/test/util"
testutil "github.com/ipfs/go-ipfs/util/testutil" testutil "github.com/ipfs/go-ipfs/util/testutil"
ctxgroup "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
) )
...@@ -31,7 +32,7 @@ type mocknet struct { ...@@ -31,7 +32,7 @@ type mocknet struct {
linkDefaults LinkOptions linkDefaults LinkOptions
cg ctxgroup.ContextGroup // for Context closing proc goprocess.Process // for Context closing
sync.RWMutex sync.RWMutex
} }
...@@ -40,7 +41,7 @@ func New(ctx context.Context) Mocknet { ...@@ -40,7 +41,7 @@ func New(ctx context.Context) Mocknet {
nets: map[peer.ID]*peernet{}, nets: map[peer.ID]*peernet{},
hosts: map[peer.ID]*bhost.BasicHost{}, hosts: map[peer.ID]*bhost.BasicHost{},
links: map[peer.ID]map[peer.ID]map[*link]struct{}{}, links: map[peer.ID]map[peer.ID]map[*link]struct{}{},
cg: ctxgroup.WithContext(ctx), proc: goprocessctx.WithContext(ctx),
} }
} }
......
...@@ -9,8 +9,9 @@ import ( ...@@ -9,8 +9,9 @@ import (
inet "github.com/ipfs/go-ipfs/p2p/net" inet "github.com/ipfs/go-ipfs/p2p/net"
peer "github.com/ipfs/go-ipfs/p2p/peer" peer "github.com/ipfs/go-ipfs/p2p/peer"
ctxgroup "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
) )
...@@ -34,7 +35,7 @@ type peernet struct { ...@@ -34,7 +35,7 @@ type peernet struct {
notifmu sync.RWMutex notifmu sync.RWMutex
notifs map[inet.Notifiee]struct{} notifs map[inet.Notifiee]struct{}
cg ctxgroup.ContextGroup proc goprocess.Process
sync.RWMutex sync.RWMutex
} }
...@@ -57,7 +58,7 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey, ...@@ -57,7 +58,7 @@ func newPeernet(ctx context.Context, m *mocknet, k ic.PrivKey,
mocknet: m, mocknet: m,
peer: p, peer: p,
ps: ps, ps: ps,
cg: ctxgroup.WithContext(ctx), proc: goprocessctx.WithContext(ctx),
connsByPeer: map[peer.ID]map[*conn]struct{}{}, connsByPeer: map[peer.ID]map[*conn]struct{}{},
connsByLink: map[*link]map[*conn]struct{}{}, connsByLink: map[*link]map[*conn]struct{}{},
...@@ -223,9 +224,9 @@ func (pn *peernet) removeConn(c *conn) { ...@@ -223,9 +224,9 @@ func (pn *peernet) removeConn(c *conn) {
delete(cs, c) delete(cs, c)
} }
// CtxGroup returns the network's ContextGroup // Process returns the network's Process
func (pn *peernet) CtxGroup() ctxgroup.ContextGroup { func (pn *peernet) Process() goprocess.Process {
return pn.cg return pn.proc
} }
// LocalPeer the network's LocalPeer // LocalPeer the network's LocalPeer
......
...@@ -14,11 +14,12 @@ import ( ...@@ -14,11 +14,12 @@ import (
peer "github.com/ipfs/go-ipfs/p2p/peer" peer "github.com/ipfs/go-ipfs/p2p/peer"
eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog" eventlog "github.com/ipfs/go-ipfs/thirdparty/eventlog"
ctxgroup "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
ps "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream" ps "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream"
pst "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport" pst "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport"
psy "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport/yamux" psy "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-peerstream/transport/yamux"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
goprocessctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
prom "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus" prom "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/prometheus/client_golang/prometheus"
mafilter "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/multiaddr-filter" mafilter "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/whyrusleeping/multiaddr-filter"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
...@@ -63,8 +64,8 @@ type Swarm struct { ...@@ -63,8 +64,8 @@ type Swarm struct {
// filters for addresses that shouldnt be dialed // filters for addresses that shouldnt be dialed
Filters *filter.Filters Filters *filter.Filters
cg ctxgroup.ContextGroup proc goprocess.Process
bwc metrics.Reporter bwc metrics.Reporter
} }
// NewSwarm constructs a Swarm, with a Chan. // NewSwarm constructs a Swarm, with a Chan.
...@@ -80,7 +81,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr, ...@@ -80,7 +81,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
swarm: ps.NewSwarm(PSTransport), swarm: ps.NewSwarm(PSTransport),
local: local, local: local,
peers: peers, peers: peers,
cg: ctxgroup.WithContext(ctx), proc: goprocessctx.WithContext(ctx),
dialT: DialTimeout, dialT: DialTimeout,
notifs: make(map[inet.Notifiee]ps.Notifiee), notifs: make(map[inet.Notifiee]ps.Notifiee),
bwc: bwc, bwc: bwc,
...@@ -88,7 +89,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr, ...@@ -88,7 +89,7 @@ func NewSwarm(ctx context.Context, listenAddrs []ma.Multiaddr,
} }
// configure Swarm // configure Swarm
s.cg.SetTeardown(s.teardown) s.proc.SetTeardown(s.teardown)
s.SetConnHandler(nil) // make sure to setup our own conn handler. s.SetConnHandler(nil) // make sure to setup our own conn handler.
// setup swarm metrics // setup swarm metrics
...@@ -111,8 +112,6 @@ func (s *Swarm) AddAddrFilter(f string) error { ...@@ -111,8 +112,6 @@ func (s *Swarm) AddAddrFilter(f string) error {
s.Filters.AddDialFilter(m) s.Filters.AddDialFilter(m)
return nil return nil
} }
// CtxGroup returns the Context Group of the swarm
func filterAddrs(listenAddrs []ma.Multiaddr) ([]ma.Multiaddr, error) { func filterAddrs(listenAddrs []ma.Multiaddr) ([]ma.Multiaddr, error) {
if len(listenAddrs) > 0 { if len(listenAddrs) > 0 {
filtered := addrutil.FilterUsableAddrs(listenAddrs) filtered := addrutil.FilterUsableAddrs(listenAddrs)
...@@ -124,7 +123,6 @@ func filterAddrs(listenAddrs []ma.Multiaddr) ([]ma.Multiaddr, error) { ...@@ -124,7 +123,6 @@ func filterAddrs(listenAddrs []ma.Multiaddr) ([]ma.Multiaddr, error) {
return listenAddrs, nil return listenAddrs, nil
} }
// CtxGroup returns the Context Group of the swarm
func (s *Swarm) Listen(addrs ...ma.Multiaddr) error { func (s *Swarm) Listen(addrs ...ma.Multiaddr) error {
addrs, err := filterAddrs(addrs) addrs, err := filterAddrs(addrs)
if err != nil { if err != nil {
...@@ -134,14 +132,14 @@ func (s *Swarm) Listen(addrs ...ma.Multiaddr) error { ...@@ -134,14 +132,14 @@ func (s *Swarm) Listen(addrs ...ma.Multiaddr) error {
return s.listen(addrs) return s.listen(addrs)
} }
// CtxGroup returns the Context Group of the swarm // Process returns the Process of the swarm
func (s *Swarm) CtxGroup() ctxgroup.ContextGroup { func (s *Swarm) Process() goprocess.Process {
return s.cg return s.proc
} }
// Close stops the Swarm. // Close stops the Swarm.
func (s *Swarm) Close() error { func (s *Swarm) Close() error {
return s.cg.Close() return s.proc.Close()
} }
// StreamSwarm returns the underlying peerstream.Swarm // StreamSwarm returns the underlying peerstream.Swarm
......
...@@ -8,8 +8,8 @@ import ( ...@@ -8,8 +8,8 @@ import (
metrics "github.com/ipfs/go-ipfs/metrics" metrics "github.com/ipfs/go-ipfs/metrics"
inet "github.com/ipfs/go-ipfs/p2p/net" inet "github.com/ipfs/go-ipfs/p2p/net"
ctxgroup "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context" context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
) )
...@@ -43,9 +43,9 @@ func (n *Network) DialPeer(ctx context.Context, p peer.ID) (inet.Conn, error) { ...@@ -43,9 +43,9 @@ func (n *Network) DialPeer(ctx context.Context, p peer.ID) (inet.Conn, error) {
return inet.Conn(sc), nil return inet.Conn(sc), nil
} }
// CtxGroup returns the network's ContextGroup // Process returns the network's Process
func (n *Network) CtxGroup() ctxgroup.ContextGroup { func (n *Network) Process() goprocess.Process {
return n.cg return n.proc
} }
// Swarm returns the network's peerstream.Swarm // Swarm returns the network's peerstream.Swarm
...@@ -100,7 +100,7 @@ func (n *Network) close() error { ...@@ -100,7 +100,7 @@ func (n *Network) close() error {
// Close calls the ContextCloser func // Close calls the ContextCloser func
func (n *Network) Close() error { func (n *Network) Close() error {
return n.Swarm().cg.Close() return n.Swarm().proc.Close()
} }
// Listen tells the network to start listening on given multiaddrs. // Listen tells the network to start listening on given multiaddrs.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment