Documentation ¶
Index ¶
- Constants
- Variables
- func ParseLoggerFlags(c *cli.Context, maybeLogFileName string) (opts []log.Option, err error)
- func ParseTelemetryFlags(ctx context.Context, c *cli.Context, serviceName, serviceInstanceID string, ...) (opts []telemetry.MeterProviderOption, err error)
- type FlagDesc
- func (fd *FlagDesc) BoolFlag() *cli.BoolFlag
- func (fd *FlagDesc) DurationFlag(required bool, defaultValue time.Duration) *cli.DurationFlag
- func (fd *FlagDesc) IntFlag(required bool, defaultValue int) *cli.IntFlag
- func (fd *FlagDesc) StringFlag(required bool, defaultValue string) *cli.StringFlag
- func (fd *FlagDesc) StringSliceFlag(required bool, defaultValues []string) *cli.StringSliceFlag
- func (fd *FlagDesc) Uint64Flag(required bool, defaultValue uint64) *cli.Uint64Flag
- func (fd *FlagDesc) UintFlag(required bool, defaultValue uint) *cli.UintFlag
Constants ¶
View Source
const ( CategoryCluster = "Cluster:" DefaultClusterID = types.MinClusterID DefaultReplicationFactor = 1 )
View Source
const ( CategoryLogger = "Logger:" DefaultLogFileMaxBackups = 100 DefaultLogFileRetentionDays = 14 DefaultLogFileMaxSizeMB = 100 DefaultLogLevel = "INFO" )
View Source
const ( CategoryTelemetry = "Telemetry:" TelemetryExporterNOOP = "noop" TelemetryExporterStdout = "stdout" TelemetryExporterOTLP = "otlp" DefaultTelemetryOTLPEndpoint = "localhost:4317" DefaultTelemetryStopTimeout = 3 * time.Second )
Variables ¶
View Source
var ( ClusterID = &cli.IntFlag{ Name: "cluster-id", Aliases: []string{"cluster", "cid"}, Category: CategoryCluster, EnvVars: []string{"CLUSTER_ID"}, Value: int(DefaultClusterID), Action: func(_ *cli.Context, value int) error { if value < int(types.MinClusterID) || value > int(types.MaxClusterID) { return fmt.Errorf("invalid value \"%d\" for flag --cluster-id", value) } return nil }, } ReplicationFactor = &cli.IntFlag{ Name: "replication-factor", Category: CategoryCluster, EnvVars: []string{"REPLICATION_FACTOR"}, Value: DefaultReplicationFactor, Action: func(_ *cli.Context, value int) error { if value <= 0 { return fmt.Errorf("invalid value \"%d\" for flag --replication-factor", value) } return nil }, } )
View Source
var ( // LogDir is a flag specifying the directory of the logs. LogDir = &cli.StringFlag{ Name: "logdir", Category: CategoryLogger, Aliases: []string{"log-dir"}, EnvVars: []string{"LOGDIR", "LOG_DIR"}, Usage: "Directory for the log files.", } // LogToStderr is a flag that decides whether the logs are printed to the stderr. LogToStderr = &cli.BoolFlag{ Name: "logtostderr", Category: CategoryLogger, Aliases: []string{"log-to-stderr"}, EnvVars: []string{"LOGTOSTDERR"}, Usage: "Print the logs to the stderr.", } // LogFileMaxBackups is a flag specifying the maximum number of backup log files. LogFileMaxBackups = &cli.IntFlag{ Name: "logfile-max-backups", Category: CategoryLogger, EnvVars: []string{"LOGFILE_MAX_BACKUPS"}, Value: DefaultLogFileMaxBackups, Usage: "Maximum number of backup log files. Retain all backup files if zero.", Action: func(_ *cli.Context, value int) error { if value < 0 { return fmt.Errorf("invalid value \"%d\" for flag --logfile-max-backups", value) } return nil }, } // LogFileRetentionDays is a flag specifying the age of backup log files. LogFileRetentionDays = &cli.IntFlag{ Name: "logfile-retention-days", Category: CategoryLogger, EnvVars: []string{"LOGFILE_RETENTION_DAYS"}, Value: DefaultLogFileRetentionDays, Usage: "Age of backup log files. Unlimited age if zero, that is, retain all.", Action: func(_ *cli.Context, value int) error { if value < 0 { return fmt.Errorf("invalid value \"%d\" for flag --logfile-retention-days", value) } return nil }, } // LogFileMaxSizeMB is a flag specifying the maximum size for each log file. LogFileMaxSizeMB = &cli.IntFlag{ Name: "logfile-max-size-mb", Category: CategoryLogger, EnvVars: []string{"LOGFILE_MAX_SIZE_MB"}, Value: DefaultLogFileMaxSizeMB, Usage: "Maximum file size for each log file.", Action: func(_ *cli.Context, value int) error { if value <= 0 { return fmt.Errorf("invalid value \"%d\" for flag --logfile-max-size-mb", value) } return nil }, } // LogFileNameUTC is a flag that decides whether backup log files are named with timestamps in UTC. LogFileNameUTC = &cli.BoolFlag{ Name: "logfile-name-utc", Category: CategoryLogger, EnvVars: []string{"LOGFILE_NAME_UTC"}, Usage: "Whether backup log files are named with timestamps in UTC or local time if not set. Log files are named 'example-1970-01-01T00-00-00.000.log' when the file is rotated.", } // LogFIleCompression is a flag that decides whether backup log files are compressed. LogFileCompression = &cli.BoolFlag{ Name: "logfile-compression", Category: CategoryLogger, EnvVars: []string{"LOGFILE_COMPRESSION"}, Usage: "Compress backup log files.", } // LogHumanReadable is a flag that decides whether logs are human-readable. LogHumanReadable = &cli.BoolFlag{ Name: "log-human-readable", Category: CategoryLogger, EnvVars: []string{"LOG_HUMAN_READABLE"}, Usage: "Human-readable output.", } // LogLevel is a flag specifying log level. LogLevel = &cli.StringFlag{ Name: "loglevel", Category: CategoryLogger, Aliases: []string{"log-level"}, EnvVars: []string{"LOGLEVEL", "LOG_LEVEL"}, Value: DefaultLogLevel, Usage: "Log levels, either debug, info, warn, or error case-insensitively.", } )
View Source
var ( TelemetryExporter = &cli.StringFlag{ Name: "telemetry-exporter", Category: CategoryTelemetry, Aliases: []string{"exporter-type"}, Usage: fmt.Sprintf("Exporter type: %s, %s or %s.", TelemetryExporterNOOP, TelemetryExporterStdout, TelemetryExporterOTLP), EnvVars: []string{"TELEMETRY_EXPORTER", "EXPORTER_TYPE"}, Value: TelemetryExporterNOOP, Action: func(_ *cli.Context, value string) error { switch strings.ToLower(value) { case TelemetryExporterNOOP, TelemetryExporterStdout, TelemetryExporterOTLP: return nil default: return fmt.Errorf("invalid value \"%s\" for flag --telemetry-exporter", value) } }, } TelemetryOTLPEndpoint = &cli.StringFlag{ Name: "telemetry-otlp-endpoint", Category: CategoryTelemetry, Aliases: []string{"exporter-otlp-endpoint"}, Usage: "Endpoint for OTLP exporter.", EnvVars: []string{"TELEMETRY_OTLP_ENDPOINT", "EXPORTER_OTLP_ENDPOINT"}, Value: DefaultTelemetryOTLPEndpoint, Action: func(c *cli.Context, value string) error { if c.String(TelemetryExporter.Name) != TelemetryExporterOTLP || value != "" { return nil } return errors.New("no value for flag --telemetry-otlp-endpoint") }, } TelemetryOTLPInsecure = &cli.BoolFlag{ Name: "telemetry-otlp-insecure", Category: CategoryTelemetry, Aliases: []string{"exporter-otlp-insecure"}, Usage: "Disable gRPC client transport security for OTLP exporter.", EnvVars: []string{"TELEMETRY_OTLP_INSECURE", "EXPORTER_OTLP_INSECURE"}, } TelemetryExporterStopTimeout = &cli.DurationFlag{ Name: "telemetry-exporter-stop-timeout", Category: CategoryTelemetry, Aliases: []string{"expoter-stop-timeout"}, Usage: "Timeout for stopping OTLP exporter.", EnvVars: []string{"TELEMETRY_EXPORTER_STOP_TIMEOUT", "EXPORTER_STOP_TIMEOUT"}, Value: DefaultTelemetryStopTimeout, } TelemetryHost = &cli.BoolFlag{ Name: "telemetry-host", Category: CategoryTelemetry, Usage: "Export host metrics.", EnvVars: []string{"TELEMETRY_HOST"}, } TelemetryRuntime = &cli.BoolFlag{ Name: "telemetry-runtime", Category: CategoryTelemetry, Usage: "Export runtime metrics.", EnvVars: []string{"TELEMETRY_RUNTIME"}, } )
Functions ¶
func ParseLoggerFlags ¶ added in v0.13.0
func ParseTelemetryFlags ¶ added in v0.15.0
Types ¶
type FlagDesc ¶
func LogStreamID ¶
func LogStreamID() *FlagDesc
func MetadataRepositoryAddress ¶
func MetadataRepositoryAddress() *FlagDesc
func StorageNodeID ¶
func StorageNodeID() *FlagDesc
func (*FlagDesc) DurationFlag ¶
func (*FlagDesc) StringFlag ¶
func (*FlagDesc) StringSliceFlag ¶
func (*FlagDesc) Uint64Flag ¶
Click to show internal directories.
Click to hide internal directories.