Documentation ¶
Index ¶
- Constants
- Variables
- func GetLogStreamIDFlag() *cli.IntFlag
- func GetStorageNodeIDFlag() *cli.IntFlag
- func GetTopicIDFlag() *cli.IntFlag
- func ParseGRPCDialOptionFlags(c *cli.Context) (opts []grpc.DialOption, err error)
- func ParseGRPCServerOptionFlags(c *cli.Context) (opts []grpc.ServerOption, _ error)
- 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 )
View Source
const (
CategoryGRPC = "gRPC:"
)
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 ( // GRPCServerReadBufferSize is a flag to set the gRPC server's read buffer // size for a single read syscall. // // See: // - https://pkg.go.dev/google.golang.org/grpc#ReadBufferSize GRPCServerReadBufferSize = &cli.StringFlag{ Name: "grpc-server-read-buffer-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_SERVER_READ_BUFFER_SIZE"}, Usage: "Set the gRPC server's read buffer size for a single read syscall. If not set, the default value of 32KiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-server-read-buffer-size", value) } return nil }, } // GRPCServerWriteBufferSize is a flag to set the gRPC server's write // buffer size for a single write syscall. // // See: // - https://pkg.go.dev/google.golang.org/grpc#WriteBufferSize GRPCServerWriteBufferSize = &cli.StringFlag{ Name: "grpc-server-write-buffer-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_SERVER_WRITE_BUFFER_SIZE"}, Usage: "Set the gRPC server's write buffer size for a single write syscall. If not set, the default value of 32KiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-server-write-buffer-size", value) } return nil }, } // // See: // - https://pkg.go.dev/google.golang.org/grpc#WithSharedWriteBuffer // - https://github.com/grpc/grpc-go/pull/6309 GRPCServerSharedWriteBuffer = &cli.BoolFlag{ Name: "grpc-server-shared-write-buffer", Category: CategoryGRPC, EnvVars: []string{"GRPC_SERVER_SHARED_WRITE_BUFFER"}, Usage: "Enable sharing gRPC server's transport write buffer across connections. If not set, each connection will allocate its own write buffer.", } // GRPCServerMaxRecvMsgSize is a flag to set the maximum message size the server can receive. // // See: // - https://pkg.go.dev/google.golang.org/grpc#MaxRecvMsgSize GRPCServerMaxRecvMsgSize = &cli.StringFlag{ Name: "grpc-server-max-recv-msg-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_SERVER_MAX_RECV_MSG_SIZE"}, Usage: "Set the maximum message size in bytes that the gRPC server can receive. If not set, the default value of 4MiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-server-max-recv-msg-size", value) } return nil }, } // GRPCServerInitialConnWindowSize is a flag to set the gRPC server's initial window size for a connection. // // See: // - https://pkg.go.dev/google.golang.org/grpc#InitialConnWindowSize GRPCServerInitialConnWindowSize = &cli.StringFlag{ Name: "grpc-server-initial-conn-window-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_SERVER_INITIAL_CONN_WINDOW_SIZE"}, Usage: "Set the gRPC server's initial window size for a connection. If not set, the default value of 64KiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value, 0, math.MaxInt32); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-server-initial-conn-window-size", value) } return nil }, } // GRPCServerInitialWindowSize is a flag to set the gRPC server's initial window size for a stream. // // See: // - https://pkg.go.dev/google.golang.org/grpc#InitialWindowSize GRPCServerInitialWindowSize = &cli.StringFlag{ Name: "grpc-server-initial-window-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_SERVER_INITIAL_WINDOW_SIZE"}, Usage: "Set the gRPC server's initial window size for a stream. If not set, the default value of 64KiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value, 0, math.MaxInt32); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-server-initial-window-size", value) } return nil }, } // GRPCClientReadBufferSize is a flag to set the gRPC client's read buffer // size for a single read syscall. // // See: // - https://pkg.go.dev/google.golang.org/grpc#WithReadBufferSize GRPCClientReadBufferSize = &cli.StringFlag{ Name: "grpc-client-read-buffer-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_CLIENT_READ_BUFFER_SIZE"}, Usage: "Set the gRPC client's read buffer size for a single read syscall. If not set, the default value of 32KiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-client-read-buffer-size", value) } return nil }, } // GRPCClientWriteBufferSize is a flag to set the gRPC client's write // buffer size for a single write syscall. // // See: // - https://pkg.go.dev/google.golang.org/grpc#WithWriteBufferSize GRPCClientWriteBufferSize = &cli.StringFlag{ Name: "grpc-client-write-buffer-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_CLIENT_WRITE_BUFFER_SIZE"}, Usage: "Set the gRPC client's write buffer size for a single write syscall. If not set, the default value of 32KiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-client-read-buffer-size", value) } return nil }, } // // See: // - https://pkg.go.dev/google.golang.org/grpc#WithSharedWriteBuffer // - https://github.com/grpc/grpc-go/pull/6309 GRPCClientSharedWriteBuffer = &cli.BoolFlag{ Name: "grpc-client-shared-write-buffer", Category: CategoryGRPC, EnvVars: []string{"GRPC_CLIENT_SHARED_WRITE_BUFFER"}, Usage: "Enable sharing gRPC client's transport write buffer across connections. If not set, each connection will allocate its own write buffer.", } // GRPCClientInitialConnWindowSize is a flag to set the gRPC client's initial window size for a connection. // // See: // - https://pkg.go.dev/google.golang.org/grpc#WithInitialConnWindowSize GRPCClientInitialConnWindowSize = &cli.StringFlag{ Name: "grpc-client-initial-conn-window-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_CLIENT_INITIAL_CONN_WINDOW_SIZE"}, Usage: "Set the gRPC client's initial window size for a connection. If not set, the default value of 64KiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value, 0, math.MaxInt32); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-client-initial-conn-window-size", value) } return nil }, } // GRPCClientInitialWindowSize is a flag to set the gRPC client's initial window size for a stream. // // See: // - https://pkg.go.dev/google.golang.org/grpc#WithInitialWindowSize GRPCClientInitialWindowSize = &cli.StringFlag{ Name: "grpc-client-initial-window-size", Category: CategoryGRPC, EnvVars: []string{"GRPC_CLIENT_INITIAL_WINDOW_SIZE"}, Usage: "Set the gRPC client's initial window size for a stream. If not set, the default value of 64KiB defined by gRPC will be used.", Action: func(c *cli.Context, value string) error { if _, err := units.FromByteSizeString(value, 0, math.MaxInt32); err != nil { return fmt.Errorf("invalid value \"%s\" for flag --grpc-client-initial-window-size", 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 GetLogStreamIDFlag ¶ added in v0.23.0
func GetLogStreamIDFlag() *cli.IntFlag
GetLogStreamIDFlag returns a flag for specifying the LogStream ID. Users can modify the returned flag without affecting the predefined flag.
func GetStorageNodeIDFlag ¶ added in v0.23.0
func GetStorageNodeIDFlag() *cli.IntFlag
GetClusterIDFlag returns a flag for specifying the Cluster ID. Users can modify the returned flag without affecting the predefined flag.
func GetTopicIDFlag ¶ added in v0.23.0
func GetTopicIDFlag() *cli.IntFlag
GetTopicIDFlag returns a flag for specifying the Topic ID. Users can modify the returned flag without affecting the predefined flag.
func ParseGRPCDialOptionFlags ¶ added in v0.21.0
func ParseGRPCDialOptionFlags(c *cli.Context) (opts []grpc.DialOption, err error)
func ParseGRPCServerOptionFlags ¶ added in v0.21.0
func ParseGRPCServerOptionFlags(c *cli.Context) (opts []grpc.ServerOption, _ error)
func ParseLoggerFlags ¶ added in v0.13.0
func ParseTelemetryFlags ¶ added in v0.15.0
Types ¶
type FlagDesc ¶
func MetadataRepositoryAddress ¶
func MetadataRepositoryAddress() *FlagDesc
func (*FlagDesc) DurationFlag ¶
func (*FlagDesc) StringFlag ¶
func (*FlagDesc) StringSliceFlag ¶
func (*FlagDesc) Uint64Flag ¶
Click to show internal directories.
Click to hide internal directories.