process

package
v0.0.0-...-0123b22 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 43 Imported by: 6

Documentation

Overview

Deprecated: Use storj.io/common/process instead.

Index

Constants

View Source
const DefaultCfgFilename = "config.yaml"

DefaultCfgFilename is the default filename used for storing a configuration.

Variables

View Source
var (
	// Error is a process error class.
	Error = errs.Class("process")
)

Functions

func AtomicLevel

func AtomicLevel(cmd *cobra.Command) *zap.AtomicLevel

AtomicLevel returns the appropriate zap.AtomicLevel for ExecuteWithConfig commands.

func Bind

func Bind(cmd *cobra.Command, config interface{}, opts ...cfgstruct.BindOpt)

Bind sets flags on a command that match the configuration struct 'config'. It ensures that the config has all of the values loaded into it when the command runs.

func Ctx

Ctx returns the appropriate context.Context for ExecuteWithConfig commands.

func Exec

func Exec(cmd *cobra.Command)

Exec runs a Cobra command. If a "config-dir" flag is defined it will be parsed and loaded using viper.

func ExecCustomDebug

func ExecCustomDebug(cmd *cobra.Command)

ExecCustomDebug runs default configuration except the default debug is disabled.

func ExecWithCustomConfig

func ExecWithCustomConfig(cmd *cobra.Command, debugEnabled bool, loadConfig func(cmd *cobra.Command, vip *viper.Viper) error)

ExecWithCustomConfig runs a Cobra command. Custom configuration can be loaded.

func ExecWithCustomConfigAndLogger

func ExecWithCustomConfigAndLogger(cmd *cobra.Command, debugEnabled bool, loadConfig func(cmd *cobra.Command, vip *viper.Viper) error, loggerFactory func(*zap.Logger) *zap.Logger)

ExecWithCustomConfigAndLogger runs a Cobra command with a custom logger. Custom configuration can be loaded.

func ExecWithCustomOptions

func ExecWithCustomOptions(cmd *cobra.Command, opts ExecOptions)

ExecWithCustomOptions runs a Cobra command with custom options.

func InitEventStatPublisher

func InitEventStatPublisher(ctx context.Context, log *zap.Logger, r *eventstat.Registry, customization func(*eventstat.ClientOpts)) error

InitEventStatPublisher initializes telemetry reporting.

func InitEventStatPublisherWithHostname

func InitEventStatPublisherWithHostname(ctx context.Context, log *zap.Logger, r *eventstat.Registry) error

InitEventStatPublisherWithHostname initializes telemetry reporting, using the hostname as the telemetry instance ID. ctx should be cancelled to stop the telemetry publisher.

func InitMetrics

func InitMetrics(ctx context.Context, log *zap.Logger, r *monkit.Registry, instanceID string) (err error)

InitMetrics initializes telemetry reporting. Makes a telemetry.Client and calls its Run() method in a goroutine.

func InitMetricsWithCertPath

func InitMetricsWithCertPath(ctx context.Context, log *zap.Logger, r *monkit.Registry, certPath string) error

InitMetricsWithCertPath initializes telemetry reporting, using the node ID corresponding to the given certificate as the telemetry instance ID.

func InitMetricsWithHostname

func InitMetricsWithHostname(ctx context.Context, log *zap.Logger, r *monkit.Registry) error

InitMetricsWithHostname initializes telemetry reporting, using the hostname as the telemetry instance ID.

func InitTracing

func InitTracing(ctx context.Context, log *zap.Logger, r *monkit.Registry, instanceID string) (*jaeger.ThriftCollector, func(), error)

InitTracing initializes distributed tracing with an instance ID.

func InitTracingWithCertPath

func InitTracingWithCertPath(ctx context.Context, log *zap.Logger, r *monkit.Registry, certDir string) (*jaeger.ThriftCollector, func(), error)

InitTracingWithCertPath initializes distributed tracing with certificate path.

func InitTracingWithHostname

func InitTracingWithHostname(ctx context.Context, log *zap.Logger, r *monkit.Registry, certDir string) (*jaeger.ThriftCollector, func(), error)

InitTracingWithHostname initializes distributed tracing with nodeID and hostname.

func LoadConfig

func LoadConfig(cmd *cobra.Command, vip *viper.Viper) error

LoadConfig loads configuration into *viper.Viper from file specified with "config-dir" flag.

func NamedLog

func NamedLog(base *zap.Logger, name string) *zap.Logger

NamedLog creates a child logger with a name and configured customization.

func NewLogger

func NewLogger(processName string) (*zap.Logger, *zap.AtomicLevel, error)

NewLogger creates new logger configured by the process flags.

func NewLoggerWithOutputPaths

func NewLoggerWithOutputPaths(processName string, outputPaths ...string) (*zap.Logger, error)

NewLoggerWithOutputPaths is the same as NewLogger, but overrides the log output paths.

func NewLoggerWithOutputPathsAndAtomicLevel

func NewLoggerWithOutputPathsAndAtomicLevel(processName string, outputPaths ...string) (*zap.Logger, *zap.AtomicLevel, error)

NewLoggerWithOutputPathsAndAtomicLevel is the same as NewLoggerWithOutputPaths, but overrides the log output paths and returns the AtomicLevel.

func Report

func Report(ctx context.Context) error

Report triggers each telemetry client to send data to its collection endpoint.

func SaveConfig

func SaveConfig(cmd *cobra.Command, outfile string, opts ...SaveConfigOption) error

SaveConfig will save only the user-specific flags with default values to outfile with specific values specified in 'overrides' overridden.

func SetHardcodedApplicationName

func SetHardcodedApplicationName(name string)

SetHardcodedApplicationName configures telemetry to use the given application name, followed by -dev/-release depending on build settings, instead of os.Args[0]. Disables configuration of metrics.app and metrics.app-suffix.

func SetProfiler

func SetProfiler(fn func(log *zap.Logger) error)

SetProfiler sets the profiler for process package.

It panics on multiple calls.

func Viper

func Viper(cmd *cobra.Command) (*viper.Viper, error)

Viper returns the appropriate *viper.Viper for the command, creating if necessary.

func ViperWithCustomConfig

func ViperWithCustomConfig(cmd *cobra.Command, loadConfig func(cmd *cobra.Command, vip *viper.Viper) error) (*viper.Viper, error)

ViperWithCustomConfig returns the appropriate *viper.Viper for the command, creating if necessary. Custom config load logic can be defined with "loadConfig" parameter.

Types

type ExecOptions

type ExecOptions struct {
	InitDefaultDebugServer bool // enable default debug server.
	InitTracing            bool
	InitProfiler           bool
	FailOnValueError       bool

	LoadConfig    func(cmd *cobra.Command, vip *viper.Viper) error
	LoggerFactory func(*zap.Logger) *zap.Logger
}

ExecOptions contains options for ExecWithCustomOptions.

type SaveConfigOption

type SaveConfigOption func(*SaveConfigOptions)

SaveConfigOption is a function that updates the options for SaveConfig.

func SaveConfigRemovingDeprecated

func SaveConfigRemovingDeprecated() SaveConfigOption

SaveConfigRemovingDeprecated tells SaveConfig to not store deprecated flags.

func SaveConfigWithOverride

func SaveConfigWithOverride(name string, value interface{}) SaveConfigOption

SaveConfigWithOverride adds a single override to SaveConfig.

func SaveConfigWithOverrides

func SaveConfigWithOverrides(overrides map[string]interface{}) SaveConfigOption

SaveConfigWithOverrides sets the overrides to the provided map.

type SaveConfigOptions

type SaveConfigOptions struct {
	Overrides        map[string]interface{}
	RemoveDeprecated bool
}

SaveConfigOptions controls the behavior of SaveConfig.

Directories

Path Synopsis
Deprecated: Use storj.io/common/gcloudlogging instead.
Deprecated: Use storj.io/common/gcloudlogging instead.
Deprecated: Use storj.io/common/googleprofiler instead.
Deprecated: Use storj.io/common/googleprofiler instead.

Jump to

Keyboard shortcuts

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