Dmitry eeca435064 Add rendezvous implementation for discovery interface
Update vendor

Integrate rendezvous into status node

Add a test with failover using rendezvous

Use multiple servers in client

Use discovery V5 by default and test that node can be started with rendezvous discovet

Fix linter

Update rendezvous client to one with instrumented stream

Address feedback

Fix test with updated topic limits

Apply several suggestions

Change log to debug for request errors because we continue execution

Remove web3js after rebase

Update rendezvous package
2018-07-25 15:10:57 +03:00

60 lines
1.1 KiB
Go

package goprocessctx
import (
"context"
"errors"
"time"
goprocess "github.com/jbenet/goprocess"
)
const (
closing = iota
closed
)
type procContext struct {
done <-chan struct{}
which int
}
// OnClosingContext derives a context from a given goprocess that will
// be 'Done' when the process is closing
func OnClosingContext(p goprocess.Process) context.Context {
return &procContext{
done: p.Closing(),
which: closing,
}
}
// OnClosedContext derives a context from a given goprocess that will
// be 'Done' when the process is closed
func OnClosedContext(p goprocess.Process) context.Context {
return &procContext{
done: p.Closed(),
which: closed,
}
}
func (c *procContext) Done() <-chan struct{} {
return c.done
}
func (c *procContext) Deadline() (time.Time, bool) {
return time.Time{}, false
}
func (c *procContext) Err() error {
if c.which == closing {
return errors.New("process closing")
} else if c.which == closed {
return errors.New("process closed")
} else {
panic("unrecognized process context type")
}
}
func (c *procContext) Value(key interface{}) interface{} {
return nil
}