util

package
v2.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Examples

Constants

View Source
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

func CompileRegexp(pattern string) *regexp.Regexp

CompileRegexp compiles a regexp to a unified regexp layout: - case insensitive - always match a full line -> implicitly adds "^" and "$"

func CompileTemplate

func CompileTemplate(temp string) (*template.Template, error)

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

func FormatBytes(bytes uint64) string

FormatBytes formats a given number of bytes in a simple human readable version

func FormatDuration

func FormatDuration(duration time.Duration) string

FormatDuration shortens a duration string representation. e.g. "12m1.231001s" -> "12m1s"

func FormatInt

func FormatInt(number int) string

FormatInt returns the given integer in a english representation (like 123,456,789)

func GetTemplateFunctions

func GetTemplateFunctions() template.FuncMap

GetTemplateFunctions returns a list of the currently available template functions which can be used in definedCommands or user specific commands

func ParseDuration

func ParseDuration(input string) (time.Duration, error)

ParseDuration also allows other duration modifier like "min" or "sec" e.g. 12min10sec -> 12m10s

Example
fmt.Println(ParseDuration("12min1sec"))
Output:

12m1s <nil>

func RegexpResultToParams

func RegexpResultToParams(re *regexp.Regexp, match []string) map[string]string

RegexpResultToParams converts a regexp result into a simple string map...kind of deprecated

func RegisterFunctions

func RegisterFunctions(funcMap template.FuncMap)

RegisterFunctions will add a function to any template renderer

Types

type GroupedLock added in v2.3.4

type GroupedLock[T string] struct {
	// contains filtered or unexported fields
}

func NewGroupedLogger added in v2.3.4

func NewGroupedLogger[T string]() GroupedLock[T]

func (*GroupedLock[T]) GetLock added in v2.3.4

func (l *GroupedLock[T]) GetLock(name T) sync.Locker

func (*GroupedLock[T]) GetRLock added in v2.3.4

func (l *GroupedLock[T]) GetRLock(name T) sync.Locker

type IncreasingDelay

type IncreasingDelay struct {
	// contains filtered or unexported fields
}

IncreasingDelay is a wrapper to support GetIncreasingDelay to have a increasing interval functionality

func GetIncreasingDelay

func GetIncreasingDelay(minDuration time.Duration, maxDuration time.Duration) IncreasingDelay

GetIncreasingDelay 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

func (d IncreasingDelay) GetNextDelay() time.Duration

GetNextDelay returns a time.Duration based on the given context

type MutexBuffer

type MutexBuffer struct {
	// contains filtered or unexported fields
}

MutexBuffer is a goroutine safe bytes.Buffer

func (*MutexBuffer) Read

func (s *MutexBuffer) Read(p []byte) (n int, err error)

Write returns the current buffer

func (*MutexBuffer) String

func (s *MutexBuffer) String() string

String returns the contents of the unread portion of the buffer as a string. If the MutexBuffer is a nil pointer, it returns "<nil>".

func (*MutexBuffer) Write

func (s *MutexBuffer) Write(p []byte) (n int, err error)

Write appends the contents of p to the buffer, growing the buffer as needed. It returns the number of bytes written.

type Parameters

type Parameters map[string]string

Parameters is a wrapper for a map[string]string which is the default set of passing template variables

type Reaction

type Reaction string

Reaction representation for a reaction/emoji. It can be the "id" of the reaction (like "smile", or the actual Unicode char, like "😄")

func (Reaction) GetChar

func (r Reaction) GetChar() string

GetChar get the real string/unicode representation of the current reaction/emoji

func (Reaction) ToSlackReaction

func (r Reaction) ToSlackReaction() string

ToSlackReaction uses the "id" of the reaction/Emoji, like "smile". It trims potential ":"

type ServerContext

type ServerContext struct {
	context.Context
	// contains filtered or unexported fields
}

ServerContext is an extended context.Context to be able to wait for all children to have a proper shutdown

func NewServerContext

func NewServerContext() *ServerContext

NewServerContext wrapper for ctx to simply add children which have a blocking shutdown process -> make sure all stuff is closed properly before exit

func (*ServerContext) ChildDone

func (c *ServerContext) ChildDone()

ChildDone ...mark a child shutdown as done (-> use this method in defer)

func (*ServerContext) RegisterChild

func (c *ServerContext) RegisterChild()

RegisterChild adds a new child...

func (*ServerContext) StopTheWorld

func (c *ServerContext) StopTheWorld()

StopTheWorld start the shutdown process

type TemplateFunctionProvider

type TemplateFunctionProvider interface {
	GetTemplateFunction() template.FuncMap
}

TemplateFunctionProvider can be provided by Commands to register template functions to the internal parser. example: "{{ jiraTicketUrl $ticket.Key }}" can be used in custom commands which is provided by the "jiraCommand"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL