Documentation
¶
Index ¶
- Constants
- func CompileRegexp(pattern string) *regexp.Regexp
- func CompileTemplate(temp string) (*template.Template, error)
- func EvalTemplate(temp *template.Template, params Parameters) (string, error)
- func FormatBytes(bytes uint64) string
- func FormatDuration(duration time.Duration) string
- func GetTemplateFunctions() template.FuncMap
- func ParseDuration(input string) (time.Duration, error)
- func RandString(n int) string
- func RegexpResultToParams(re *regexp.Regexp, match []string) map[string]string
- func RegisterFunctions(funcMap template.FuncMap)
- type IncreasingDelay
- type Parameters
- type ServerContext
- type TemplateFunctionProvider
Examples ¶
Constants ¶
const FullMatch = "match"
FullMatch is the key of the "Result" which contains the initial full string of the matching process todo remove this old shitty magic...
Variables ¶
This section is empty.
Functions ¶
func CompileRegexp ¶
CompileRegexp compiles a regexp to a unified regexp layout: - case insensitive - always match a full line -> implicitly adds "^" and "$"
func CompileTemplate ¶
CompileTemplate pre compiles a template and returns an error if an function is not available etc
func EvalTemplate ¶
func EvalTemplate(temp *template.Template, params Parameters) (string, error)
EvalTemplate renders the template
func FormatBytes ¶ added in v1.6.0
func FormatDuration ¶
FormatDuration shortens a duration string representation. e.g. "12m1.231001s" -> "12m1s"
func GetTemplateFunctions ¶ added in v1.7.0
GetTemplateFunctions returns a list of the currently available template functions which can be used in definedCommands or user specific commands
func ParseDuration ¶
ParseDuration also allowes other duration modifier like "min" or "sec" e.g. 12min10sec -> 12m10s
Example ¶
fmt.Println(ParseDuration("12min1sec"))
Output: 12m1s <nil>
func RandString ¶ added in v1.3.0
RandString get random string containing just letters and numbers todo search better crypto/ function to generate such string
func RegexpResultToParams ¶
RegexpResultToParams converts a regexp result into a simple string map...kind of deprecated
func RegisterFunctions ¶
RegisterFunctions will add a function to any template renderer
Types ¶
type IncreasingDelay ¶ added in v1.6.0
type IncreasingDelay struct {
// contains filtered or unexported fields
}
func GetIncreasingDelay ¶ added in v1.6.0
func GetIncreasingDelay(minDuration time.Duration, maxDuration time.Duration) IncreasingDelay
Returns a increasing duration to have less polling overhead but keep a higher frequency in the first day
given: min: 2, max: 9 Timeline: start max now Result: 22223333444455556666777788889999999999999999999
func (IncreasingDelay) GetNextDelay ¶ added in v1.6.0
func (d IncreasingDelay) GetNextDelay() time.Duration
type Parameters ¶
type ServerContext ¶ added in v1.6.3
func NewServerContext ¶ added in v1.6.3
func NewServerContext() *ServerContext
wrapper for ctx to simply add childs which have a blocking shutdown process -> make sure all stuff is closed properly before exit todo directly add term/kill handling
func (*ServerContext) ChildDone ¶ added in v1.6.3
func (c *ServerContext) ChildDone()
...mark a child shutdown as done (-> use this method in defer)
func (*ServerContext) RegisterChild ¶ added in v1.6.3
func (c *ServerContext) RegisterChild()
add a new child...
func (*ServerContext) StopTheWorld ¶ added in v1.6.3
func (c *ServerContext) StopTheWorld()
start the shutdown process