diff --git a/informer/disk/disk.go b/informer/disk/disk.go index 07366de3..3306df23 100644 --- a/informer/disk/disk.go +++ b/informer/disk/disk.go @@ -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. diff --git a/informer/disk/disk_test.go b/informer/disk/disk_test.go index 610f636c..44721354 100644 --- a/informer/disk/disk_test.go +++ b/informer/disk/disk_test.go @@ -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() diff --git a/ipfscluster_test.go b/ipfscluster_test.go index 8acfdd56..710d785f 100644 --- a/ipfscluster_test.go +++ b/ipfscluster_test.go @@ -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 }