Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( GRPCServerType = ServerType("grpc") RESTServerType = ServerType("rest") )
View Source
var ( DevelopmentEnvType = EnvType("development") ProductionEnvType = EnvType("production") )
View Source
var EnvTypes = []EnvType{ DevelopmentEnvType, ProductionEnvType, }
View Source
var ServerTypes = []ServerType{ GRPCServerType, RESTServerType, }
ServerTypes is a list of server types
Functions ¶
func IsFlakeConfiguredProperly ¶
IsFlakeConfiguredProperly returns true if the flake configuration is properly configured, sum of bits length must be 63
func IsValidEnvType ¶
IsValidEnvType returns true if the environment type is valid
func IsValidServerType ¶
func IsValidServerType(serverType ServerType) bool
IsValidServerType returns true if the server type is valid
func IsValidTLSConfig ¶ added in v1.0.2
IsValidTLSConfig returns true if the tls configuration is valid
Types ¶
type Config ¶
type Config struct { Env EnvType `json:"env"` LogLevel string `mapstructure:"log_level" json:"log_level"` DatacenterID uint8 `mapstructure:"datacenter_id" json:"datacenter_id"` MachineID uint8 `mapstructure:"machine_id" json:"machine_id"` Server struct { Type ServerType `mapstructure:"type" json:"type"` Host string `mapstructure:"host" json:"host"` Port int `mapstructure:"port" json:"port"` TLS struct { CertPath string `mapstructure:"cert_path" json:"cert_path"` KeyPath string `mapstructure:"key_path" json:"key_path"` } `mapstructure:"tls" json:"tls"` } `mapstructure:"server" json:"server"` Flake struct { Epoch uint64 `mapstructure:"epoch" json:"epoch"` TickMs uint64 `mapstructure:"tick_ms" json:"tick_ms"` BitsLen struct { DatacenterID uint8 `mapstructure:"datacenter_id" json:"datacenter_id"` MachineID uint8 `mapstructure:"machine_id" json:"machine_id"` Time uint8 `mapstructure:"time" json:"time"` Sequence uint8 `mapstructure:"sequence" json:"sequence"` } `mapstructure:"bits_len" json:"bits_len"` } `mapstructure:"flake" json:"flake"` }
Config is the configuration for the application
func MustConfig ¶
func MustConfig() *Config
MustConfig configures the application and panics on error
type EnvType ¶
type EnvType string
EnvType is the type of environment (development, production, etc)
type ErrInvalidConfig ¶
type ErrInvalidConfig struct {
Err string
}
ErrInvalidConfig is returned when the configuration is invalid
func (ErrInvalidConfig) Error ¶
func (e ErrInvalidConfig) Error() string
Error returns the error message
Click to show internal directories.
Click to hide internal directories.