v0.5.7 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2023 License: Apache-2.0, MIT Imports: 8 Imported by: 0




View Source
const (
	// DefaultPathName is the default config dir name.
	DefaultPathName = ".assigner"
	// DefaultPathRoot is the path to the default config dir location.
	DefaultPathRoot = "~/" + DefaultPathName
	// DefaultConfigFile is the filename of the configuration file.
	DefaultConfigFile = "config"
	// EnvDir is the environment variable used to change the path root.

	Version = 1


This section is empty.


func Filename

func Filename(configRoot string) (string, error)

Filename returns the configuration file path given a configuration root directory. If the configuration root directory is empty, use the default.

func Marshal

func Marshal(value interface{}) ([]byte, error)

Marshal configuration with JSON.

func Path

func Path(configRoot, configFile string) (string, error)

Path returns the config file path relative to the configuration root. If an empty string is provided for `configRoot`, the default root is used. If configFile is an absolute path, then configRoot is ignored.

func PathRoot

func PathRoot() (string, error)

PathRoot returns the default configuration root directory.


type Assignment

type Assignment struct {
	// FilterIPs, when true, removes any private, loopback, or unspecified IP
	// addresses from provider and publisher addresses.
	FilterIPs bool
	// PoolInterval is how often to poll indexers for status.
	PollInterval sticfg.Duration
	// IndexerPool is the set of indexers the pool.
	IndexerPool []Indexer
	// Policy configures which peers are allowed and blocked.
	Policy Policy
	// PubSubTopic sets the topic name to which to subscribe for ingestion
	// announcements.
	PubSubTopic string
	// PresetReplication is the number of pre-assigned indexers to assign a
	// publisher to. See Indexer.PresetPeers. Any value < 1 defaults to 1.
	PresetReplication int
	// Replication is the number of indexers to assign each publisher to, when
	// the publisher does not have a preset assignment. A value <= 0 assigns
	// each publisher to one indexer.
	Replication int

Assignment holds addresses of indexers to assign publishers to, policy specifying which peers to allow announce messages from, and related settings.

func NewAssignment

func NewAssignment() Assignment

NewDiscovery returns Discovery with values set to their defaults.

type Config

type Config struct {
	Version    int              // config version.
	Identity   sticfg.Identity  // peer identity.
	Assignment Assignment       // Indexer assignment settings.
	Bootstrap  sticfg.Bootstrap // Peers to connect to for gossip,
	Daemon     Daemon           // daemon settings.
	Logging    Logging          // logging configuration.,
	Peering    sticfg.Peering   // peering service configuration.

Config is used to load config files.

func Init

func Init(out io.Writer) (*Config, error)

func InitWithIdentity

func InitWithIdentity(identity sticfg.Identity) (*Config, error)

func Load

func Load(filePath string) (*Config, error)

Load reads the json-serialized config at the specified path.

func (*Config) Save

func (c *Config) Save(filePath string) error

Save writes the json-serialized config to the specified path.

func (*Config) String

func (c *Config) String() string

String returns a pretty-printed json config.

func (*Config) UpgradeConfig

func (c *Config) UpgradeConfig(filePath string) error

UpgradeConfig upgrades (or downgrades) the config file to the current version. If the config file is at the current version a backup is still created and the config rewritten with any unconfigured values set to their defaults.

type Daemon

type Daemon struct {
	// HTTPAddr is the HTTP host multiaddr for receiving direct announce
	// messages. Set to "none" to disable HTTP hosting.
	HTTPAddr string
	// P2PAddr is the libp2p host multiaddr for receiving announce messages.
	// Set to "none" to disable libp2p hosting.
	P2PAddr string
	// NoResourceManager disables the libp2p resource manager when true.
	NoResourceManager bool

Daemon stores daemon settings.

func NewDaemon

func NewDaemon() Daemon

NewDaemon returns Addresses with values set to their defaults.

type Indexer

type Indexer struct {
	// AdminURL is the base URL for the indexer's admin interface.
	AdminURL string
	// FindURL is the base URL for the indexer's find interface.
	FindURL string
	// IngestURL is the base URL for the indexer's ingest interface.
	IngestURL string
	// PresetPeers is a list of the peer IDs of pre-assigned publishers. A
	// publisher is assigned to n of the indexers that has the publisher in
	// PresetPeers, where n is PresetReplication.
	PresetPeers []string

func NewIndexer

func NewIndexer() Indexer

type Logging

type Logging struct {
	// Level sets the log level for all loggers that do not have a setting in
	// Loggers. The default value is "info".
	Level string
	// Loggers sets log levels for individual loggers.
	Loggers map[string]string

Logging configures overall and logger-specific log levels. Level values are case-insensitive and include the following in order of importance: "fatal", "panic", "dpanic", ""error", "warn", "info", "debug"

func NewLogging

func NewLogging() Logging

NewLogging returns Logging with values set to their defaults.

type Policy

type Policy struct {
	// Allow is either false or true, and determines whether a peer is allowed
	// (true) or is blocked (false), by default.
	Allow bool
	// Except is a list of peer IDs that are exceptions to the Allow policy.
	// If Allow is true, then all peers are allowed except those listed in
	// Except. If Allow is false, then no peers are allowed except those listed
	// in Except. in other words, Allow=true means that Except is a deny-list
	// and Allow=false means that Except is an allow-list.
	Except []string

Policy configures which peers are allowed and which are blocked. Announce messages are accepted from allowed peers and the publisher assigned to an indexer. Announce messagees from blocked peers are ignored.

func NewPolicy

func NewPolicy() Policy

NewPolicy returns Policy with values set to their defaults.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL