Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

49
pkg/dbc/state/helpers.go Normal file
View File

@@ -0,0 +1,49 @@
package state
import (
"fmt"
"math"
"time"
)
const redisObjectExpire = 604800
const errInvalidValue = "invalid value %f"
func FloatToBool(input float64) interface{} {
return int(input) != 0
}
func RoundMilli(input float64) interface{} {
return math.Round(input*1000) / 1000
}
func RoundGPS(input float64) interface{} {
return math.Round(input*100000) / 100000
}
func IntCeil(input float64) interface{} {
return int(math.Ceil(input))
}
func IntFloor(input float64) interface{} {
return int(math.Floor(input))
}
func Int(input float64) interface{} {
return int(input)
}
// WHy does this return an array of bytes instead of a string, or a time.Time
func SerializeTimestampUSec(timestampUSec int) ([]byte, error) {
return time.UnixMicro(int64(timestampUSec)).UTC().MarshalJSON()
}
func GetMappedStrValues(valueMap map[float64]string) func(float64) interface{} {
return func(input float64) interface{} {
if value, ok := valueMap[input]; ok {
return value
}
return fmt.Sprintf(errInvalidValue, input)
}
}