mirror of
https://github.com/status-im/status-go.git
synced 2025-01-11 07:07:24 +00:00
eeca435064
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
60 lines
1.1 KiB
Go
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
|
|
}
|