-
Notifications
You must be signed in to change notification settings - Fork 0
/
nilDiscoverer.go
40 lines (30 loc) · 1010 Bytes
/
nilDiscoverer.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package discovery
import (
"context"
"github.com/bhagyaraj1208117/andes-communication-go/p2p"
)
var _ p2p.PeerDiscoverer = (*NilDiscoverer)(nil)
var _ p2p.Reconnecter = (*NilDiscoverer)(nil)
const nilName = "no peer discovery"
// NilDiscoverer is the non-functional peer discoverer aimed to be used when peer discovery options are all disabled
type NilDiscoverer struct {
}
// NewNilDiscoverer creates a new NullDiscoverer implementation
func NewNilDiscoverer() *NilDiscoverer {
return &NilDiscoverer{}
}
// Bootstrap will return nil. There is no implementation.
func (nd *NilDiscoverer) Bootstrap() error {
return nil
}
// Name returns a message which says no peer discovery mechanism is used
func (nd *NilDiscoverer) Name() string {
return nilName
}
// ReconnectToNetwork does nothing
func (nd *NilDiscoverer) ReconnectToNetwork(_ context.Context) {
}
// IsInterfaceNil returns true if there is no value under the interface
func (nd *NilDiscoverer) IsInterfaceNil() bool {
return nd == nil
}