Documentation ¶
Index ¶
- Constants
- Variables
- func AsHash(o interface{}) string
- func AsXXHash(inputs ...[]byte) []byte
- func Divmod(numerator, denominator int64) (quotient, remainder int64)
- func EnvIsTrue(envVariable string) bool
- func GetAssetIDFromCache(customerID string, location string, assetID string) (DBassetID uint32, cacheHit bool)
- func GetAverageStateTimeFromCache(key string) (data []interface{}, cacheHit bool)
- func GetBackoffTime(retries int64, slotTime time.Duration, maximum time.Duration) (backoff time.Duration)
- func GetCalculatateLowSpeedStatesFromCache(from time.Time, to time.Time, assetID uint32) (processedStateArray []datamodel.StateEntry, cacheHit bool)
- func GetCustomerConfigurationFromCache(customerID string) (data datamodel.CustomerConfiguration, cacheHit bool)
- func GetDistinctProcessValuesFromCache(customerID string, location string, assetID string) (data []string, cacheHit bool)
- func GetMemcached(key string) (value interface{}, found bool)
- func GetProcessStatesFromCache(key string) (processedStateArray []datamodel.StateEntry, cacheHit bool)
- func GetProductIDFromCache(productName int32, DBassetID uint32) (DBProductId uint32, cacheHit bool)
- func GetRawCountsFromCache(assetID uint32, from time.Time, to time.Time) (data []datamodel.CountEntry, cacheHit bool)
- func GetRawShiftsFromCache(assetID uint32, from time.Time, to time.Time, ...) (data []datamodel.ShiftEntry, cacheHit bool)
- func GetStatesRawFromCache(assetID uint32, from time.Time, to time.Time, ...) (data []datamodel.StateEntry, cacheHit bool)
- func GetTiered(key string) (cached bool, value interface{})
- func GetUniqueProductIDFromCache(aid string, DBassetID uint32) (uid uint32, cacheHit bool)
- func InitCache(redisURI string, redisURI2 string, redisURI3 string, redisPassword string, ...)
- func InitMemcache()
- func IsInSliceFloat64(slice []float64, val float64) bool
- func IsInSliceInt32(slice []int32, val int32) bool
- func IsKafkaTopicValid(topic string) bool
- func IsRedisAvailable() bool
- func IsValidStruct(testStruct interface{}, allowedNilFields []string) (success bool)
- func Load(path string, v interface{}) error
- func LogObject(functionName string, objectName string, now time.Time, v interface{})
- func SanitizeByteArray(unsafebytearray []byte) (safestring string)
- func SanitizeString(unsafestring string) (safestring string)
- func SanitizeStringArray(unsafestringarray []string) (safestrings []string)
- func Save(path string, v interface{}) error
- func SaveIoddFile(vendorId int64, deviceId int, relativeDirectoryPath string) (err error)
- func SetMemcached(key string, value interface{})
- func SetMemcachedLong(key string, value interface{}, d time.Duration)
- func SetTiered(key string, value interface{}, redisExpiration time.Duration)
- func SetTieredLongTerm(key string, value interface{})
- func SetTieredShortTerm(key string, value interface{})
- func SleepBackedOff(retries int64, slotTime time.Duration, maximum time.Duration)
- func StoreAssetIDToCache(customerID string, location string, assetID string, DBassetID uint32)
- func StoreAverageStateTimeToCache(key string, data []interface{})
- func StoreCalculatateLowSpeedStatesToCache(from time.Time, to time.Time, assetID uint32, ...)
- func StoreCustomerConfigurationToCache(customerID string, data datamodel.CustomerConfiguration)
- func StoreDistinctProcessValuesToCache(customerID string, location string, assetID string, data []string)
- func StoreProcessStatesToCache(key string, processedStateArray []datamodel.StateEntry)
- func StoreProductIDToCache(productName int32, DBassetID uint32, DBProductId uint32)
- func StoreRawCountsToCache(assetID uint32, from time.Time, to time.Time, data []datamodel.CountEntry)
- func StoreRawShiftsToCache(assetID uint32, from time.Time, to time.Time, ...)
- func StoreRawStatesToCache(assetID uint32, from time.Time, to time.Time, ...)
- func StoreUniqueProductIDToCache(aid string, DBassetID uint32, uid uint32)
- func Uint128ToBytes(a xxh3.Uint128) (b []byte)
- func UniqueInt(input []int) []int
- type Content
- type IoDDFile
- type Ioddfinder
- type TopicInformation
- type Xy
Constants ¶
const Int64Max = 1<<63 - 1
Variables ¶
var FifteenSeconds = 15 * time.Second
var FiveSeconds = 5 * time.Second
var KafkaUMHTopicCompiledRegex = regexp.MustCompile(KafkaUMHTopicRegex)
var KafkaUMHTopicRegex = `` /* 378-byte string literal not displayed */
var Marshal = func(v interface{}) (io.Reader, error) { b, err := json.MarshalIndent(v, "", "\t") if err != nil { return nil, err } return bytes.NewReader(b), nil }
Marshal is a function that marshals the object into an io.Reader. By default, it uses the JSON marshaller.
var OneSecond = 1 * time.Second
var TenSeconds = 10 * time.Second
var Unmarshal = func(r io.Reader, v interface{}) error { return json.NewDecoder(r).Decode(v) }
Unmarshal is a function that unmarshals the data from the reader into the specified value. By default, it uses the JSON unmarshaller.
Functions ¶
func AsXXHash ¶
AsXXHash returns the XXHash128 of the given data. This hash is extremely fast and reasonable for use as a key in a cache. https://cyan4973.github.io/xxHash/
func Divmod ¶
Divmod allows division with remainder. Source: https://stackoverflow.com/questions/43945675/division-with-returning-quotient-and-remainder
func GetAssetIDFromCache ¶
func GetAssetIDFromCache(customerID string, location string, assetID string) (DBassetID uint32, cacheHit bool)
GetAssetIDFromCache gets asset id from cache
func GetAverageStateTimeFromCache ¶
GetAverageStateTimeFromCache gets average state time from cache
func GetBackoffTime ¶
func GetCalculatateLowSpeedStatesFromCache ¶
func GetCalculatateLowSpeedStatesFromCache(from time.Time, to time.Time, assetID uint32) (processedStateArray []datamodel.StateEntry, cacheHit bool)
GetCalculatateLowSpeedStatesFromCache get low speed states from cache
func GetCustomerConfigurationFromCache ¶
func GetCustomerConfigurationFromCache(customerID string) (data datamodel.CustomerConfiguration, cacheHit bool)
GetCustomerConfigurationFromCache gets customer configuration from cache
func GetDistinctProcessValuesFromCache ¶
func GetDistinctProcessValuesFromCache(customerID string, location string, assetID string) (data []string, cacheHit bool)
GetDistinctProcessValuesFromCache gets distinct process values from cache
func GetMemcached ¶
func GetProcessStatesFromCache ¶
func GetProcessStatesFromCache(key string) (processedStateArray []datamodel.StateEntry, cacheHit bool)
GetProcessStatesFromCache gets process states from cache
func GetProductIDFromCache ¶
GetProductIDFromCache gets Product from cache
func GetRawCountsFromCache ¶
func GetRawCountsFromCache(assetID uint32, from time.Time, to time.Time) (data []datamodel.CountEntry, cacheHit bool)
GetRawCountsFromCache gets raw counts from cache
func GetRawShiftsFromCache ¶
func GetRawShiftsFromCache(assetID uint32, from time.Time, to time.Time, configuration datamodel.CustomerConfiguration) (data []datamodel.ShiftEntry, cacheHit bool)
GetRawShiftsFromCache gets raw shifts from cache
func GetStatesRawFromCache ¶
func GetStatesRawFromCache(assetID uint32, from time.Time, to time.Time, configuration datamodel.CustomerConfiguration) (data []datamodel.StateEntry, cacheHit bool)
GetStatesRawFromCache gets raw states from cache
func GetUniqueProductIDFromCache ¶
GetUniqueProductIDFromCache gets uniqueProduct from cache
func InitCache ¶
func InitCache(redisURI string, redisURI2 string, redisURI3 string, redisPassword string, redisDB int, dryRun string)
InitCache initializes a redis cache
func InitMemcache ¶
func InitMemcache()
func IsInSliceFloat64 ¶
IsInSliceFloat64 takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false.
func IsInSliceInt32 ¶
IsInSliceInt32 takes a slice and looks for an element in it. If found it will return it's key, otherwise it will return -1 and a bool of false.
func IsKafkaTopicValid ¶
func IsRedisAvailable ¶
func IsRedisAvailable() bool
func IsValidStruct ¶
func Load ¶
Load loads the file at path into v. Use os.IsNotExist() to see if the returned error is due to the file being missing.
func SanitizeByteArray ¶
SanitizeByteArray formats the byte array and passes it through SanitizeString
func SanitizeString ¶
SanitizeString removes any rune that is not graphic and printable.
func SanitizeStringArray ¶
func SaveIoddFile ¶
func SetMemcached ¶
func SetMemcached(key string, value interface{})
func SetMemcachedLong ¶
func SetTieredLongTerm ¶
func SetTieredLongTerm(key string, value interface{})
SetTieredLongTerm is an helper, that calls SetTiered with default redis expiration
func SetTieredShortTerm ¶
func SetTieredShortTerm(key string, value interface{})
SetTieredShortTerm is an helper, that calls SetTiered with default memory expiration
func SleepBackedOff ¶
func StoreAssetIDToCache ¶
StoreAssetIDToCache stores asset id to cache
func StoreAverageStateTimeToCache ¶
func StoreAverageStateTimeToCache(key string, data []interface{})
StoreAverageStateTimeToCache stores average state time to cache
func StoreCalculatateLowSpeedStatesToCache ¶
func StoreCalculatateLowSpeedStatesToCache(from time.Time, to time.Time, assetID uint32, processedStateArray []datamodel.StateEntry)
StoreCalculatateLowSpeedStatesToCache stores low speed states to cache
func StoreCustomerConfigurationToCache ¶
func StoreCustomerConfigurationToCache(customerID string, data datamodel.CustomerConfiguration)
StoreCustomerConfigurationToCache stores customer configuration to cache
func StoreDistinctProcessValuesToCache ¶
func StoreDistinctProcessValuesToCache(customerID string, location string, assetID string, data []string)
StoreDistinctProcessValuesToCache stores distinct process values to cache
func StoreProcessStatesToCache ¶
func StoreProcessStatesToCache(key string, processedStateArray []datamodel.StateEntry)
StoreProcessStatesToCache stores process states to the cache
func StoreProductIDToCache ¶
StoreUniqueProductIDToCache stores uniqueProductID to cache
func StoreRawCountsToCache ¶
func StoreRawCountsToCache(assetID uint32, from time.Time, to time.Time, data []datamodel.CountEntry)
StoreRawCountsToCache stores raw counts to cache
func StoreRawShiftsToCache ¶
func StoreRawShiftsToCache(assetID uint32, from time.Time, to time.Time, configuration datamodel.CustomerConfiguration, data []datamodel.ShiftEntry)
StoreRawShiftsToCache stores raw shifts to cache
func StoreRawStatesToCache ¶
func StoreRawStatesToCache(assetID uint32, from time.Time, to time.Time, configuration datamodel.CustomerConfiguration, data []datamodel.StateEntry)
StoreRawStatesToCache stores raw states to cache
func StoreUniqueProductIDToCache ¶
StoreUniqueProductIDToCache stores uniqueProductID to cache
func Uint128ToBytes ¶
Uint128ToBytes converts a uint128 to a byte array
Types ¶
type Content ¶
type Content struct { HasMoreVersions bool `json:"hasMoreVersions"` DeviceID int64 `json:"deviceId"` IoLinkRev string `json:"ioLinkRev"` VersionString string `json:"versionString"` IoddID int64 `json:"ioddId"` ProductID string `json:"productId"` ProductVariantID int64 `json:"productVariantId"` ProductName string `json:"productName"` VendorName string `json:"vendorName"` UploadDate int64 `json:"uploadDate"` VendorID int64 `json:"vendorId"` IoddStatus string `json:"ioddStatus"` IndicationOfSource string `json:"indicationOfSource"` }
type IoDDFile ¶
IoDDFile is a helper structure with the name, file and additional context of the iodd file
type Ioddfinder ¶
type Ioddfinder struct { Content []Content `json:"content"` Number int64 `json:"number"` Size int64 `json:"size"` NumberOfElements int64 `json:"numberOfElements"` Sort []interface{} `json:"sort"` First bool `json:"first"` Last bool `json:"last"` TotalPages int64 `json:"totalPages"` TotalElements int64 `json:"totalElements"` }
func UnmarshalIoddfinder ¶
func UnmarshalIoddfinder(data []byte) (Ioddfinder, error)
func (*Ioddfinder) Marshal ¶
func (r *Ioddfinder) Marshal() ([]byte, error)
type TopicInformation ¶
type TopicInformation struct { AssetId string Location string CustomerId string Topic string ExtendedTopics []string TransmitterId *string MacAddressOfCamera *string }
func GetTopicInformationCached ¶
func GetTopicInformationCached(topic string) *TopicInformation
GetTopicInformationCached returns the topic information for the given topic. The topic information is cached in an LRU cache, resulting in up to 10x performance improvement.