utils

package
v0.0.0-...-977965f Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 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 returns 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 KeyPeriodicJobTimeSlots

func KeyPeriodicJobTimeSlots(namespace string) string

KeyPeriodicJobTimeSlots returns the key of the time slots of scheduled jobs.

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 KeyUpstreamJobAndExecutions

func KeyUpstreamJobAndExecutions(namespace, upstreamJobID string) string

KeyUpstreamJobAndExecutions returns the key for persisting executions.

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 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 compatibility.

func SerializeJob

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

SerializeJob encodes work.Job to json data.

func TranslateRedisAddress

func TranslateRedisAddress(commaFormat string) (string, bool)

TranslateRedisAddress translates the comma format to redis URL

Types

type CtlContextKey

type CtlContextKey string

CtlContextKey is used to keep controller reference in the system context

const (
	// CtlKeyOfLaunchJobFunc is context key to keep the ctl launch job func
	CtlKeyOfLaunchJobFunc CtlContextKey = "controller_launch_job_func"
)

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