Documentation
¶
Index ¶
- Constants
- Variables
- type AppVersion
- type BrokerConfig
- type CLIConfig
- type CommandOption
- type Config
- func (config *Config) GetConnectionTimeout() time.Duration
- func (config *Config) GetDBConnectionMaxIdleTime() time.Duration
- func (config *Config) GetDBConnectionMaxLifetime() time.Duration
- func (config *Config) GetDBConnectionURL() string
- func (config *Config) GetDBDialect() DBDialect
- func (config *Config) GetExportNodeName() string
- func (config *Config) GetExportPath() string
- func (config *Config) GetHTTPListeningAddr() string
- func (config *Config) GetHTTPReadTimeout() time.Duration
- func (config *Config) GetHTTPWriteTimeout() time.Duration
- func (config *Config) GetLogFilename() string
- func (config *Config) GetLogLevel() LogLevel
- func (config *Config) GetMaxAgeForALogFile() uint
- func (config *Config) GetMaxArchiveFileSizeInMB() uint
- func (config *Config) GetMaxIdleDBConnections() uint16
- func (config *Config) GetMaxLogBackups() uint
- func (config *Config) GetMaxLogFileSize() uint
- func (config *Config) GetMaxMessageQueueSize() uint
- func (config *Config) GetMaxOpenDBConnections() uint16
- func (config *Config) GetMaxRetry() uint8
- func (config *Config) GetMaxWorkers() uint
- func (config *Config) GetMessageRetentionDays() uint
- func (config *Config) GetMinScheduleDelay() time.Duration
- func (config *Config) GetRationalDelay() time.Duration
- func (config *Config) GetRemoteExportDestination() RemoteMessageDestination
- func (config *Config) GetRemoteExportURL() *url.URL
- func (config *Config) GetRemoteFilePrefix() string
- func (config *Config) GetRetriggerBaseEndpoint() string
- func (config *Config) GetRetryBackoffDelays() []time.Duration
- func (config *Config) GetSchedulerBatchSize() int
- func (config *Config) GetSchedulerInterval() time.Duration
- func (config *Config) GetSeedData() SeedData
- func (config *Config) GetTokenRequestHeaderName() string
- func (config *Config) GetUserAgent() string
- func (config *Config) IsCompressionEnabledOnLogBackups() bool
- func (config *Config) IsLoggerConfigAvailable() bool
- func (config *Config) IsPriorityDispatcherEnabled() bool
- func (config *Config) IsPruningEnabled() bool
- func (config *Config) IsRecoveryWorkersEnabled() bool
- type ConsumerConnectionConfig
- type DBDialect
- type HTTPConfig
- type LogConfig
- type LogLevel
- type MessagePruningConfig
- type RelationalDatabaseConfig
- type RemoteMessageDestination
- type SchedulerConfig
- type SeedChannel
- type SeedConsumer
- type SeedData
- type SeedDataConfig
- type SeedProducer
Constants ¶
const ( PullConsumerStr = "pull" PushConsumerStr = "push" )
const ( // SQLite3Dialect represents the DB Dialect for SQLite3 SQLite3Dialect = DBDialect("sqlite3") // MySQLDialect represents the DB Dialect for MySQL MySQLDialect = DBDialect("mysql") // ConfigFilename is the default config file name ConfigFilename = "webhook-broker.cfg" // DefaultSystemConfigFilePath is the default system location of the configuration DefaultSystemConfigFilePath = "/etc/webhook-broker/" + ConfigFilename // DefaultCurrentDirConfigFilePath is the config file path based on current working dir DefaultCurrentDirConfigFilePath = ConfigFilename // Debug is the lowest LogLevel, will expose all logs Debug LogLevel = 20 + iota // Info is the second lowest LogLevel Info // Error is the second highest LogLevel Error // Fatal is the highest LogLevel with lowest logs Fatal )
const ( // DefaultSchedulerIntervalMs is the default interval between scheduler runs in milliseconds DefaultSchedulerIntervalMs = 5000 // DefaultMinScheduleDelayMinutes is the minimum delay required for scheduled messages in minutes DefaultMinScheduleDelayMinutes = 2 // DefaultSchedulerBatchSize is the maximum number of messages to process per scheduler run DefaultSchedulerBatchSize = 100 )
const DefaultConfiguration = `` /* 1349-byte string literal not displayed */
DefaultConfiguration is the configuration that will be in effect if no configuration is loaded from any of the expected locations
Variables ¶
var ( // EmptyConfigurationForError Represents the configuration instance to be // used when there is a configuration error during load EmptyConfigurationForError = &Config{} // ConfigInjector sets up configuration related bindings ConfigInjector = wire.NewSet(GetConfigurationFromCLIConfig, wire.Bind(new(SeedDataConfig), new(*Config)), wire.Bind(new(HTTPConfig), new(*Config)), wire.Bind(new(RelationalDatabaseConfig), new(*Config)), wire.Bind(new(LogConfig), new(*Config)), wire.Bind(new(BrokerConfig), new(*Config)), wire.Bind(new(ConsumerConnectionConfig), new(*Config)), wire.Bind(new(SchedulerConfig), new(*Config))) )
Functions ¶
This section is empty.
Types ¶
type AppVersion ¶
type AppVersion string
AppVersion is the version string type
func GetVersion ¶
func GetVersion() AppVersion
GetVersion provides the current version of the project
type BrokerConfig ¶
type BrokerConfig interface {
GetMaxMessageQueueSize() uint
GetMaxWorkers() uint
IsPriorityDispatcherEnabled() bool
GetRetriggerBaseEndpoint() string
GetMaxRetry() uint8
GetRationalDelay() time.Duration
GetRetryBackoffDelays() []time.Duration
IsRecoveryWorkersEnabled() bool
}
BrokerConfig provides the interface for configuring the broker
type CLIConfig ¶
type CLIConfig struct {
ConfigPath string
MigrationSource string
StopOnConfigChange bool
DoNotWatchConfigChange bool
Command CommandOption
// contains filtered or unexported fields
}
CLIConfig represents the Command Line Args config
func (*CLIConfig) IsConfigWatcherStarted ¶
IsConfigWatcherStarted returns whether config watcher is running
func (*CLIConfig) IsMigrationEnabled ¶
IsMigrationEnabled returns whether migration is enabled
func (*CLIConfig) NotifyOnConfigFileChange ¶
func (conf *CLIConfig) NotifyOnConfigFileChange(callback func())
NotifyOnConfigFileChange registers a callback function for changes to ConfigPath; it calls the `callback` when a change is detected
func (*CLIConfig) SetCommandIfValid ¶
SetCommandIfValid sets the command if it's valid
func (*CLIConfig) StopWatcher ¶
func (conf *CLIConfig) StopWatcher()
StopWatcher stops any watcher if started for CLI ConfigPath file change
type CommandOption ¶
type CommandOption string
CommandOption represents the command to be run by the CLI
const ( // BrokerCMD represents the broker command BrokerCMD CommandOption = "broker" // PruneCMD represents the prune command PruneCMD CommandOption = "prune" )
type Config ¶
type Config struct {
DBDialect DBDialect
DBConnectionURL string
DBConnectionMaxIdleTime time.Duration
DBConnectionMaxLifetime time.Duration
DBMaxIdleConnections uint16
DBMaxOpenConnections uint16
HTTPListeningAddr string
HTTPReadTimeout time.Duration
HTTPWriteTimeout time.Duration
LogFilename string
MaxFileSize uint
MaxBackups uint
MaxAge uint
CompressBackupsEnabled bool
SeedData SeedData
TokenRequestHeaderName string
UserAgent string
ConnectionTimeout time.Duration
MaxMessageQueueSize uint
MaxWorkers uint
PriorityDispatcherEnabled bool
RecoveryWorkersEnabled bool
RetriggerBaseEndpoint string
MaxRetry uint8
RationalDelay time.Duration
RetryBackoffDelays []time.Duration
LogLevel LogLevel
// Message pruning configuration
ExportPath string
ExportNodeName string
MessageRetentionDays uint
RemoteExportDestination RemoteMessageDestination
RemoteExportURL *url.URL
RemoteFilePrefix string
MaxArchiveFileSizeInMB uint
// Scheduler configuration
SchedulerIntervalMs uint
MinScheduleDelayMinutes uint
SchedulerBatchSize uint
}
Config represents the application configuration
func GetAutoConfiguration ¶
GetAutoConfiguration gets configuration from default config and system defined path chain of /etc/webhook-broker/webhook-broker.cfg, {USER_HOME}/.webhook-broker/webhook-broker.cfg, webhook-broker.cfg (current dir)
func GetConfiguration ¶
GetConfiguration gets the current state of application configuration
func GetConfigurationFromCLIConfig ¶
GetConfigurationFromCLIConfig from CLIConfig.
func GetConfigurationFromParseConfig ¶
GetConfigurationFromParseConfig returns configuration from parsed configuration
func (*Config) GetConnectionTimeout ¶
GetConnectionTimeout returns the connection timeout from broker to consumer
func (*Config) GetDBConnectionMaxIdleTime ¶
GetDBConnectionMaxIdleTime returns the DB Connection max idle time
func (*Config) GetDBConnectionMaxLifetime ¶
GetDBConnectionMaxLifetime returns the DB Connection max lifetime
func (*Config) GetDBConnectionURL ¶
GetDBConnectionURL returns the DB Connection URL string
func (*Config) GetDBDialect ¶
GetDBDialect returns the DB dialect of the configuration
func (*Config) GetExportNodeName ¶
GetExportNodeName returns a prefix to be added to the exported file name.
func (*Config) GetExportPath ¶
GetExportPath returns the local filesystem path where messages will be exported before being uploaded.
func (*Config) GetHTTPListeningAddr ¶
GetHTTPListeningAddr retrieves the connection string to listen to
func (*Config) GetHTTPReadTimeout ¶
GetHTTPReadTimeout retrieves the connection read timeout
func (*Config) GetHTTPWriteTimeout ¶
GetHTTPWriteTimeout retrieves the connection write timeout
func (*Config) GetLogFilename ¶
GetLogFilename retrieves the file name of the log
func (*Config) GetLogLevel ¶
GetLogLevel returns the log level as per the configuration
func (*Config) GetMaxAgeForALogFile ¶
GetMaxAgeForALogFile retrieves maximum day to retain a rotated log file
func (*Config) GetMaxArchiveFileSizeInMB ¶
func (*Config) GetMaxIdleDBConnections ¶
GetMaxIdleDBConnections returns the maximum number of idle DB connections to retain in pool
func (*Config) GetMaxLogBackups ¶
GetMaxLogBackups retrieves max rotated logs to retain
func (*Config) GetMaxLogFileSize ¶
GetMaxLogFileSize retrieves the max log file size before its rotated in MB
func (*Config) GetMaxMessageQueueSize ¶
GetMaxMessageQueueSize returns the maximum number of messages to be queued without being dispatched
func (*Config) GetMaxOpenDBConnections ¶
GetMaxOpenDBConnections returns the maximum number of concurrent DB connections to keep open
func (*Config) GetMaxRetry ¶
GetMaxRetry returns the maximum number of attempts for delivering a message to a consumer
func (*Config) GetMaxWorkers ¶
GetMaxWorkers returns the max number of workers dispatching a message to a consumer
func (*Config) GetMessageRetentionDays ¶
GetMessageRetentionDays returns the number of days to retain messages for which all jobs have completed.
func (*Config) GetMinScheduleDelay ¶ added in v0.2.1
GetMinScheduleDelay returns the minimum delay required for scheduled messages
func (*Config) GetRationalDelay ¶
GetRationalDelay returns how long to wait before retriggering, i.e., what is the addition to picking up messages in fail-safe process.
func (*Config) GetRemoteExportDestination ¶
func (config *Config) GetRemoteExportDestination() RemoteMessageDestination
GetRemoteExportDestination returns the remote destination for exported messages (e.g., "s3" or "gcs").
func (*Config) GetRemoteExportURL ¶
GetRemoteExportURL returns the root URL for the remote export destination (e.g., S3 bucket URL or GCS bucket URL).
func (*Config) GetRemoteFilePrefix ¶
func (*Config) GetRetriggerBaseEndpoint ¶
GetRetriggerBaseEndpoint returns the URL to the load balanced endpoint for the broker for retriggering jobs
func (*Config) GetRetryBackoffDelays ¶
GetRetryBackoffDelays returns the delay steps in retrying delivery; retry will be the index and if index is greater than size use the last value times retry-attempt
func (*Config) GetSchedulerBatchSize ¶ added in v0.2.1
GetSchedulerBatchSize returns the maximum number of messages to process per scheduler run
func (*Config) GetSchedulerInterval ¶ added in v0.2.1
GetSchedulerInterval returns the interval between scheduler runs
func (*Config) GetSeedData ¶
GetSeedData returns the seed data configuration
func (*Config) GetTokenRequestHeaderName ¶
GetTokenRequestHeaderName returns the Token request header to pass to the consumers
func (*Config) GetUserAgent ¶
GetUserAgent returns the user agent string for consumer HTTP connection
func (*Config) IsCompressionEnabledOnLogBackups ¶
IsCompressionEnabledOnLogBackups checks if log backups are compressed
func (*Config) IsLoggerConfigAvailable ¶
IsLoggerConfigAvailable checks is logger configuration is set since its optional
func (*Config) IsPriorityDispatcherEnabled ¶
IsPriorityDispatcherEnabled returns whether priority will be respected during dispatching from queue
func (*Config) IsPruningEnabled ¶
IsPruningEnabled returns true if message pruning is enabled.
func (*Config) IsRecoveryWorkersEnabled ¶
IsRecoveryWorkersEnabled retrieves whether the recovery worker should be enabled or not
type ConsumerConnectionConfig ¶
type ConsumerConnectionConfig interface {
GetTokenRequestHeaderName() string
GetUserAgent() string
GetConnectionTimeout() time.Duration
}
ConsumerConnectionConfig provides the interface for working with consumer connection related configuration
type DBDialect ¶
type DBDialect string
DBDialect allows us to define constants for supported DB drivers
type HTTPConfig ¶
type HTTPConfig interface {
GetHTTPListeningAddr() string
GetHTTPReadTimeout() time.Duration
GetHTTPWriteTimeout() time.Duration
}
HTTPConfig represents the HTTP configuration related behaviors
type LogConfig ¶
type LogConfig interface {
GetLogLevel() LogLevel
IsLoggerConfigAvailable() bool
GetLogFilename() string
GetMaxLogFileSize() uint
GetMaxLogBackups() uint
GetMaxAgeForALogFile() uint
IsCompressionEnabledOnLogBackups() bool
}
LogConfig represents the interface for log related configuration
type MessagePruningConfig ¶
type MessagePruningConfig interface {
// IsPruningEnabled returns true if message pruning is enabled.
IsPruningEnabled() bool
// GetExportPath returns the local filesystem path where messages will be exported before being uploaded.
GetExportPath() string
// GetExportNodeName returns a prefix to be added to the exported file name.
GetExportNodeName() string
// GetMessageRetentionDays returns the number of days to retain messages for which all jobs have completed.
GetMessageRetentionDays() uint
// GetRemoteExportDestination returns the remote destination for exported messages (e.g., "s3" or "gcs").
GetRemoteExportDestination() RemoteMessageDestination
// GetRemoteExportURL returns the root URL for the remote export destination (e.g., S3 bucket URL or GCS bucket URL).
GetRemoteExportURL() *url.URL
// GetRemoteExportPrefix returns the prefix to be added to the exported file name when uploading to the remote destination.
GetRemoteFilePrefix() string
// GetMaxArchiveFileSizeInMB returns the maximum size of the exported file in MB before it is rotated to a new file
GetMaxArchiveFileSizeInMB() uint
}
MessagePruningConfig provides the interface for configuring message pruning.
type RelationalDatabaseConfig ¶
type RelationalDatabaseConfig interface {
GetDBDialect() DBDialect
GetDBConnectionURL() string
GetDBConnectionMaxIdleTime() time.Duration
GetDBConnectionMaxLifetime() time.Duration
GetMaxIdleDBConnections() uint16
GetMaxOpenDBConnections() uint16
}
RelationalDatabaseConfig represents DB configuration related behaviors
type RemoteMessageDestination ¶
type RemoteMessageDestination string
RemoteMessageDestination represents the destination for exported messages.
const ( // RemoteMessageDestinationS3 represents AWS S3 as the export destination. RemoteMessageDestinationS3 RemoteMessageDestination = "s3" // RemoteMessageDestinationGCS represents Google Cloud Storage as the export destination. RemoteMessageDestinationGCS RemoteMessageDestination = "gcs" )
type SchedulerConfig ¶ added in v0.2.1
type SchedulerConfig interface {
// GetSchedulerInterval returns the interval between scheduler runs
GetSchedulerInterval() time.Duration
// GetMinScheduleDelay returns the minimum delay required for scheduled messages
GetMinScheduleDelay() time.Duration
// GetSchedulerBatchSize returns the maximum number of messages to process per scheduler run
GetSchedulerBatchSize() int
}
SchedulerConfig represents configuration related to message scheduling
type SeedChannel ¶
type SeedChannel SeedProducer
SeedChannel represents pre configured channel via configuration
type SeedConsumer ¶
type SeedConsumer struct {
SeedProducer
// CallbackURL represents the URl to call back
CallbackURL *url.URL
// Channel represents which channel this consumer listens to
Channel string
Type string
}
SeedConsumer represents pre configured consumer via configuration
type SeedData ¶
type SeedData struct {
DataHash string
Producers []SeedProducer
Channels []SeedChannel
Consumers []SeedConsumer
}
SeedData represents data specified in configuration to ensure is present when app starts up
type SeedDataConfig ¶
type SeedDataConfig interface {
GetSeedData() SeedData
}
SeedDataConfig provides the interface for working with SeedData in configuration
type SeedProducer ¶
type SeedProducer struct {
// ID is the ID of the data
ID string
// Name is name of the data
Name string
// Token is the pre configured token of the data
Token string
}
SeedProducer represents the pre configured producer via configuration