Documentation ¶
Index ¶
- Variables
- func ArgsMapToObject(args map[string]string, obj interface{}) error
- func BuildFullVersion() string
- func BuildVersion() string
- func ClearString(str string) string
- func ConvertToBool(v interface{}) (bool, error)
- func ConvertToFloat(v interface{}) (float64, error)
- func ConvertToInt64(v interface{}) (int64, error)
- func ConvertToString(v interface{}) (string, error)
- func DeleteElemFromSlice(s []string, i int) []string
- func DeleteTempDir() error
- func GetDefaultPath(productname string) string
- func GetDurationMap() map[string]string
- func GetHexColor(c color.Color) string
- func GetSectionsMap(jsonBytes []byte) (map[string]interface{}, error)
- func GetTempDir() (string, error)
- func KeysToLower(input map[string]string) map[string]string
- func MapToURLArgs(args map[string]string) url.Values
- func ObjectToArgsMap(obj interface{}) (map[string]string, error)
- func ParseBool(str string) bool
- func ParseHexColor(s string) (c color.RGBA, err error)
- func ReadBytesFromFile(filePath string, configFileDir string) []byte
- func ReadBytesFromUrl(url string) []byte
- func ReadObjectFromURL(url string, obj interface{}) error
- func ReadSectionWithDefaults(jsonBytes []byte, sectionName string, configStruct interface{}, ...) ([]byte, error)
- func RemoveSection(jsonBytes []byte, sectionName string) ([]byte, error)
- func StringCmpIgnoreCase(a string, b string) bool
- func StringEndsWith(input string, suffix string) bool
- func StringPtr(input string) *string
- func StringStartsWith(input string, prefix string) bool
- func StringToBool(input string) bool
- func StringToFloat64(input string) (float64, error)
- func StringToIdentifier(input string) string
- func StringToInt(input string) (int, error)
- func StringToLower(input string) string
- func URLArgsToJSON(args map[string][]string) []byte
- func URLArgsToMap(args url.Values) map[string]string
- func URLParseQuery(query string) (map[string]string, error)
- func WriteSection(jsonBytes []byte, sectionName string, configStruct interface{}, ...) ([]byte, error)
- func WriteSectionBytes(jsonBytes []byte, sectionName string, sectionBytes []byte) ([]byte, error)
- type CIMap
- type CIMapImpl
- func (fa *CIMapImpl[Val]) Get(key string) Val
- func (fa *CIMapImpl[Val]) GetLowerCaseKeys() []string
- func (fa *CIMapImpl[Val]) GetLowerCaseMap() map[string][]Val
- func (fa *CIMapImpl[Val]) GetLowerCaseMapJoined() map[string]string
- func (fa *CIMapImpl[Val]) GetLowerCaseMapOnlyFirst() map[string]Val
- func (fa *CIMapImpl[Val]) GetOrDefault(key string, defaultVal Val) Val
- func (fa *CIMapImpl[Val]) GetOriginalCase(key string) string
- func (fa *CIMapImpl[Val]) GetOriginalCaseMap() map[string][]Val
- func (fa *CIMapImpl[Val]) GetOriginalCaseMapJoined() map[string]string
- func (fa *CIMapImpl[Val]) GetOriginalCaseMapOnlyFirst() map[string]Val
- func (fa *CIMapImpl[Val]) GetOriginalKeys() []string
- func (fa *CIMapImpl[Val]) GetValues(key string) []Val
- func (fa *CIMapImpl[Val]) Has(key string) bool
- func (fa *CIMapImpl[Val]) IsEmpty() bool
- func (fa *CIMapImpl[Val]) MarshalJSON() ([]byte, error)
- type ConfigIncluder
- type ConfigReader
- func (c *ConfigReader) GetConfigDir() string
- func (c *ConfigReader) GetConfigFileContent() string
- func (c *ConfigReader) GetSectionBytes(sectionName string) ([]byte, error)
- func (c *ConfigReader) GetSectionNames() ([]string, error)
- func (c *ConfigReader) GetSectionNamesWithPrefix(prefix string) ([]string, error)
- func (c *ConfigReader) ReadObjectFromFile(obj interface{}, filename string) error
- func (c *ConfigReader) ReadObjectFromURL(obj interface{}, url string) error
- func (c *ConfigReader) ReadSectionWithDefaults(sectionName string, configStruct interface{}) error
- func (c *ConfigReader) RemoveFile(filename string) error
- func (c *ConfigReader) RemoveSection(sectionName string) error
- func (c *ConfigReader) SetConfigFileContent(newContent string) error
- func (c *ConfigReader) WriteBackConfigIfChanged() error
- func (c *ConfigReader) WriteObjectToFile(obj interface{}, filename string) error
- func (c *ConfigReader) WriteSection(sectionName string, configStruct interface{}, persistImmediately bool) error
- func (c *ConfigReader) WriteSectionBytes(sectionName string, sectionBytes []byte) error
- type TopKEntry
- type TopKList
Constants ¶
This section is empty.
Variables ¶
var ( Version = "dev" CommitHash = "n/a" BuildTime = "n/a" Branch = "n/a" StartTimestamp = time.Now() )
Functions ¶
func ArgsMapToObject ¶ added in v1.0.0
ArgsMapToObject converts a string map to an object via JSON encode/decode
func BuildFullVersion ¶ added in v1.2.0
func BuildFullVersion() string
func BuildVersion ¶ added in v1.2.0
func BuildVersion() string
func ClearString ¶ added in v1.0.0
func ConvertToBool ¶ added in v1.3.0
ConvertToBool converts a value to a bool
func ConvertToFloat ¶ added in v1.3.0
ConvertToFloat converts a value to a float64
func ConvertToInt64 ¶ added in v1.3.0
ConvertToInt64 converts a value to an int
func ConvertToString ¶ added in v1.3.0
ConvertToString converts a value to a string
func DeleteElemFromSlice ¶ added in v1.2.0
DeleteElemFromSlice swaps i-th and last Element and deletes the last
func DeleteTempDir ¶ added in v1.2.0
func DeleteTempDir() error
DeleteTempDir deletes the temp dir that was created when the process was started
func GetDefaultPath ¶
func GetDurationMap ¶ added in v1.2.0
GetDurationMap returns a map of typical durations for operator argument suggestions
func GetHexColor ¶ added in v1.2.0
GetHexColor returns the hex represantion of a Go-color
func GetSectionsMap ¶ added in v0.9.1
GetSectionsMap returns a map of section names (all lower case) to config-objects, the type of config-object depends on the section
func GetTempDir ¶ added in v1.2.0
GetTempDir returns the temp dir that was created when the process was started
func KeysToLower ¶ added in v1.3.0
KeysToLower converts all keys in a map to lower case (always returns a new map, even if the input map is nil)
func MapToURLArgs ¶ added in v1.3.0
MapToURLArgs converts a string map to a string map of arrays and splits multiple values per key
func ObjectToArgsMap ¶ added in v1.3.0
ObjectToArgsMap converts and object to a string map via JSON encode/decode
func ReadBytesFromFile ¶ added in v0.9.1
func ReadBytesFromUrl ¶ added in v0.9.1
func ReadObjectFromURL ¶ added in v1.0.0
ReadObjectFromURL decodes a JSON object from an http stream
func ReadSectionWithDefaults ¶
func ReadSectionWithDefaults(jsonBytes []byte, sectionName string, configStruct interface{}, configFileDir string) ([]byte, error)
ReadSectionWithDefaults parses the content of the first-level-JSON object in <sectionName> into configStruct
if the section exists, configStruct will first get overwritten by an optional included file, then by the contents of the section (append+overwrite in both cases), returns an empty byte-slice if the section does not exist, the serialized content of configStruct (assuming these are default values) is added to jsonBytes and returned
func RemoveSection ¶ added in v1.3.0
RemoveSection removes the given section from the config file, returns a byte-slice with the new content, empty byte slice if nothing was removed
func StringCmpIgnoreCase ¶ added in v1.3.0
StringCmpIgnoreCase compares two strings ignoring case
func StringEndsWith ¶ added in v1.3.0
func StringStartsWith ¶ added in v1.3.0
func StringToBool ¶ added in v1.3.0
StringToBool converts a string to a bool
func StringToFloat64 ¶ added in v1.3.0
StringToFloat64 converts a string to a float64
func StringToIdentifier ¶ added in v1.3.0
func StringToInt ¶ added in v1.3.0
StringToInt converts a string to an int
func StringToLower ¶ added in v1.3.0
StringToLower converts a string to lower case
func URLArgsToJSON ¶
URLArgsToJSON converts the string map of arrays to a string map of strings by dropping all but the first elements from the map, it returns the json serialization of the map
func URLArgsToMap ¶ added in v1.0.0
URLArgsToMap converts the string map of arrays to a string map of strings by joining multiple values per key this simplfies handling of single key-value pairs, while consciously sacrificing keys with multiple values
func URLParseQuery ¶ added in v1.3.0
URLParseQuery parses a query string and returns a map of the values
Types ¶
type CIMap ¶ added in v1.3.0
type CIMap[Val any] interface { // Has returns true if map contains a key Has(key string) bool // Get returns the first value stored for key or the default value if key is not in map Get(key string) Val // GetOrDefault returns the first value stored for key or the given default value if key is not in map GetOrDefault(key string, defaultVal Val) Val // GetValues returns all values stored for key GetValues(key string) []Val // GetLowerCaseKeys returns the stored keys in lower case GetLowerCaseKeys() []string // GetOriginalKeys returns the stored key in original case GetOriginalKeys() []string GetOriginalCase(key string) string // problematic -> what to do if key does not exist GetOriginalCaseMap() map[string][]Val GetOriginalCaseMapOnlyFirst() map[string]Val GetOriginalCaseMapJoined() map[string]Val GetLowerCaseMap() map[string][]Val GetLowerCaseMapOnlyFirst() map[string]Val GetLowerCaseMapJoined() map[string]Val IsEmpty() bool }
CIMap is a struct that can be used to pass arguments to a function
func NewStringCIMap ¶ added in v1.3.0
NewStringCIMap creates a new CIMap struct from the given map
type CIMapImpl ¶ added in v1.3.0
type CIMapImpl[Val any] struct { OriginalMap map[string][]Val // map with original case keys // contains filtered or unexported fields }
CIMapImpl is a struct similar to url.Values that allows case-insensitive comparisons but stores the orignal case it can be built from url.Values or a map[string]Val and preserves the case of the keys but allows accessing them in a case-insensitive way when inserting keys with different cases, they will be combined into one key with the first case used
func (*CIMapImpl[Val]) GetLowerCaseKeys ¶ added in v1.3.0
GetLowerCaseKeys returns the stored keys in lower case
func (*CIMapImpl[Val]) GetLowerCaseMap ¶ added in v1.3.0
GetLowerCaseMap returns a map of all keys in lower case
func (*CIMapImpl[Val]) GetLowerCaseMapJoined ¶ added in v1.3.0
GetLowerCaseMapJoined
func (*CIMapImpl[Val]) GetLowerCaseMapOnlyFirst ¶ added in v1.3.0
GetLowerCaseMapOnlyFirst returns a map of all keys in lower case with only a single value
func (*CIMapImpl[Val]) GetOrDefault ¶ added in v1.3.0
GetOrDefault returns the first value for the given key
func (*CIMapImpl[Val]) GetOriginalCase ¶ added in v1.3.0
GetOriginalCase returns the key in the correct variant (if multiple, whichever comes first)
func (*CIMapImpl[Val]) GetOriginalCaseMap ¶ added in v1.3.0
GetOriginalCaseMap returns a map of all keys in the original case (this will contain only one case-variant if multiple key with different cases were inserted)
func (*CIMapImpl[Val]) GetOriginalCaseMapJoined ¶ added in v1.3.0
GetOriginalCaseMapJoined
func (*CIMapImpl[Val]) GetOriginalCaseMapOnlyFirst ¶ added in v1.3.0
GetOriginalCaseMap returns a map of all keys in the original case (this will contain only one case-variant if multiple key with different cases were inserted)
func (*CIMapImpl[Val]) GetOriginalKeys ¶ added in v1.3.0
GetKeys returns the stored key in original case
func (*CIMapImpl[Val]) Has ¶ added in v1.3.0
Has returns true if the given key is present in any variant
func (*CIMapImpl[Val]) IsEmpty ¶ added in v1.3.0
IsEmpty returns true if there are no keys in the map
func (*CIMapImpl[Val]) MarshalJSON ¶ added in v1.3.0
MarshalJSON provides a custom marshaller with better readable time formats
type ConfigIncluder ¶
type ConfigReader ¶
type ConfigReader struct {
// contains filtered or unexported fields
}
func NewConfigReader ¶
func NewConfigReader(logger logrus.FieldLogger, configFilePath string) (*ConfigReader, error)
func (*ConfigReader) GetConfigDir ¶ added in v1.0.0
func (c *ConfigReader) GetConfigDir() string
GetConfigDir returns the basepath of the config file
func (*ConfigReader) GetConfigFileContent ¶ added in v1.0.0
func (c *ConfigReader) GetConfigFileContent() string
GetConfigFileContent returns the content of the config file
func (*ConfigReader) GetSectionBytes ¶ added in v0.9.1
func (c *ConfigReader) GetSectionBytes(sectionName string) ([]byte, error)
GetSectionBytes returns the bytes of the section given by sectionName
func (*ConfigReader) GetSectionNames ¶ added in v0.9.1
func (c *ConfigReader) GetSectionNames() ([]string, error)
GetSectionNames returns the names of all sections in the config file
func (*ConfigReader) GetSectionNamesWithPrefix ¶ added in v1.3.0
func (c *ConfigReader) GetSectionNamesWithPrefix(prefix string) ([]string, error)
GetSectionNamesWithPrefix returns the names of all sections in the config file that start with prefix
func (*ConfigReader) ReadObjectFromFile ¶ added in v1.0.0
func (c *ConfigReader) ReadObjectFromFile(obj interface{}, filename string) error
func (*ConfigReader) ReadObjectFromURL ¶ added in v1.0.0
func (c *ConfigReader) ReadObjectFromURL(obj interface{}, url string) error
func (*ConfigReader) ReadSectionWithDefaults ¶
func (c *ConfigReader) ReadSectionWithDefaults(sectionName string, configStruct interface{}) error
func (*ConfigReader) RemoveFile ¶ added in v1.2.0
func (c *ConfigReader) RemoveFile(filename string) error
func (*ConfigReader) RemoveSection ¶ added in v1.3.0
func (c *ConfigReader) RemoveSection(sectionName string) error
func (*ConfigReader) SetConfigFileContent ¶ added in v1.0.0
func (c *ConfigReader) SetConfigFileContent(newContent string) error
SetConfigFileContent validates the new Content and sets it if valid
func (*ConfigReader) WriteBackConfigIfChanged ¶
func (c *ConfigReader) WriteBackConfigIfChanged() error
func (*ConfigReader) WriteObjectToFile ¶ added in v1.0.0
func (c *ConfigReader) WriteObjectToFile(obj interface{}, filename string) error
func (*ConfigReader) WriteSection ¶ added in v0.9.1
func (c *ConfigReader) WriteSection(sectionName string, configStruct interface{}, persistImmediately bool) error
func (*ConfigReader) WriteSectionBytes ¶ added in v1.3.0
func (c *ConfigReader) WriteSectionBytes(sectionName string, sectionBytes []byte) error
type TopKList ¶ added in v1.3.0
type TopKList struct {
// contains filtered or unexported fields
}
TopKList is a top-k-list of strings with timestamps sorted by timestamp
func NewTopKList ¶ added in v1.3.0
NewTopKList creates a new TopKList