Documentation
¶
Index ¶
- func ApplyInsecureServingToGRPCConfig[Txp, Ep, Svc, Store any](i *InsecureServingOptions[Svc, Store], ...) error
- func ApplySecureServingToGRPCConfig[Txp, Ep, Svc, Store any](s *SecureServingOptions[Svc, Store], ...) error
- type APIServerRunOptions
- type CertKey
- type GRPCServerRunOptions
- func (s *GRPCServerRunOptions[Txp, Ep, Svc, Store]) AddFlags(fs *pflag.FlagSet)
- func (s *GRPCServerRunOptions[Txp, Ep, Svc, Store]) ApplyTo(c *server.GRPCServerConfig[Txp, Ep, Svc, Store]) error
- func (s *GRPCServerRunOptions[Txp, Ep, Svc, Store]) Complete() error
- func (s *GRPCServerRunOptions[Txp, Ep, Svc, Store]) Validate() []error
- type GRPCServingOptions
- func (g *GRPCServingOptions[Txp, Ep, Svc, Store]) AddFlags(fs *pflag.FlagSet)
- func (g *GRPCServingOptions[Txp, Ep, Svc, Store]) ApplyTo(c *server.GRPCServerConfig[Txp, Ep, Svc, Store]) error
- func (g *GRPCServingOptions[Txp, Ep, Svc, Store]) Complete() error
- func (g *GRPCServingOptions[Txp, Ep, Svc, Store]) Validate() []error
- type GeneratableKeyCert
- type InsecureServingOptions
- func (i *InsecureServingOptions[Svc, Store]) AddFlags(fs *pflag.FlagSet)
- func (i *InsecureServingOptions[Svc, Store]) Addr() string
- func (i *InsecureServingOptions[Svc, Store]) ApplyToAPIConfig(c *server.APIServerConfig[Svc, Store]) error
- func (i *InsecureServingOptions[Svc, Store]) Complete() error
- func (i *InsecureServingOptions[Svc, Store]) Validate() []error
- type LoggerOptions
- func (o *LoggerOptions) AddFlags(fs *pflag.FlagSet)
- func (o *LoggerOptions) ApplyTo(conf *logger.Config) error
- func (o *LoggerOptions) Complete() error
- func (o *LoggerOptions) Validate() []error
- func (o *LoggerOptions) WithLogBaseDir(logBaseDir string) *LoggerOptions
- func (o *LoggerOptions) WithProjectName(projectName string) *LoggerOptions
- type RAOptions
- type SecureServingOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyInsecureServingToGRPCConfig ¶
func ApplyInsecureServingToGRPCConfig[Txp, Ep, Svc, Store any](i *InsecureServingOptions[Svc, Store], c *server.GRPCServerConfig[Txp, Ep, Svc, Store]) error
ApplyInsecureServingToGRPCConfig applies the insecure serving options to the gRPC server config. It is a package-level function because the gRPC config carries endpoint/transport type parameters that this HTTP/gRPC shared options type does not carry; they are inferred from the config argument.
func ApplySecureServingToGRPCConfig ¶
func ApplySecureServingToGRPCConfig[Txp, Ep, Svc, Store any](s *SecureServingOptions[Svc, Store], c *server.GRPCServerConfig[Txp, Ep, Svc, Store]) error
ApplySecureServingToGRPCConfig applies the secure serving options to the gRPC server config. It is a package-level function because the gRPC config carries endpoint/transport type parameters that this HTTP/gRPC shared options type does not carry; they are inferred from the config argument.
Types ¶
type APIServerRunOptions ¶
type APIServerRunOptions[Svc any, Store any] struct { Mode string `json:"mode" mapstructure:"mode"` Healthz bool `json:"healthz" mapstructure:"healthz"` HealthCheckPath string `json:"health-check-path" mapstructure:"health-check-path"` PingTimeout time.Duration `json:"ping-timeout" mapstructure:"ping-timeout"` ShutdownTimeout time.Duration `json:"shutdown-timeout" mapstructure:"shutdown-timeout"` Middlewares []string `json:"middlewares" mapstructure:"middlewares"` }
APIServerRunOptions contains the options for running a generic API server.
func NewAPIServerRunOptions ¶
func NewAPIServerRunOptions[Svc any, Store any]() (o *APIServerRunOptions[Svc, Store])
NewAPIServerRunOptions creates a new APIServerRunOptions with default values.
func (*APIServerRunOptions[Svc, Store]) AddFlags ¶
func (o *APIServerRunOptions[Svc, Store]) AddFlags(fs *pflag.FlagSet)
AddFlags adds flags to the specified FlagSet.
func (*APIServerRunOptions[Svc, Store]) ApplyTo ¶
func (o *APIServerRunOptions[Svc, Store]) ApplyTo(c *server.APIServerConfig[Svc, Store]) error
ApplyTo applies the run options to the server config.
func (*APIServerRunOptions[Svc, Store]) Complete ¶
func (o *APIServerRunOptions[Svc, Store]) Complete() error
Complete fills in default values for unset fields.
func (*APIServerRunOptions[Svc, Store]) Validate ¶
func (o *APIServerRunOptions[Svc, Store]) Validate() []error
Validate validates the run options and returns a list of errors if any.
type CertKey ¶
type CertKey struct {
// CertFile is a file containing a PEM-encoded certificate, and possibly the complete certificate chain
CertFile string `json:"cert-file" mapstructure:"cert-file"`
// KeyFile is a file containing a PEM-encoded private key for the certificate specified by CertFile
KeyFile string `json:"private-key-file" mapstructure:"private-key-file"`
}
CertKey contains configuration items related to certificate.
type GRPCServerRunOptions ¶
type GRPCServerRunOptions[Txp, Ep, Svc, Store any] struct { Healthz bool `json:"healthz" mapstructure:"healthz"` Middlewares []string `json:"middlewares" mapstructure:"middlewares"` PingTimeout time.Duration `json:"ping-timeout" mapstructure:"ping-timeout"` ShutdownTimeout time.Duration `json:"shutdown-timeout" mapstructure:"shutdown-timeout"` }
GRPCServerRunOptions contains the options for running a generic gRPC server.
func NewGRPCServerRunOptions ¶
func NewGRPCServerRunOptions[Txp, Ep, Svc, Store any]() (o *GRPCServerRunOptions[Txp, Ep, Svc, Store])
NewGRPCServerRunOptions creates a new GRPCServerRunOptions with default values.
func (*GRPCServerRunOptions[Txp, Ep, Svc, Store]) AddFlags ¶
func (s *GRPCServerRunOptions[Txp, Ep, Svc, Store]) AddFlags(fs *pflag.FlagSet)
AddFlags adds flags for the gRPC server to the specified FlagSet.
func (*GRPCServerRunOptions[Txp, Ep, Svc, Store]) ApplyTo ¶
func (s *GRPCServerRunOptions[Txp, Ep, Svc, Store]) ApplyTo(c *server.GRPCServerConfig[Txp, Ep, Svc, Store]) error
ApplyTo applies the run options to the gRPC server config.
func (*GRPCServerRunOptions[Txp, Ep, Svc, Store]) Complete ¶
func (s *GRPCServerRunOptions[Txp, Ep, Svc, Store]) Complete() error
Complete fills in default values for unset fields.
func (*GRPCServerRunOptions[Txp, Ep, Svc, Store]) Validate ¶
func (s *GRPCServerRunOptions[Txp, Ep, Svc, Store]) Validate() []error
Validate validates the gRPC server run options.
type GRPCServingOptions ¶
type GRPCServingOptions[Txp, Ep, Svc, Store any] struct { ChunkSize int `json:"chunksize" mapstructure:"chunksize"` ReceiveTimeoutMinutes int `json:"receive-timeout-minutes" mapstructure:"receive-timeout-minutes"` }
GRPCServingOptions contains configuration for gRPC serving.
func NewGRPCServingOptions ¶
func NewGRPCServingOptions[Txp, Ep, Svc, Store any]() *GRPCServingOptions[Txp, Ep, Svc, Store]
NewGRPCServingOptions creates a new GRPCServingOptions object with default parameters.
func (*GRPCServingOptions[Txp, Ep, Svc, Store]) AddFlags ¶
func (g *GRPCServingOptions[Txp, Ep, Svc, Store]) AddFlags(fs *pflag.FlagSet)
AddFlags adds command-line flags for GRPCServingOptions.
func (*GRPCServingOptions[Txp, Ep, Svc, Store]) ApplyTo ¶
func (g *GRPCServingOptions[Txp, Ep, Svc, Store]) ApplyTo(c *server.GRPCServerConfig[Txp, Ep, Svc, Store]) error
ApplyTo applies the gRPC serving options to the gRPC server config.
func (*GRPCServingOptions[Txp, Ep, Svc, Store]) Complete ¶
func (g *GRPCServingOptions[Txp, Ep, Svc, Store]) Complete() error
Complete fills in default values for unset fields.
func (*GRPCServingOptions[Txp, Ep, Svc, Store]) Validate ¶
func (g *GRPCServingOptions[Txp, Ep, Svc, Store]) Validate() []error
Validate validates the gRPC serving options.
type GeneratableKeyCert ¶
type GeneratableKeyCert struct {
// CertKey allows setting an explicit cert/key file to use.
CertKey CertKey `json:"cert-key" mapstructure:"cert-key"`
// CertDirectory specifies a directory to write generated certificates to if CertFile/KeyFile aren't explicitly set.
// PairName is used to determine the filenames within CertDirectory.
// If CertDirectory and PairName are not set, an in-memory certificate will be generated.
CertDirectory string `json:"cert-dir" mapstructure:"cert-dir"`
// PairName is the name which will be used with CertDirectory to make a cert and key filenames.
// It becomes CertDirectory/PairName.crt and CertDirectory/PairName.key
PairName string `json:"pair-name" mapstructure:"pair-name"`
}
GeneratableKeyCert contains configuration items related to certificate.
type InsecureServingOptions ¶
type InsecureServingOptions[Svc any, Store any] struct { BindAddress string `json:"bind-address" mapstructure:"bind-address"` BindPort int `json:"bind-port" mapstructure:"bind-port"` }
InsecureServingOptions contains configuration for serving HTTP requests.
func NewInsecureServingOptions ¶
func NewInsecureServingOptions[Svc any, Store any]() *InsecureServingOptions[Svc, Store]
NewInsecureServingOptions creates a new InsecureServingOptions object with default parameters.
func (*InsecureServingOptions[Svc, Store]) AddFlags ¶
func (i *InsecureServingOptions[Svc, Store]) AddFlags(fs *pflag.FlagSet)
AddFlags adds command-line flags for InsecureServingOptions.
func (*InsecureServingOptions[Svc, Store]) Addr ¶
func (i *InsecureServingOptions[Svc, Store]) Addr() string
Addr returns the address for insecure serving.
func (*InsecureServingOptions[Svc, Store]) ApplyToAPIConfig ¶
func (i *InsecureServingOptions[Svc, Store]) ApplyToAPIConfig(c *server.APIServerConfig[Svc, Store]) error
ApplyToAPIConfig applies the insecure serving options to the API server config.
func (*InsecureServingOptions[Svc, Store]) Complete ¶
func (i *InsecureServingOptions[Svc, Store]) Complete() error
func (*InsecureServingOptions[Svc, Store]) Validate ¶
func (i *InsecureServingOptions[Svc, Store]) Validate() []error
Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.
type LoggerOptions ¶
type LoggerOptions struct {
LogBaseDir string `json:"log-base-dir" mapstructure:"log-base-dir"`
InfoOutputPaths []string `json:"info-output-paths" mapstructure:"info-output-paths"`
ErrorOutputPaths []string `json:"error-output-paths" mapstructure:"error-output-paths"`
InnerErrorOutputPaths []string `json:"inner-error-output-paths" mapstructure:"inner-error-output-paths"`
InfoLevel string `json:"info-level" mapstructure:"info-level"`
ErrorLevel string `json:"error-level" mapstructure:"error-level"`
Format string `json:"format" mapstructure:"format"`
DisableCaller bool `json:"disable-caller" mapstructure:"disable-caller"`
DisableStacktrace bool `json:"disable-stacktrace" mapstructure:"disable-stacktrace"`
EnableColor bool `json:"enable-color" mapstructure:"enable-color"`
Development bool `json:"development" mapstructure:"development"`
// contains filtered or unexported fields
}
LoggerOptions holds configuration for the logger.
Usage:
// Option 1: Use default log paths (logs/info.log, logs/error.log)
opts := NewLoggerOptions()
// Option 2: Use project-specific log paths (logs/{projectName}.log, logs/{projectName}_error.log)
opts := NewLoggerOptionsWithProject("my-service")
// Option 3: Customize log paths via CLI flags or config file
opts := NewLoggerOptions()
opts.AddFlags(flag.CommandLine)
flag.Parse()
// Option 4: Use builder pattern (project name does not affect default log paths)
opts := NewLoggerOptions().WithProjectName("my-service")
opts.Complete() // Keeps: logs/info.log, logs/error.log (paths unchanged)
Note: WithProjectName() only sets the project name for the logger, it does not adjust log paths. Log paths are determined by the constructor used or explicitly set via CLI flags/config file.
func NewLoggerOptions ¶
func NewLoggerOptions() *LoggerOptions
NewLoggerOptions creates a new LoggerOptions with default log paths. This constructor uses default log paths: logs/info.log, logs/error.log
func NewLoggerOptionsWithProject ¶
func NewLoggerOptionsWithProject(projectName string) *LoggerOptions
NewLoggerOptionsWithProject creates a new LoggerOptions with project-specific configuration. This constructor customizes info and error log paths based on the project name. Example: logs/{projectName}.log, logs/{projectName}_error.log
func (*LoggerOptions) AddFlags ¶
func (o *LoggerOptions) AddFlags(fs *pflag.FlagSet)
func (*LoggerOptions) Complete ¶
func (o *LoggerOptions) Complete() error
func (*LoggerOptions) Validate ¶
func (o *LoggerOptions) Validate() []error
func (*LoggerOptions) WithLogBaseDir ¶
func (o *LoggerOptions) WithLogBaseDir(logBaseDir string) *LoggerOptions
WithLogBaseDir sets the base log directory for logger options. Returns self for method chaining.
func (*LoggerOptions) WithProjectName ¶
func (o *LoggerOptions) WithProjectName(projectName string) *LoggerOptions
WithProjectName sets the project name for logger options. This method does not adjust log paths. Returns self for method chaining.
type RAOptions ¶
type RAOptions[Txp, Ep, Svc, Store any] struct { Host string `json:"host" mapstructure:"host"` Port int `json:"port" mapstructure:"port"` }
RAOptions contains the options used to connect to the RA server.
func NewRAOptions ¶
NewRAOptions creates a new RAOptions object with default parameters.
func (*RAOptions[Txp, Ep, Svc, Store]) ApplyTo ¶
func (ra *RAOptions[Txp, Ep, Svc, Store]) ApplyTo(c *server.GRPCServerConfig[Txp, Ep, Svc, Store]) error
ApplyTo applies the RA options to the gRPC server config.
type SecureServingOptions ¶
type SecureServingOptions[Svc any, Store any] struct { BindAddress string `json:"bind-address" mapstructure:"bind-address"` // BindPort is ignored when Listener is set, will disable even with 0. BindPort int `json:"bind-port" mapstructure:"bind-port"` // ServerCert is the TLS cert info for serving secure traffic ServerCert GeneratableKeyCert `json:"tls" mapstructure:"tls"` }
SecureServingOptions contains configuration items related to TLS server startup.
func NewSecureServingOptions ¶
func NewSecureServingOptions[Svc any, Store any]() *SecureServingOptions[Svc, Store]
NewSecureServingOptions creates a new SecureServingOptions object with default parameters.
func (*SecureServingOptions[Svc, Store]) AddFlags ¶
func (s *SecureServingOptions[Svc, Store]) AddFlags(fs *pflag.FlagSet)
AddFlags adds command-line flags for SecureServingOptions.
func (*SecureServingOptions[Svc, Store]) ApplyToAPIConfig ¶
func (s *SecureServingOptions[Svc, Store]) ApplyToAPIConfig(c *server.APIServerConfig[Svc, Store]) error
ApplyToAPIConfig applies the secure serving options to the API server config.
func (*SecureServingOptions[Svc, Store]) Complete ¶
func (s *SecureServingOptions[Svc, Store]) Complete() error
func (*SecureServingOptions[Svc, Store]) Validate ¶
func (s *SecureServingOptions[Svc, Store]) Validate() []error
Validate is used to parse and validate the parameters entered by the user at the command line when the program starts.