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

package disk

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

Package disk implements an ipfs-cluster informer which can provide different disk-related metrics from the IPFS daemon as an api.Metric.

Index

Package Files

config.go disk.go

Constants

const (
    DefaultMetricTTL  = 30 * time.Second
    DefaultMetricType = MetricFreeSpace
)

Default values for disk Config

const (
    // MetricFreeSpace provides the available space reported by IPFS
    MetricFreeSpace = iota
    // MetricRepoSize provides the used space reported by IPFS
    MetricRepoSize
)

type Config Uses

type Config struct {
    config.Saver

    MetricTTL  time.Duration
    MetricType MetricType
}

Config is used to initialize an Informer and customize the type and parameters of the metric it produces.

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 type of Metric.

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 reads the fields of this Config from a JSON byteslice 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() (raw []byte, err error)

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

func (*Config) Validate Uses

func (cfg *Config) Validate() error

Validate checks that the fields of this Config have working values, at least in appearance.

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 using the given InformerConfig.

func (*Informer) GetMetric Uses

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

GetMetric returns the metric obtained by this Informer.

func (*Informer) Name Uses

func (disk *Informer) Name() string

Name returns the user-facing name of this informer.

func (*Informer) SetClient Uses

func (disk *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 (disk *Informer) Shutdown(ctx context.Context) error

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

type MetricType Uses

type MetricType int

MetricType identifies the type of metric to fetch from the IPFS daemon.

func (MetricType) String Uses

func (t MetricType) String() string

String returns a string representation for MetricType.

Package disk imports 11 packages (graph) and is imported by 1 packages. Updated 2020-06-07. Refresh now. Tools for package owners.