Documentation
¶
Index ¶
- Constants
- func BeginningLastMonth() time.Time
- func BeginningNextMonth() time.Time
- func BeginningOf28thDayOfMonth(month, year int) time.Time
- func BeginningOfInputMonth(month, year int) time.Time
- func BeginningOfLastMonth() time.Time
- func BeginningOfMonth() time.Time
- func BeginningOfNextMonth() time.Time
- func EndOfInputMonth(month, year int) time.Time
- func EndOfLastMonth() time.Time
- func EndOfMonth() time.Time
- func Float64Ptr(input float64) *float64
- func GetBeginningOfNextMonth() time.Time
- func GetBeginningOfThisMonth() time.Time
- func GetCurrentMonthString() string
- func GetEnv(key string, defaultValue string) string
- func GetNextMonthString() string
- func GetTime() *string
- func GetTimeSinceStartOfMonth() string
- func IsPtrNil(v any) bool
- func LogError(deploymentId uuid.UUID, message string, err error)
- func LogFuncExecTime(log zerolog.Logger, funcName string, callbacks ...func(startTime time.Time)) func()
- func LogInfo(deploymentId uuid.UUID, message string)
- func MapStringToUUID(arr []string) ([]uuid.UUID, error)
- func NoOfDaysInLastMonth() int
- func NoOfDaysInMonth() int
- func NoOp()
- func PostgresArrayToStrings(s string) ([]string, error)
- func SetDate(t time.Time, day int) time.Time
- func SetDateAndHour(t time.Time, day int, hour int) time.Time
- func TimeDiff(a, b time.Time) (year, month, day, hour, min, sec int)
- func TimeDiffString(a, b time.Time) (timeString string)
- func TimePtr(input time.Time) *time.Time
- func ToAnyMap[K comparable, E any](input map[K]E) map[K]any
- type JsonList
- type StringList
- type StringMap
Constants ¶
const ( XHasuraRole = "x-hasura-role" XHasuraUserID = "x-hasura-user-id" XHasuraUserEmail = "x-hasura-user-email" XHasuraIsSAMLUser = "x-hasura-user-saml" // Returned only for metrics role XHasuraAllowedProjectIDs = "x-hasura-allowed-project-ids" XHasuraAllowedMetricsProjectIDs = "x-hasura-allowed-metrics-project-Ids" XHasuraAdminProjectIDs = "x-hasura-admin-project-ids" // Returned for licensing public role Authorization = "Authorization" SUBSCRIPTION_DATE = 1 )
Variables ¶
This section is empty.
Functions ¶
func BeginningLastMonth ¶
func BeginningNextMonth ¶
func BeginningOfInputMonth ¶
func BeginningOfLastMonth ¶
func BeginningOfMonth ¶
func BeginningOfNextMonth ¶
BeginningOfNextMonth returns the absolute beginning of the next month
func EndOfInputMonth ¶
func EndOfLastMonth ¶
func EndOfMonth ¶
func Float64Ptr ¶
Float64Ptr returns pointer of the float64 input
func GetBeginningOfNextMonth ¶
GetBeginningOfNextMonth returns the date at which the new billing cycle kicks in
func GetBeginningOfThisMonth ¶
func GetCurrentMonthString ¶
func GetCurrentMonthString() string
func GetNextMonthString ¶
func GetNextMonthString() string
func GetTimeSinceStartOfMonth ¶
func GetTimeSinceStartOfMonth() string
GetTimeSinceStartOfMonth returns the string of time since the start of the month in the same format as `time.Since`
func LogFuncExecTime ¶
func LogFuncExecTime(log zerolog.Logger, funcName string, callbacks ...func(startTime time.Time)) func()
LogFuncExecTime logs the execution time of a function and can (optionally) execute callback functions. Example of a potential callback is to raise an alert if the execution time is high. This is best suited to be called as a deferred function at the start of the target function. For usage example, refer `CheckDataUsageComponents` in the `api` service.
func MapStringToUUID ¶
MapStringToUUID parse array strings to uuids
func NoOfDaysInLastMonth ¶
func NoOfDaysInLastMonth() int
func PostgresArrayToStrings ¶
PostgresArrayToStrings convert postgres array to string array
func TimeDiff ¶
TimeDiff calculates the absolute difference between 2 time instances in years, months, days, hours, minutes and seconds.
For details, see https://stackoverflow.com/a/36531443/1705598
func TimeDiffString ¶
TimeDiffString returns a string similar to the Duration type. It runs the TimeDiff function internally. Please note that this only works for returning correct strings for days, hours, minutes and seconds. In case you're using this function for Prometheus queries that stretch over years or months, please do not use this function since Prometheus supports the following durations: milliseconds, seconds, minutes, hours, weeks and years. With weeks being involved in between, due to the nature of TimeDiff, this function will not provide the correct result.
Examples:
TimeDiffString(time.Now(), time.Now().Add(-12 * time.Minute)) // 12m TimeDiffString(time.Now().Add(-365 * 24 * time.Hour), time.Now()) // -8760h0m0s
func ToAnyMap ¶
func ToAnyMap[K comparable, E any](input map[K]E) map[K]any
ToAnyMap a generic function to convert the input map to any map
Types ¶
type JsonList ¶
type JsonList []string
JsonList stores strings representing json
func (JsonList) ToJson ¶
ToJson serializes the JSON List into a valid JSON array. Elements are not marshalled, because they are json already
func (JsonList) ToJsonSingleElementOrArray ¶
ToJsonSingleElementOrArray serializes a list containing a single element into that element's JSON; and into an array if it contains multiple elements.
type StringList ¶
type StringList []string
StringList stores string values
func (*StringList) Add ¶
func (sl *StringList) Add(values ...string)
Add append new value or skip if it's existing
func (StringList) Compact ¶
func (sl StringList) Compact() StringList
Compact returns a copy of the string list with empty elements removed
func (StringList) String ¶
func (sl StringList) String() string
String implements the Stringer interface
func (StringList) ToJson ¶
func (sl StringList) ToJson() []byte
ToJson serializes the StringList into Json
func (StringList) UniqueString ¶
func (sl StringList) UniqueString() string
UniqueString creates a string of comma separated unique values sorted alphabetically