utils

package
v1.5.0-rc5 Latest Latest
Warning

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

Go to latest
Published: May 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 added in v1.5.0

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

DeSerializeJob decodes bytes to ptr of work.Job.

func DirExists added in v1.5.0

func DirExists(path string) bool

DirExists check if the specified dir exists

func FileExists added in v1.5.0

func FileExists(file string) bool

FileExists check if the specified exists.

func IsEmptyStr added in v1.5.0

func IsEmptyStr(str string) bool

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

func IsValidPort added in v1.5.0

func IsValidPort(port uint) bool

IsValidPort check if port is valid.

func IsValidURL added in v1.5.0

func IsValidURL(address string) bool

IsValidURL validates if the url is well-formted

func KeyJobCtlCommands added in v1.5.0

func KeyJobCtlCommands(namespace string, jobID string) string

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

func KeyJobStats added in v1.5.0

func KeyJobStats(namespace string, jobID string) string

KeyJobStats returns the key of job stats

func KeyNamespacePrefix added in v1.5.0

func KeyNamespacePrefix(namespace string) string

KeyNamespacePrefix returns the based key based on the namespace.

func KeyPeriod added in v1.5.0

func KeyPeriod(namespace string) string

KeyPeriod returns the key of period

func KeyPeriodicLock added in v1.5.0

func KeyPeriodicLock(namespace string) string

KeyPeriodicLock returns the key of locker under period

func KeyPeriodicNotification added in v1.5.0

func KeyPeriodicNotification(namespace string) string

KeyPeriodicNotification returns the key of periodic pub/sub channel.

func KeyPeriodicPolicy added in v1.5.0

func KeyPeriodicPolicy(namespace string) string

KeyPeriodicPolicy returns the key of periodic policies.

func KeyPeriodicPolicyScore added in v1.5.0

func KeyPeriodicPolicyScore(namespace string) string

KeyPeriodicPolicyScore returns the key of policy key and score mapping.

func MakeIdentifier added in v1.5.0

func MakeIdentifier() string

MakeIdentifier creates uuid for job.

func MakePeriodicPolicyUUID added in v1.5.0

func MakePeriodicPolicyUUID() (string, int64)

MakePeriodicPolicyUUID returns an UUID for the periodic policy.

func MakeUniquePeriodicID added in v1.5.0

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

MakeUniquePeriodicID creates id for the periodic job.

func NowEpochSeconds added in v1.5.0

func NowEpochSeconds() int64

NowEpochSeconds ...

func ReadEnv added in v1.5.0

func ReadEnv(key string) string

ReadEnv return the value of env variable.

func RedisKeyDead added in v1.5.0

func RedisKeyDead(namespace string) string

RedisKeyDead returns key of the dead jobs.

func RedisKeyLastPeriodicEnqueue added in v1.5.0

func RedisKeyLastPeriodicEnqueue(namespace string) string

RedisKeyLastPeriodicEnqueue returns key of timestamp if last periodic enqueue.

func RedisKeyScheduled added in v1.5.0

func RedisKeyScheduled(namespace string) string

RedisKeyScheduled returns key of scheduled job.

func RedisNamespacePrefix added in v1.5.0

func RedisNamespacePrefix(namespace string) string

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

func SerializeJob added in v1.5.0

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

SerializeJob encodes work.Job to json data.

func SetNowEpochSecondsMock added in v1.5.0

func SetNowEpochSecondsMock(t int64)

SetNowEpochSecondsMock ...

func TranslateRedisAddress added in v1.5.0

func TranslateRedisAddress(commaFormat string) (string, bool)

TranslateRedisAddress translates the comma format to redis URL

Types

type JobScore added in v1.5.0

type JobScore struct {
	JobBytes []byte
	Score    int64
}

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

func GetZsetByScore added in v1.5.0

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