utils

package
v0.0.0-...-57b83e3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: Apache-2.0 Imports: 11 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 GenerateNodeID

func GenerateNodeID() string

GenerateNodeID returns ID of current node

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 MakeIdentifier

func MakeIdentifier() string

MakeIdentifier creates uuid for job.

func ReadEnv

func ReadEnv(key string) string

ReadEnv return the value of env variable.

func ResolveHostnameAndIP

func ResolveHostnameAndIP() (string, error)

ResolveHostnameAndIP gets the local hostname and IP

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 NodeIDContextKey

type NodeIDContextKey string

NodeIDContextKey is used to keep node ID in the system context

const (
	// NodeID is const of the ID context key
	NodeID NodeIDContextKey = "node_id"
)

Jump to

Keyboard shortcuts

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