utils

package
v0.0.0-...-e33f0fe Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package utils provides reusable and sharable utilities for other packages and components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeSerializeJob

func DeSerializeJob(jobBytes []byte) (*work.Job, error)

DeSerializeJob decodes bytes to ptr of work.Job.

func DirExists

func DirExists(path string) bool

DirExists check if the specified dir exists

func FileExists

func FileExists(file string) bool

FileExists check if the specified exists.

func IsEmptyStr

func IsEmptyStr(str string) bool

IsEmptyStr check if the specified str is empty (len ==0) after triming prefix and suffix spaces.

func IsValidPort

func IsValidPort(port uint) bool

IsValidPort check if port is valid.

func IsValidURL

func IsValidURL(address string) bool

IsValidURL validates if the url is well-formted

func KeyJobCtlCommands

func KeyJobCtlCommands(namespace string, jobID string) string

KeyJobCtlCommands give the key for publishing ctl commands like 'stop' etc.

func KeyJobStats

func KeyJobStats(namespace string, jobID string) string

KeyJobStats returns the key of job stats

func KeyNamespacePrefix

func KeyNamespacePrefix(namespace string) string

KeyNamespacePrefix returns the based key based on the namespace.

func KeyPeriod

func KeyPeriod(namespace string) string

KeyPeriod returns the key of period

func KeyPeriodicLock

func KeyPeriodicLock(namespace string) string

KeyPeriodicLock returns the key of locker under period

func KeyPeriodicNotification

func KeyPeriodicNotification(namespace string) string

KeyPeriodicNotification returns the key of periodic pub/sub channel.

func KeyPeriodicPolicy

func KeyPeriodicPolicy(namespace string) string

KeyPeriodicPolicy returns the key of periodic policies.

func KeyPeriodicPolicyScore

func KeyPeriodicPolicyScore(namespace string) string

KeyPeriodicPolicyScore returns the key of policy key and score mapping.

func MakeIdentifier

func MakeIdentifier() string

MakeIdentifier creates uuid for job.

func MakePeriodicPolicyUUID

func MakePeriodicPolicyUUID() (string, int64)

MakePeriodicPolicyUUID returns an UUID for the periodic policy.

func MakeUniquePeriodicID

func MakeUniquePeriodicID(name, spec string, epoch int64) string

MakeUniquePeriodicID creates id for the periodic job.

func NowEpochSeconds

func NowEpochSeconds() int64

NowEpochSeconds ...

func ReadEnv

func ReadEnv(key string) string

ReadEnv return the value of env variable.

func RedisKeyDead

func RedisKeyDead(namespace string) string

RedisKeyDead returns key of the dead jobs.

func RedisKeyLastPeriodicEnqueue

func RedisKeyLastPeriodicEnqueue(namespace string) string

RedisKeyLastPeriodicEnqueue returns key of timestamp if last periodic enqueue.

func RedisKeyScheduled

func RedisKeyScheduled(namespace string) string

RedisKeyScheduled returns key of scheduled job.

func RedisNamespacePrefix

func RedisNamespacePrefix(namespace string) string

RedisNamespacePrefix ... Same with 'KeyNamespacePrefix', only for compatiblity.

func SerializeJob

func SerializeJob(job *work.Job) ([]byte, error)

SerializeJob encodes work.Job to json data.

func SetNowEpochSecondsMock

func SetNowEpochSecondsMock(t int64)

SetNowEpochSecondsMock ...

func TranslateRedisAddress

func TranslateRedisAddress(commaFormat string) (string, bool)

TranslateRedisAddress translates the comma format to redis URL

Types

type JobScore

type JobScore struct {
	JobBytes []byte
	Score    int64
}

JobScore represents the data item with score in the redis db.

func GetZsetByScore

func GetZsetByScore(pool *redis.Pool, key string, scores []int64) ([]JobScore, error)

GetZsetByScore get the items from the zset filtered by the specified score scope.

Jump to

Keyboard shortcuts

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