Documentation
¶
Overview ¶
Package configs provides config management args.go provides some common command line arguments.
Package configs provides config management ¶
Package configs provides config management pulsar.go provides pulsar config
Package configs provides config management ¶
Package configs provides config management ¶
Package configs provides config management server_base_config.go contains the base config of a server
Package configs provide config management server_broker_config.go contains the config of broker server
Package configs provides config management server_trigger_config.go contains the config of trigger server
Index ¶
- Constants
- func GetConfigFilePath() *string
- func GetLogConfig(logName string) *log.Config
- func JSONFormat(c any) (*bytes.Buffer, error)
- func Parse(configPath, format string, reader ParserFunc, opts ...OptionFunc) error
- func ReadFromConsul(configPath string, parser koanf.Parser) error
- func ReadFromFile(filePath string, parser koanf.Parser) error
- func UnmarshalToStruct(path string, c any) error
- type BaseConfig
- type BrokerConfig
- type KafkaConfig
- type MySQLConfig
- type OptionFunc
- type ParserFunc
- type ProducerConfig
- type PulsarConfig
- type RedisConfig
- type TLS
- type TriggerConfig
Constants ¶
const ( // ConfigFormatYAML config format type yaml ConfigFormatYAML = "yaml" // ConfigFormatJSON config format type json ConfigFormatJSON = "json" )
const ( // DefaultHostDomain is the default server domain DefaultHostDomain = "localhost" // DefaultGRPCPort is the default port for gRPC server. DefaultGRPCPort = 50050 // DefaultHTTPPort is the default port for HTTP server. DefaultHTTPPort = 8080 // DefaultTLSEnable is enabled TLS DefaultTLSEnable = false // DefaultEnableAutocert is enabled TLS autocert DefaultEnableAutocert = false // DefaultCertPath is the default path for TLS certificate. DefaultCertPath = "./certs/pudding.pem" // DefaultKeyPath is the default path for TLS key. DefaultKeyPath = "./certs/pudding-key.pem" // DefaultNameServerURL is the default name server connection url DefaultNameServerURL = "" )
Variables ¶
This section is empty.
Functions ¶
func GetConfigFilePath ¶
func GetConfigFilePath() *string
GetConfigFilePath get the config file path
func GetLogConfig ¶
GetLogConfig get specify log config by log name
func JSONFormat ¶
JSONFormat returns the json format of the config.
func Parse ¶
func Parse(configPath, format string, reader ParserFunc, opts ...OptionFunc) error
Parse load config from given filePath and format
func ReadFromConsul ¶
ReadFromConsul read config from consul with format
func ReadFromFile ¶
ReadFromFile read config from filePath with format
func UnmarshalToStruct ¶
UnmarshalToStruct unmarshal config to struct
Types ¶
type BaseConfig ¶
type BaseConfig struct { // server domain HostDomain string `json:"host_domain" yaml:"host_domain" mapstructure:"host_domain"` // GRPCPort grpc server port GRPCPort int `json:"grpc_port" yaml:"grpc_port" mapstructure:"grpc_port"` // HTTPPort http server port HTTPPort int `json:"http_port" yaml:"http_port" mapstructure:"http_port"` // NameServerURL name server url NameServerURL string `json:"name_server_url" yaml:"name_server_url" mapstructure:"name_server_url"` // TLS config TLS *TLS `json:"tls" yaml:"tls" mapstructure:"tls"` }
BaseConfig server base Config support CommandLine
type BrokerConfig ¶
type BrokerConfig struct { // BaseConfig server base Config BaseConfig `json:"server_config" yaml:"server_config" mapstructure:"server_config"` // ServerConfig server config // use same struct tag merge BaseConfig to ServerConfig //nolint:govet,revive ServerConfig struct { // TimeSliceInterval broker loop time interval TimeSliceInterval string `json:"time_slice_interval" yaml:"time_slice_interval" mapstructure:"time_slice_interval"` // MessageTopic default message topic, if no topic set in message, use this topic MessageTopic string `json:"message_topic" yaml:"message_topic" mapstructure:"message_topic"` // TokenTopic TimeSlice token topic TokenTopic string `json:"token_topic" yaml:"token_topic" mapstructure:"token_topic"` // Broker type Broker string `json:"broker" yaml:"broker" mapstructure:"broker"` // Connector type Connector string `json:"connector" yaml:"connector" mapstructure:"connector"` // EtcdURLs etcd connection urls EtcdURLs []string `json:"etcd_urls" yaml:"etcd_urls" mapstructure:"etcd_urls"` } `json:"server_config" yaml:"server_config" mapstructure:"server_config"` // Logger log config for output config message Logger []log.Config `json:"log_config" yaml:"log_config" mapstructure:"log_config"` // RedisConfig redis config RedisConfig RedisConfig `json:"redis_config" yaml:"redis_config" mapstructure:"redis_config"` // Kafka kafka config KafkaConfig KafkaConfig `json:"kafka_config" yaml:"kafka_config" mapstructure:"kafka_config"` }
BrokerConfig BrokerConfig Config
func ParseBrokerConfig ¶
func ParseBrokerConfig(configPath string, opts ...OptionFunc) *BrokerConfig
ParseBrokerConfig read the config from the given configPath.
type KafkaConfig ¶
type KafkaConfig struct { // Address is the address list of kafka server Address []string `json:"address" yaml:"address" mapstructure:"address"` // Network is the network of kafka server Network string `json:"network" yaml:"network" mapstructure:"network"` // WriteTimeout is to write timeout of kafka server WriteTimeout int `json:"write_timeout" yaml:"write_timeout" mapstructure:"write_timeout"` // ReadTimeout is the read timeout of kafka server ReadTimeout int `json:"read_timeout" yaml:"read_timeout" mapstructure:"read_timeout"` // NumPartitions is the number of partitions of kafka server NumPartitions int `json:"num_partitions" yaml:"num_partitions" mapstructure:"num_partitions"` // ReplicationFactor is the number of replicas of kafka server ReplicationFactor int `json:"replication_factor" yaml:"replication_factor" mapstructure:"replication_factor"` // ConsumerMaxWaitTime is the max wait time of consumer, milliseconds ConsumerMaxWaitTime int `json:"consumer_max_wait_time" yaml:"consumer_max_wait_time" mapstructure:"consumer_max_wait_time"` // ProducerBatchTimeout is the min wait time of producer, milliseconds ProducerBatchTimeout int `json:"producer_batch_timeout" yaml:"producer_batch_timeout" mapstructure:"producer_batch_timeout"` // BatchSize is the max number of messages to send in a single batch BatchSize int `json:"batch_size" yaml:"batch_size" mapstructure:"batch_size"` }
KafkaConfig kafka client config
type MySQLConfig ¶
type MySQLConfig struct { // DSN is the data source name DSN string `json:"dsn" yaml:"dsn" mapstructure:"dsn"` }
MySQLConfig MySQLConfig Config
type OptionFunc ¶
OptionFunc is the option function for config.
type ParserFunc ¶
ParserFunc Parse config option func
type ProducerConfig ¶
type ProducerConfig struct { // Topic specifies the topic this producer will be publishing on. // This argument is required when constructing the producer. Topic string `json:"topic" yaml:"topic" mapstructure:"topic"` // BatchingMaxPublishDelay specifies the time period within which the messages sent will be batched (default: 10ms) // if batch messages are enabled. If set to a non-zero value, messages will be queued until this time // interval or until BatchingMaxPublishDelay uint `json:"batching_max_publish_delay" yaml:"batching_max_publish_delay" mapstructure:"batching_max_publish_delay"` // BatchingMaxMessages specifies the maximum number of messages permitted in a batch. (default: 1000) // If set to a value greater than 1, messages will be queued until this threshold is reached or // BatchingMaxSize (see below) has been reached or the batch interval has elapsed. BatchingMaxMessages uint `json:"batching_max_messages" yaml:"batching_max_messages" mapstructure:"batching_max_messages"` // BatchingMaxSize specifies the maximum number of bytes permitted in a batch. (default 128 KB) // If set to a value greater than 1, messages will be queued until this threshold is reached or // BatchingMaxMessages (see above) has been reached or the batch interval has elapsed. BatchingMaxSize uint `json:"batching_max_size" yaml:"batching_max_size" mapstructure:"batching_max_size"` }
ProducerConfig pulsar producer config
type PulsarConfig ¶
type PulsarConfig struct { URL string `json:"url" yaml:"url" mapstructure:"url"` ConnectionTimeout int `json:"connection_timeout" yaml:"connection_timeout" mapstructure:"connection_timeout"` ProducersConfig []ProducerConfig `json:"producers_config" yaml:"producers_config" mapstructure:"producers_config"` }
PulsarConfig pulsar config
type RedisConfig ¶
type RedisConfig struct { // URL is the redis connection url URL string `json:"url" yaml:"url" mapstructure:"url"` // DialTimeout Dial timeout for establishing new connections. // Default is 5 seconds. DialTimeout int `json:"dial_timeout" yaml:"dial_timeout" mapstructure:"dial_timeout"` }
RedisConfig Redis config
type TLS ¶
type TLS struct { // Enable is enabled TLS, default is false Enable bool `json:"enable" yaml:"enable" mapstructure:"enable"` // AutoCert is enabled TLS autocert, default is false AutoCert bool `json:"autocert" yaml:"autocert" mapstructure:"autocert"` // CertPath tls cert file path, the file must contain PEM encoded data. CACert string `json:"ca_cert" yaml:"ca_cert" mapstructure:"ca_cert"` // ServerCert tls server cert file path, the file must contain PEM encoded data. ServerCert string `json:"server_cert" yaml:"server_cert" mapstructure:"server_cert"` // ServerKey tls server key file path, the file must contain PEM encoded data. ServerKey string `json:"server_key" yaml:"server_key" mapstructure:"server_key"` // ClientCert tls client cert file path, the file must contain PEM encoded data. ClientCert string `json:"client_cert" yaml:"client_cert" mapstructure:"client_cert"` // ClientKey tls client key file path, the file must contain PEM encoded data. ClientKey string `json:"client_key" yaml:"client_key" mapstructure:"client_key"` }
TLS config
type TriggerConfig ¶
type TriggerConfig struct { // BaseConfig server base Config BaseConfig `json:"server_config" yaml:"server_config" mapstructure:"server_config"` // ServerConfig server config // use same struct tag merge BaseConfig to ServerConfig //nolint:govet,revive ServerConfig struct { // WebhookPrefix is the prefix of webhook url. WebhookPrefix string `json:"webhook_prefix" yaml:"webhook_prefix" mapstructure:"webhook_prefix"` // SchedulerConsulURL is the scheduler consul connection url. SchedulerConsulURL string `json:"scheduler_consul_url" yaml:"scheduler_consul_url" mapstructure:"scheduler_consul_url"` } `json:"server_config" yaml:"server_config" mapstructure:"server_config"` // Logger log config for output config message Logger []log.Config `json:"log_config" yaml:"log_config" mapstructure:"log_config"` // MySQLConfig config MySQLConfig *MySQLConfig `json:"mysql_config" yaml:"mysql_config" mapstructure:"mysql_config"` }
TriggerConfig Trigger server config
func ParseTriggerConfig ¶
func ParseTriggerConfig(configPath string, opts ...OptionFunc) *TriggerConfig
ParseTriggerConfig read the config from the given configPath.