Documentation ¶
Overview ¶
Package config provides configuration for `supraworker` application.
Index ¶
- Constants
- Variables
- func ConvertMapStringToInterface(in map[string]string) map[string]interface{}
- func GetBool(section string) bool
- func GetIntSlice(section string, param string, def []int) []int
- func GetMapStringMapStringTemplatedDefault(section string, param string, def map[string]string) map[string]map[string]string
- func GetStringDefault(section string, def string) string
- func GetStringMapStringTemplated(section string, param string) map[string]string
- func GetStringMapStringTemplatedDefault(section string, param string, def map[string]string) map[string]string
- func GetStringMapStringTemplatedFromMap(section string, param string, from map[string]string) map[string]string
- func GetStringMapStringTemplatedFromMapDefault(section string, param string, from map[string]string, def map[string]string) map[string]string
- func GetStringTemplatedDefault(section string, def string) string
- func GetTimeDurationDefault(section string, param string, def time.Duration) (interval time.Duration)
- func LoadCfgForTests(t *testing.T, CfgFile string) (Config, Config)
- func NewTestServer(t *testing.T, in func() interface{}, out func(string)) *httptest.Server
- func ReinitializeConfig()
- func TestMain(m *testing.M)
- type ApiOperations
- type Config
- type UrlConf
Constants ¶
View Source
const (
// ProjectName defines project name
ProjectName = "supraworker"
)
Variables ¶
View Source
var ( // CfgFile defines Path to the config CfgFile string // ClientId defines Indentification for the instance. ClientId string // C defines main configuration structure. C Config = Config{ CallAPIDelaySec: int(2), NumActiveJobs: 0, NumFreeSlots: 0, NumWorkers: 0, } )
View Source
var ( //CFG_PREFIX_COMMUNICATOR defines parameter in the config for Communicators CFG_PREFIX_COMMUNICATOR = "communicator" CFG_PREFIX_COMMUNICATORS = "communicators" // HTTP Communicator tuning // User for allowed response codes definmition. CFG_PREFIX_ALLOWED_RESPONSE_CODES = "codes" // Defines backoff prefixes // More information at // https://github.com/cenkalti/backoff/blob/v4.0.2/exponential.go#L9 CFG_PREFIX_BACKOFF = "backoff" // MaxInterval caps the RetryInterval and not the randomized interval. CFG_PREFIX_BACKOFF_MAXINTERVAL = "maxinterval" // After MaxElapsedTime the ExponentialBackOff returns Stop. // It never stops if MaxElapsedTime == 0. CFG_PREFIX_BACKOFF_MAXELAPSEDTIME = "maxelapsedtime" CFG_PREFIX_BACKOFF_INITIALINTERVAL = "initialinterval" CFG_COMMUNICATOR_PARAMS_KEY = "params" CFG_INTERVAL_PARAMETER = "interval" )
Functions ¶
func ConvertMapStringToInterface ¶ added in v0.2.3
func GetIntSlice ¶ added in v0.2.3
GetIntSlice returns []int or default.
func GetMapStringMapStringTemplatedDefault ¶ added in v0.2.3
func GetMapStringMapStringTemplatedDefault(section string, param string, def map[string]string) map[string]map[string]string
GetMapStringMapStringTemplatedDefault returns map of [string]string maps templated & enriched by default.
func GetStringDefault ¶ added in v0.2.3
GetStringDefault return section string or default.
func GetStringMapStringTemplated ¶ added in v0.2.3
func GetStringMapStringTemplatedDefault ¶ added in v0.2.3
func GetStringMapStringTemplatedFromMap ¶ added in v0.2.3
func GetStringMapStringTemplatedFromMapDefault ¶ added in v0.2.3
func GetStringTemplatedDefault ¶ added in v0.2.0
func GetTimeDurationDefault ¶ added in v0.2.3
func GetTimeDurationDefault(section string, param string, def time.Duration) (interval time.Duration)
GetTimeDuration return delay for the section with default of 1 second. Example config: section:
interval: 5s
func LoadCfgForTests ¶ added in v0.2.3
func NewTestServer ¶ added in v0.2.3
Types ¶
type ApiOperations ¶
type ApiOperations struct { Run UrlConf `mapstructure:"run"` // defines how to run item Cancelation UrlConf `mapstructure:"cancelation"` // defines how to cancel item LogStreams UrlConf `mapstructure:"logstream"` // defines how to get item Get UrlConf `mapstructure:"get"` // defines how to get item Lock UrlConf `mapstructure:"lock"` // defines how to lock item Update UrlConf `mapstructure:"update"` // defines how to update item Unlock UrlConf `mapstructure:"unlock"` // defines how to unlock item Finish UrlConf `mapstructure:"finish"` // defines how to finish item Failed UrlConf `mapstructure:"failed"` // defines how to update on failed Cancel UrlConf `mapstructure:"cancel"` // defines how to update on cancel }
ApiOperations is defines operations structure
type Config ¶
type Config struct { // Indentification for the process ClientId string `mapstructure:"clientId"` NumActiveJobs int // Number of jobs NumFreeSlots int // Number of free jobs slots NumWorkers int ClusterId string ClusterPool string URL string // Used for overload URL for Tests "{{.URL}}" // delay between API calls to prevent Denial-of-service CallAPIDelaySec int `mapstructure:"api_delay_sec"` // represent API for Jobs JobsAPI ApiOperations `mapstructure:"jobs"` // LogsAPI ApiOperations `mapstructure:"logs"` HeartBeat ApiOperations `mapstructure:"heartbeat"` // Config version ConfigVersion string `mapstructure:"version"` }
Config is top level Configuration structure
type UrlConf ¶
type UrlConf struct { Url string `mapstructure:"url"` Method string `mapstructure:"method"` Headers map[string]string `mapstructure:"headers"` PreservedFields map[string]string `mapstructure:"preservedfields"` Params map[string]string `mapstructure:"params"` }
UrlConf defines all params for request.
Click to show internal directories.
Click to hide internal directories.