Documentation
¶
Index ¶
- func CalculateInterval(from, to Timestamp) (rFrom, rTo Timestamp, interval time.Duration)
- func CreateTimeSeries[T any](name string, from, to Timestamp, interval time.Duration, initValue T) (series Entity)
- func DockerUtils() (du *dockerUtils)
- func HashUtils() *hashUtils
- func HistogramTimeSeries(name string, from, to Timestamp, interval time.Duration, ...) (series Entity)
- func JsonUtils() *jsonUtils
- func PrintBanner(banner string)
- func RecoverAll(cb func(v any))
- func RecoverAny(errors []error, cb func(v any))
- func RecoverOne(e error, cb func(v any))
- func SetSecret(secret, vector []byte) error
- func StringUtils() *stringUtils
- type DockerContainer
- func (c *DockerContainer) AutoRemove(value bool) *DockerContainer
- func (c *DockerContainer) EntryPoint(args ...string) *DockerContainer
- func (c *DockerContainer) Exists() bool
- func (c *DockerContainer) IsRunning() bool
- func (c *DockerContainer) Label(label, value string) *DockerContainer
- func (c *DockerContainer) Labels(label map[string]string) *DockerContainer
- func (c *DockerContainer) Name(value string) *DockerContainer
- func (c *DockerContainer) Port(external, internal string) *DockerContainer
- func (c *DockerContainer) Ports(ports map[string]string) *DockerContainer
- func (c *DockerContainer) Run() error
- func (c *DockerContainer) Stop() error
- func (c *DockerContainer) Var(key, value string) *DockerContainer
- func (c *DockerContainer) Vars(vars map[string]string) *DockerContainer
- type HttpUtilsStruct
- func (u *HttpUtilsStruct) New(method, url string) *HttpUtilsStruct
- func (u *HttpUtilsStruct) Send() (*http.Response, error)
- func (u *HttpUtilsStruct) WithBody(body string) *HttpUtilsStruct
- func (u *HttpUtilsStruct) WithHeader(key, value string) *HttpUtilsStruct
- func (u *HttpUtilsStruct) WithHeaders(headers map[string]string) *HttpUtilsStruct
- func (u *HttpUtilsStruct) WithTimeout(timeout int) *HttpUtilsStruct
- type TimeUtilsStruct
- func (t *TimeUtilsStruct) ConvertISO8601Format(format string) string
- func (t *TimeUtilsStruct) DayRange() TimeFrame
- func (t *TimeUtilsStruct) Format(format string) string
- func (t *TimeUtilsStruct) Get() Timestamp
- func (t *TimeUtilsStruct) GetSeries(end Timestamp, interval time.Duration) (series []Timestamp)
- func (t *TimeUtilsStruct) GetSeriesMap(end Timestamp, interval time.Duration) map[Timestamp]int
- func (t *TimeUtilsStruct) GetTimeFrames(end Timestamp, interval time.Duration) (series []TimeFrame)
- func (t *TimeUtilsStruct) GetTimeFramesMap(end Timestamp, interval time.Duration) map[Timestamp]TimeFrame
- func (t *TimeUtilsStruct) LowerBound(duration time.Duration) *TimeUtilsStruct
- func (t *TimeUtilsStruct) MonthRange() TimeFrame
- func (t *TimeUtilsStruct) SetInterval(someFunc func(), milliseconds int, async bool) chan bool
- func (t *TimeUtilsStruct) UpperBound(duration time.Duration) *TimeUtilsStruct
- type TokenUtilsStruct
- func (t *TokenUtilsStruct) CreateApiKey(appName string) (string, error)
- func (t *TokenUtilsStruct) CreateToken(claims *jwt.RegisteredClaims) (string, error)
- func (t *TokenUtilsStruct) ParseApiKey(apiKey string) (string, error)
- func (t *TokenUtilsStruct) ParseToken(tokenString string) (*jwt.RegisteredClaims, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculateInterval ¶ added in v1.2.143
CalculateInterval returns the preferred time interval based on the time period
func CreateTimeSeries ¶ added in v1.2.143
func CreateTimeSeries[T any](name string, from, to Timestamp, interval time.Duration, initValue T) (series Entity)
CreateTimeSeries creates a blank time series for the provided time period based on the time interval
func DockerUtils ¶ added in v1.1.5
func DockerUtils() (du *dockerUtils)
DockerUtils is a simple utility to execute docker commands using shell This utility does not us the docker client library (due to compatability issues) but instead utilizes the shell command executor (from os/exec package). The pre-requisite
func HashUtils ¶
func HashUtils() *hashUtils
HashUtils is a factory method that acts as a static member
func HistogramTimeSeries ¶ added in v1.2.143
func HistogramTimeSeries(name string, from, to Timestamp, interval time.Duration, hist map[Timestamp]Tuple[int64, float64]) (series Entity)
HistogramTimeSeries converts histogram to a sorted and consecutive time series
func PrintBanner ¶ added in v1.2.89
func PrintBanner(banner string)
PrintBanner displays the application's banner and lists all configuration variables along with their values in alphabetical order. This function is designed to provide a clear overview of the application's current configuration state at startup or when needed, facilitating easier debugging and configuration verification. It ensures that the configuration variables are presented in a sorted manner for quick reference and readability.
func RecoverAll ¶
func RecoverAll(cb func(v any))
RecoverAll performs recover for all panics.
Sample usage:
defer RecoverAll(func(err any) {
fmt.Printf("got error: %s", err)
})
func RecoverAny ¶
RecoverAny calls the callback function: cb with recovered value in case when recovered value exists in slice errors.
Sample usage:
defer recover.Any([]error{ErrorUsernameBlank, ErrorUsernameAlreadyTaken}, func(err any) {
fmt.Printf("got error: %s", err)
})
func RecoverOne ¶
RecoverOne calls the callback function: cb with recovered value in case when recovered value equals to e otherwise panic won't be recovered and will be propagated.
Sample usage:
defer recover.One(ErrorUsernameBlank, func(err any) {
fmt.Printf("got error: %s", err)
})
Types ¶
type DockerContainer ¶ added in v1.1.5
type DockerContainer struct {
// contains filtered or unexported fields
}
DockerContainer is used to construct docker container spec for the docker engine.
func (*DockerContainer) AutoRemove ¶ added in v1.1.5
func (c *DockerContainer) AutoRemove(value bool) *DockerContainer
AutoRemove determines whether to automatically remove the container when it has stopped
func (*DockerContainer) EntryPoint ¶ added in v1.1.5
func (c *DockerContainer) EntryPoint(args ...string) *DockerContainer
EntryPoint sets the entrypoint arguments of the container.
func (*DockerContainer) Exists ¶ added in v1.1.5
func (c *DockerContainer) Exists() bool
Exists return true if the container exists
func (*DockerContainer) IsRunning ¶ added in v1.1.7
func (c *DockerContainer) IsRunning() bool
IsRunning return true if the container exists and running
func (*DockerContainer) Label ¶ added in v1.1.5
func (c *DockerContainer) Label(label, value string) *DockerContainer
Label adds custom label
func (*DockerContainer) Labels ¶ added in v1.1.5
func (c *DockerContainer) Labels(label map[string]string) *DockerContainer
Labels adds multiple labels
func (*DockerContainer) Name ¶ added in v1.1.5
func (c *DockerContainer) Name(value string) *DockerContainer
Name sets the container name.
func (*DockerContainer) Port ¶ added in v1.1.5
func (c *DockerContainer) Port(external, internal string) *DockerContainer
Port adds a port mapping
func (*DockerContainer) Ports ¶ added in v1.1.5
func (c *DockerContainer) Ports(ports map[string]string) *DockerContainer
Ports adds multiple port mappings
func (*DockerContainer) Run ¶ added in v1.1.5
func (c *DockerContainer) Run() error
Run builds and run command
func (*DockerContainer) Stop ¶ added in v1.1.5
func (c *DockerContainer) Stop() error
Stop and kill container
func (*DockerContainer) Var ¶ added in v1.1.5
func (c *DockerContainer) Var(key, value string) *DockerContainer
Var adds an environment variable
func (*DockerContainer) Vars ¶ added in v1.1.5
func (c *DockerContainer) Vars(vars map[string]string) *DockerContainer
Vars adds multiple environment variables
type HttpUtilsStruct ¶ added in v1.2.106
type HttpUtilsStruct struct {
TimeoutSec int
// contains filtered or unexported fields
}
func HttpUtils ¶ added in v1.2.106
func HttpUtils() *HttpUtilsStruct
HttpUtils is a factory method that acts as a static member
func (*HttpUtilsStruct) New ¶ added in v1.2.106
func (u *HttpUtilsStruct) New(method, url string) *HttpUtilsStruct
func (*HttpUtilsStruct) Send ¶ added in v1.2.106
func (u *HttpUtilsStruct) Send() (*http.Response, error)
func (*HttpUtilsStruct) WithBody ¶ added in v1.2.106
func (u *HttpUtilsStruct) WithBody(body string) *HttpUtilsStruct
func (*HttpUtilsStruct) WithHeader ¶ added in v1.2.106
func (u *HttpUtilsStruct) WithHeader(key, value string) *HttpUtilsStruct
func (*HttpUtilsStruct) WithHeaders ¶ added in v1.2.106
func (u *HttpUtilsStruct) WithHeaders(headers map[string]string) *HttpUtilsStruct
func (*HttpUtilsStruct) WithTimeout ¶ added in v1.2.106
func (u *HttpUtilsStruct) WithTimeout(timeout int) *HttpUtilsStruct
type TimeUtilsStruct ¶ added in v1.2.143
type TimeUtilsStruct struct {
SECOND uint64
MINUTE uint64
HOUR uint64
DAY uint64
// contains filtered or unexported fields
}
TimeUtilsStruct internal helper
func TimeUtils ¶ added in v1.2.26
func TimeUtils(ts Timestamp) *TimeUtilsStruct
TimeUtils is a factory method
func (*TimeUtilsStruct) ConvertISO8601Format ¶ added in v1.2.143
func (t *TimeUtilsStruct) ConvertISO8601Format(format string) string
ConvertISO8601Format converts ISO6801 datetime format to Go RFC3339 format (used by Go)
func (*TimeUtilsStruct) DayRange ¶ added in v1.2.143
func (t *TimeUtilsStruct) DayRange() TimeFrame
DayRange create the boundaries of a day (start to end)
func (*TimeUtilsStruct) Format ¶ added in v1.2.143
func (t *TimeUtilsStruct) Format(format string) string
Format converts Epoch milliseconds timestamp to readable string, if format is empty, the default layout (RFC3339) is used
func (*TimeUtilsStruct) Get ¶ added in v1.2.143
func (t *TimeUtilsStruct) Get() Timestamp
Get returns the current timestamp
func (*TimeUtilsStruct) GetSeries ¶ added in v1.2.143
func (t *TimeUtilsStruct) GetSeries(end Timestamp, interval time.Duration) (series []Timestamp)
GetSeries creates a time series from the base time to the end time with the given interval
func (*TimeUtilsStruct) GetSeriesMap ¶ added in v1.2.143
func (t *TimeUtilsStruct) GetSeriesMap(end Timestamp, interval time.Duration) map[Timestamp]int
GetSeriesMap creates a time series from the base time to the end time with the given interval as a map
func (*TimeUtilsStruct) GetTimeFrames ¶ added in v1.2.143
func (t *TimeUtilsStruct) GetTimeFrames(end Timestamp, interval time.Duration) (series []TimeFrame)
GetTimeFrames creates time frames from the base time to the end time with the given interval with delay between slots
func (*TimeUtilsStruct) GetTimeFramesMap ¶ added in v1.2.143
func (t *TimeUtilsStruct) GetTimeFramesMap(end Timestamp, interval time.Duration) map[Timestamp]TimeFrame
GetTimeFramesMap creates time frames from the base time to the end time with the given interval as a map
func (*TimeUtilsStruct) LowerBound ¶ added in v1.2.143
func (t *TimeUtilsStruct) LowerBound(duration time.Duration) *TimeUtilsStruct
LowerBound return the floor value of the timestamp to the lowest time duration Supported duration values: * time.Minute - get the lower bound by minute * time.Hour - get the lower bound by hour * time.Hour * 24 - get the lower bound by day
func (*TimeUtilsStruct) MonthRange ¶ added in v1.2.143
func (t *TimeUtilsStruct) MonthRange() TimeFrame
MonthRange gets the local timestamp boundaries of a month
func (*TimeUtilsStruct) SetInterval ¶ added in v1.2.143
func (t *TimeUtilsStruct) SetInterval(someFunc func(), milliseconds int, async bool) chan bool
SetInterval create periodic time triggered function call
func (*TimeUtilsStruct) UpperBound ¶ added in v1.2.143
func (t *TimeUtilsStruct) UpperBound(duration time.Duration) *TimeUtilsStruct
UpperBound return the ceiling value of the timestamp to the next time duration Supported duration values: * time.Minute - get the upper bound by minute * time.Hour - get the upper bound by hour * time.Hour * 24 - get the upper bound by day
type TokenUtilsStruct ¶ added in v1.2.103
type TokenUtilsStruct struct {
}
func TokenUtils ¶ added in v1.1.2
func TokenUtils() *TokenUtilsStruct
TokenUtils is a factory method that acts as a static member
func (*TokenUtilsStruct) CreateApiKey ¶ added in v1.2.103
func (t *TokenUtilsStruct) CreateApiKey(appName string) (string, error)
CreateApiKey generate API Key from application name
func (*TokenUtilsStruct) CreateToken ¶ added in v1.2.103
func (t *TokenUtilsStruct) CreateToken(claims *jwt.RegisteredClaims) (string, error)
CreateToken build JWT token from Token Data structure
func (*TokenUtilsStruct) ParseApiKey ¶ added in v1.2.103
func (t *TokenUtilsStruct) ParseApiKey(apiKey string) (string, error)
ParseApiKey extract application name from API key
func (*TokenUtilsStruct) ParseToken ¶ added in v1.2.103
func (t *TokenUtilsStruct) ParseToken(tokenString string) (*jwt.RegisteredClaims, error)
ParseToken rebuild Token Data structure from JWT token
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cache Cache item implementation Based on https://github.com/ReneKroon/ttlcache
|
Package cache Cache item implementation Based on https://github.com/ReneKroon/ttlcache |
|
Package cache2 Cache item old implementation Based on https://github.com/ReneKroon/ttlcache
|
Package cache2 Cache item old implementation Based on https://github.com/ReneKroon/ttlcache |