removing name arg from NewInformer

This commit is contained in:
dgrisham 2017-09-01 13:45:55 -06:00
parent 456603f7a8
commit b1356cd33a
3 changed files with 10 additions and 10 deletions

View File

@ -5,6 +5,7 @@
package disk
import (
"errors"
"fmt"
rpc "github.com/hsanjuan/go-libp2p-gorpc"
@ -42,18 +43,17 @@ type Informer struct {
rpcName string
}
// NewInformer returns an initialized Informer that uses the DefaultMetric. The
// name argument is meant as a user-facing identifier for the Informer and can
// be anything.
func NewInformer(name string) *Informer {
// NewInformer returns an initialized Informer that uses the DefaultMetric.
func NewInformer() *Informer {
return &Informer{
name: name,
name: "disk-default",
rpcName: metricToRPC[DefaultMetric],
}
}
// NewInformerWithMetric returns an Informer that uses the input MetricType. The
// name argument has the same purpose as in NewInformer.
// name argument is meant as a user-facing identifier for the Informer and can
// be anything.
func NewInformerWithMetric(metric MetricType, name string) (*Informer, error) {
// check whether specified metric is supported
if rpc, valid := metricToRPC[metric]; valid {
@ -62,7 +62,7 @@ func NewInformerWithMetric(metric MetricType, name string) (*Informer, error) {
rpcName: rpc,
}, nil
}
return nil, fmt.Error("Error creating Informer: invalid MetricType")
return nil, errors.New("Error creating Informer: invalid MetricType")
}
// Name returns the user-facing name of this informer.

View File

@ -56,7 +56,7 @@ func (mock *badRPCService) IPFSFreeSpace(in struct{}, out *int) error {
}
func Test(t *testing.T) {
inf := NewInformer("name")
inf := NewInformer()
defer inf.Shutdown()
if inf.Type != DefaultMetric {
t.Error("careful when changing the name of an informer")
@ -115,7 +115,7 @@ func TestRepoSize(t *testing.T) {
}
func TestWithErrors(t *testing.T) {
inf := NewInformer("name")
inf := NewInformer()
defer inf.Shutdown()
inf.SetClient(badRPCClient(t))
m := inf.GetMetric()

View File

@ -96,7 +96,7 @@ func createComponents(t *testing.T, i int, clusterSecret []byte) (*Config, API,
mon := basic.NewStdPeerMonitor(cfg.MonitoringIntervalSeconds)
alloc := descendalloc.NewAllocator()
disk.MetricTTL = 1 // second
inf := disk.NewInformer("freespace")
inf := disk.NewInformer()
return cfg, api, ipfs, state, tracker, mon, alloc, inf, mock
}