ipfs-cluster: github.com/ipfs/ipfs-cluster/informer/numpin Index | Files

package numpin

import "github.com/ipfs/ipfs-cluster/informer/numpin"

Package numpin implements an ipfs-cluster informer which determines how many items this peer is pinning and returns it as api.Metric


Package Files

config.go numpin.go


const (
    DefaultMetricTTL = 10 * time.Second

These are the default values for a Config.


var MetricName = "numpin"

MetricName specifies the name of our metric

type Config Uses

type Config struct {

    MetricTTL time.Duration

Config allows to initialize an Informer.

func (*Config) ApplyEnvVars Uses

func (cfg *Config) ApplyEnvVars() error

ApplyEnvVars fills in any Config fields found as environment variables.

func (*Config) ConfigKey Uses

func (cfg *Config) ConfigKey() string

ConfigKey returns a human-friendly identifier for this Config's type.

func (*Config) Default Uses

func (cfg *Config) Default() error

Default initializes this Config with sensible values.

func (*Config) LoadJSON Uses

func (cfg *Config) LoadJSON(raw []byte) error

LoadJSON parses a raw JSON byte-slice as generated by ToJSON().

func (*Config) ToDisplayJSON Uses

func (cfg *Config) ToDisplayJSON() ([]byte, error)

ToDisplayJSON returns JSON config as a string.

func (*Config) ToJSON Uses

func (cfg *Config) ToJSON() ([]byte, error)

ToJSON generates a human-friendly JSON representation of this Config.

func (*Config) Validate Uses

func (cfg *Config) Validate() error

Validate checks that the fields of this configuration have sensible values.

type Informer Uses

type Informer struct {
    // contains filtered or unexported fields

Informer is a simple object to implement the ipfscluster.Informer and Component interfaces

func NewInformer Uses

func NewInformer(cfg *Config) (*Informer, error)

NewInformer returns an initialized Informer.

func (*Informer) GetMetric Uses

func (npi *Informer) GetMetric(ctx context.Context) *api.Metric

GetMetric contacts the IPFSConnector component and requests the `pin ls` command. We return the number of pins in IPFS.

func (*Informer) Name Uses

func (npi *Informer) Name() string

Name returns the name of this informer

func (*Informer) SetClient Uses

func (npi *Informer) SetClient(c *rpc.Client)

SetClient provides us with an rpc.Client which allows contacting other components in the cluster.

func (*Informer) Shutdown Uses

func (npi *Informer) Shutdown(ctx context.Context) error

Shutdown is called on cluster shutdown. We just invalidate any metrics from this point.

Package numpin imports 10 packages (graph) and is imported by 2 packages. Updated 2020-06-07. Refresh now. Tools for package owners.