option

package
v2.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package option implements the start-up options.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseURLs

func ParseURLs(urlStrings []string) ([]url.URL, error)

ParseURLs parses list of strings to url.URL objects.

func SetFlagsFromEnv added in v2.6.1

func SetFlagsFromEnv(prefix string, fs *pflag.FlagSet) error

SetFlagsFromEnv sets flags from environment variables.

Types

type ClusterOptions

type ClusterOptions struct {
	// Primary members define following URLs to form a cluster.
	ListenPeerURLs           []string          `yaml:"listen-peer-urls"`
	ListenClientURLs         []string          `yaml:"listen-client-urls"`
	AdvertiseClientURLs      []string          `yaml:"advertise-client-urls"`
	InitialAdvertisePeerURLs []string          `yaml:"initial-advertise-peer-urls"`
	InitialCluster           map[string]string `yaml:"initial-cluster"`
	StateFlag                string            `yaml:"state-flag"`
	// Secondary members define URLs to connect to cluster formed by primary members.
	PrimaryListenPeerURLs []string `yaml:"primary-listen-peer-urls"`
	MaxCallSendMsgSize    int      `yaml:"max-call-send-msg-size"`
}

ClusterOptions defines the cluster members.

type Options

type Options struct {

	// Flags from command line only.
	ShowVersion     bool   `yaml:"-"`
	ShowHelp        bool   `yaml:"-"`
	ShowConfig      bool   `yaml:"-"`
	ConfigFile      string `yaml:"-"`
	ForceNewCluster bool   `yaml:"-"`
	SignalUpgrade   bool   `yaml:"-"`

	// meta
	Name                     string            `yaml:"name" env:"EG_NAME"`
	Labels                   map[string]string `yaml:"labels" env:"EG_LABELS"`
	APIAddr                  string            `yaml:"api-addr"`
	TLS                      bool              `yaml:"tls"`
	CertFile                 string            `yaml:"cert-file"`
	KeyFile                  string            `yaml:"key-file"`
	ClientCAFile             string            `yaml:"client-ca-file"`
	Debug                    bool              `yaml:"debug"`
	DisableAccessLog         bool              `yaml:"disable-access-log"`
	InitialObjectConfigFiles []string          `yaml:"initial-object-config-files"`
	ObjectsDumpInterval      string            `yaml:"objects-dump-interval"`
	BasicAuth                map[string]string `yaml:"basic-auth"`

	// cluster options
	UseStandaloneEtcd     bool           `yaml:"use-standalone-etcd"`
	ClusterName           string         `yaml:"cluster-name"`
	ClusterRole           string         `yaml:"cluster-role"`
	ClusterRequestTimeout string         `yaml:"cluster-request-timeout"`
	Cluster               ClusterOptions `yaml:"cluster"`

	// Path.
	HomeDir string `yaml:"home-dir"`
	DataDir string `yaml:"data-dir"`
	WALDir  string `yaml:"wal-dir"`
	LogDir  string `yaml:"log-dir"`

	// Profile.
	CPUProfileFile    string `yaml:"cpu-profile-file"`
	MemoryProfileFile string `yaml:"memory-profile-file"`

	// Status
	StatusUpdateMaxBatchSize int `yaml:"status-update-max-batch-size"`

	// Prepare the items below in advance.
	AbsHomeDir string `yaml:"-"`
	AbsDataDir string `yaml:"-"`
	AbsWALDir  string `yaml:"-"`
	AbsLogDir  string `yaml:"-"`
	// contains filtered or unexported fields
}

Options is the start-up options.

func New

func New() *Options

New creates a default Options.

func (*Options) FlagUsages

func (opt *Options) FlagUsages() string

FlagUsages export original flag usages, see FlagSet.FlagUsages.

func (*Options) GetFirstAdvertiseClientURL

func (opt *Options) GetFirstAdvertiseClientURL() (string, error)

GetFirstAdvertiseClientURL returns the first advertised client url.

func (*Options) GetPeerURLs

func (opt *Options) GetPeerURLs() []string

GetPeerURLs returns URLs listed in cluster.initial-cluster for primary (a.k.a writer) and for secondary (a.k.a reader) the ones listed in cluster.primary-listen-peer-url.

func (*Options) InitialClusterToString

func (opt *Options) InitialClusterToString() string

InitialClusterToString returns initial clusters string representation.

func (*Options) Parse

func (opt *Options) Parse() error

Parse parses all arguments, when the user wants to display version information or view help, we do not execute subsequent logic and return directly.

func (*Options) UseInitialCluster

func (opt *Options) UseInitialCluster() bool

UseInitialCluster returns true if the cluster.initial-cluster is defined. If it is, the ClusterJoinUrls is ignored.

func (*Options) YAML

func (opt *Options) YAML() string

YAML returns yaml string of option, need to be called after calling Parse.

Jump to

Keyboard shortcuts

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