common

package
v2.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2017 License: MIT Imports: 20 Imported by: 39

Documentation

Index

Constants

View Source
const (
	// ClientVersion is current client library's version
	// It uses Semantic Versions MAJOR.MINOR.PATCH (https://blog.gopheracademy.com/advent-2015/semver/)
	// ClientVersion needs to be updated to reflect client library changes:
	// 1. MAJOR version when you make incompatible API changes,
	// 2. MINOR version when you add functionality in a backwards-compatible manner, and
	// 3. PATCH version when you make backwards-compatible bug fixes.
	ClientVersion = "0.1.0"
	// HeaderClientVersion is the name of thrift context header contains client version
	HeaderClientVersion = "client-version"
	// HeaderUserName is the name of thrift context header contains current user name
	HeaderUserName = "user-name"
	// HeaderHostName is the name of thrift context header contains current host name
	HeaderHostName = "host-name"

	// SequenceBegin refers to the beginning of an extent
	SequenceBegin = 0
	// SequenceEnd refers to the end of an extent
	SequenceEnd = math.MaxInt64

	// UUIDStringLength is the length of an UUID represented as a hex string
	UUIDStringLength = 36 // xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

	// InputServiceName refers to the name of the cherami in service
	InputServiceName = "cherami-inputhost"
	// OutputServiceName refers to the name of the cherami out service
	OutputServiceName = "cherami-outputhost"
	// FrontendServiceName refers to the name of the cherami frontend service
	FrontendServiceName = "cherami-frontendhost"
	// FrontendStagingServiceName refers to the name of the cherami staging frontend service
	FrontendStagingServiceName = "cherami-frontendhost-staging"
	// ControllerServiceName refers to the name of the cherami controller service
	ControllerServiceName = "cherami-controllerhost"
	// StoreServiceName refers to the name of the cherami store service
	StoreServiceName = "cherami-storehost"

	// EndpointOpenPublisherStream is websocket endpoint name for OpenPublisherStream
	EndpointOpenPublisherStream = "open_publisher_stream"
	// EndpointOpenConsumerStream is websocket endpoint name for OpenConsumerStream
	EndpointOpenConsumerStream = "open_consumer_stream"
	// EndpointOpenAppendStream is websocket endpoint name for OpenAppendStream
	EndpointOpenAppendStream = "open_append_stream"
	// EndpointOpenReadStream is websocket endpoint name for OpenReadStream
	EndpointOpenReadStream = "open_read_stream"
	// EndpointOpenReplicationRemoteReadStream is websocket endpoint name for OpenReplicationRemoteReadStream
	EndpointOpenReplicationRemoteReadStream = "open_replication_remote_read_stream"
	// EndpointOpenReplicationReadStream is websocket endpoint name for OpenReplicationReadStream
	EndpointOpenReplicationReadStream = "open_replication_read_stream"
	// HTTPHandlerPattern is pattern format for http handler, eg "/endpoint"
	HTTPHandlerPattern = "/%s"
	// WSUrlFormat is url format for websocket, eg "ws://host:port/endpoint"
	WSUrlFormat = "ws://%s/%s"
)
View Source
const TagAckID = `ackID`

TagAckID is the logging tag for AckId

View Source
const TagCnsPth = `cnsPth`

TagCnsPth is the logging tag for Consumer group Path

View Source
const TagCnsm = `cnsmID`

TagCnsm is the logging tag for Consumer Group UUID

View Source
const TagCtrl = `ctrlID`

TagCtrl is the logging tag for Extent Controller UUID

View Source
const TagDLQID = `dlqID`

TagDLQID is the logging tag for a Dead Letter Queue destination UUID

View Source
const TagDst = `destID`

TagDst is the tag for Destination UUID

View Source
const TagDstPth = `dstPth`

TagDstPth is the logging tag for Destination Path

View Source
const TagErr = `err`

TagErr is the tag for error object message

View Source
const TagExt = `extnID`

TagExt is the logging tag for Extent UUID

View Source
const TagFrnt = `frntID`

TagFrnt is the logging tag for Frontend UUID

View Source
const TagHostIP = `hostIP`

TagHostIP is the logging tag for host IP

View Source
const TagHostPort = "hostport"

TagHostPort is the log tag for hostport

View Source
const TagHosts = "hosts"

TagHosts is the log tag for list of hosts

View Source
const TagIn = `inhoID`

TagIn is the logging tag for Inputhost UUID

View Source
const TagInPubConnID = `inPubConnID`

TagInPubConnID is the logging tag for input pubconnection ID

View Source
const TagInPutAckID = `inPutAckID`

TagInPutAckID is the logging tag for PutMessageAck ID

View Source
const TagInReplicaHost = `inReplicaHost`

TagInReplicaHost is the logging tag for replica host on input

View Source
const TagMsgID = `msgID`

TagMsgID is the logging tag for MsgId

View Source
const TagOut = `outhID`

TagOut is the logging tag for Outputhost UUID

View Source
const TagReconfigureID = `reconfigID`

TagReconfigureID is the logging tag for reconfiguration identifiers

View Source
const TagReconfigureType = `reconfigType`

TagReconfigureType is the logging tag for reconfiguration type

View Source
const TagService = "service"

TagService is the log tag for the service

View Source
const TagStor = `storID`

TagStor is the logging tag for StoreHost UUID

View Source
const TagUpdateUUID = `updateUUID`

TagUpdateUUID is the logging tag for reconfiguration update UUIDs

Variables

This section is empty.

Functions

func AdvertiseInHyperbahn

func AdvertiseInHyperbahn(ch *tchannel.Channel, bootstrapFile string) *hyperbahn.Client

AdvertiseInHyperbahn advertises this node in Hyperbahn

func AwaitWaitGroup

func AwaitWaitGroup(wg *sync.WaitGroup, timeout time.Duration) bool

AwaitWaitGroup calls Wait on the given wait Returns true if the Wait() call succeeded before the timeout Returns false if the Wait() did not return before the timeout

func BoolPtr

func BoolPtr(v bool) *bool

BoolPtr makes a copy and returns the pointer to a bool.

func CalculateRate

func CalculateRate(last, curr SequenceNumber, lastTime, currTime UnixNanoTime) float64

CalculateRate does a simple rate calculation

func CheramiConsumerGroupStatusPtr

func CheramiConsumerGroupStatusPtr(status cherami.ConsumerGroupStatus) *cherami.ConsumerGroupStatus

CheramiConsumerGroupStatusPtr makes a copy and returns the pointer to a CheramiConsumerGroupStatus.

func CheramiDestinationStatusPtr

func CheramiDestinationStatusPtr(status cherami.DestinationStatus) *cherami.DestinationStatus

CheramiDestinationStatusPtr makes a copy and returns the pointer to a CheramiDestinationStatus.

func CheramiDestinationTypePtr

func CheramiDestinationTypePtr(destType cherami.DestinationType) *cherami.DestinationType

CheramiDestinationTypePtr makes a copy and returns the pointer to a CheramiDestinationType.

func CheramiInputHostCommandTypePtr

func CheramiInputHostCommandTypePtr(cmdType cherami.InputHostCommandType) *cherami.InputHostCommandType

CheramiInputHostCommandTypePtr makes a copy and returns the pointer to a CheramiInputHostCommandType.

func CheramiOutputHostCommandTypePtr

func CheramiOutputHostCommandTypePtr(cmdType cherami.OutputHostCommandType) *cherami.OutputHostCommandType

CheramiOutputHostCommandTypePtr makes a copy and returns the pointer to a CheramiOutputHostCommandType.

func CheramiStatusPtr

func CheramiStatusPtr(status cherami.Status) *cherami.Status

CheramiStatusPtr makes a copy and returns the pointer to a CheramiStatus.

func CreateHyperbahnClient

func CreateHyperbahnClient(ch *tchannel.Channel, bootstrapFile string) *hyperbahn.Client

CreateHyperbahnClient returns a hyperbahn client

func CreateTChannel

func CreateTChannel(service string) *tchannel.Channel

CreateTChannel creates the top level TChannel object for the specified servicer

func Float64Ptr

func Float64Ptr(v float64) *float64

Float64Ptr makes a copy and returns the pointer to an int64.

func FmtAckID

func FmtAckID(s string) string

FmtAckID formats a string to be used with TagAckID

func FmtCnsPth

func FmtCnsPth(s string) string

FmtCnsPth formats a string to be used with TagCnsPth

func FmtCnsm

func FmtCnsm(s string) string

FmtCnsm formats a string to be used with TagCnsm

func FmtCtrl

func FmtCtrl(s string) string

FmtCtrl formats a string to be used with TagCtrl

func FmtDLQID

func FmtDLQID(s string) string

FmtDLQID formats a string to be used with TagDLQID

func FmtDst

func FmtDst(s string) string

FmtDst formats a string to be used with TagDst

func FmtDstPth

func FmtDstPth(s string) string

FmtDstPth formats a string to be used with TagDstPth

func FmtExt

func FmtExt(s string) string

FmtExt formats a string to be used with TagExt

func FmtFrnt

func FmtFrnt(s string) string

FmtFrnt formats a string to be used with TagFrnt

func FmtHostIP

func FmtHostIP(s string) string

FmtHostIP formats a string to be used with TagHostIP

func FmtHostPort

func FmtHostPort(s string) string

FmtHostPort formats a string to be used with TagHostPort

func FmtIn

func FmtIn(s string) string

FmtIn formats a string to be used with TagIn

func FmtInPubConnID

func FmtInPubConnID(s int) string

FmtInPubConnID formats an int to be used with TagInPubConnID

func FmtInPutAckID

func FmtInPutAckID(s string) string

FmtInPutAckID formats a string to be used with TagInPutAckID

func FmtInReplicaHost

func FmtInReplicaHost(s string) string

FmtInReplicaHost formats a string to be used with TagInReplicaHost

func FmtMsgID

func FmtMsgID(s string) string

FmtMsgID formats a string to be used with TagMsgID

func FmtOut

func FmtOut(s string) string

FmtOut formats a string to be used with TagOut

func FmtReconfigureID

func FmtReconfigureID(s string) string

FmtReconfigureID formats a string to be used with TagReconfigureID

func FmtService

func FmtService(s string) string

FmtService formats a string to be used with TagService

func FmtStor

func FmtStor(s string) string

FmtStor formats a string to be used with TagStor

func GetConnectionKey

func GetConnectionKey(host *cherami.HostAddress) string

GetConnectionKey is used to create a key used by connections for looking up connections

func GetDateTag

func GetDateTag() string

GetDateTag returns the current date used for tagging daily metric

func GetDirectoryName

func GetDirectoryName(path string) (string, error)

GetDirectoryName function gives the directory name given a path used for destination or consumer groups

func GetRandInt64

func GetRandInt64(min int64, max int64) int64

GetRandInt64 is used to get a 64 bit random number between min and max

func Int32Ptr

func Int32Ptr(v int32) *int32

Int32Ptr makes a copy and returns the pointer to an int32.

func Int64Ptr

func Int64Ptr(v int64) *int64

Int64Ptr makes a copy and returns the pointer to an int64.

func IntPtr

func IntPtr(v int) *int

IntPtr makes a copy and returns the pointer to an int.

func IsRetryableTChanErr

func IsRetryableTChanErr(err error) bool

IsRetryableTChanErr returns true if the given tchannel error is a retryable error.

func MinInt

func MinInt(a, b int) int

MinInt returns the minimum of values (a, b)

func ShortenGUIDString

func ShortenGUIDString(s string) string

ShortenGUIDString takes a string with one or more GUIDs and elides them to make it more human readable. It turns "354754bd-b73e-4d20-8021-ab93a3d145c0:67af70c5-f45e-4b3d-9d20-6758195e2ff4:3:2" into "354754bd:67af70c5:3:2"

func SpinWaitOnCondition

func SpinWaitOnCondition(condition ConditionFunc, timeout time.Duration) bool

SpinWaitOnCondition busy waits for a given condition to be true until the timeout Returns true if the condition was satisfied, false on timeout

func SplitHostPort

func SplitHostPort(hostPort string) (string, int, error)

SplitHostPort takes a x.x.x.x:yyyy string and split it into host and ports

func StringPtr

func StringPtr(v string) *string

StringPtr makes a copy and returns the pointer to a string.

func TDeserialize

func TDeserialize(msg thrift.TStruct, b []byte) (err error)

TDeserialize is used to deserialize []byte to thrift TStruct

func TDeserializeString

func TDeserializeString(msg thrift.TStruct, s string) (err error)

TDeserializeString is used to deserialize string to thrift TStruct

func TListDeserialize

func TListDeserialize(msgType reflect.Type, b []byte) (msgs []thrift.TStruct, err error)

TListDeserialize is used to deserialize []byte to list of thrift TStruct

func TListSerialize

func TListSerialize(msgs []thrift.TStruct) (b []byte, err error)

TListSerialize is used to serialize list of thrift TStruct to []byte

func TSerialize

func TSerialize(msg thrift.TStruct) (b []byte, err error)

TSerialize is used to serialize thrift TStruct to []byte

func TSerializeString

func TSerializeString(msg thrift.TStruct) (s string, err error)

TSerializeString is used to serialize thrift TStruct to string

func UUIDHashCode

func UUIDHashCode(key string) uint32

UUIDHashCode is a hash function for hashing string uuid if the uuid is malformed, then the hash function always returns 0 as the hash value

func Uint32Ptr

func Uint32Ptr(v uint32) *uint32

Uint32Ptr makes a copy and returns the pointer to a uint32.

func Uint64Ptr

func Uint64Ptr(v uint64) *uint64

Uint64Ptr makes a copy and returns the pointer to a uint64.

func ValidateTimeout

func ValidateTimeout(t time.Duration) error

ValidateTimeout returns an error if the passed timeout is unreasonable

Types

type ConditionFunc

type ConditionFunc func() bool

ConditionFunc represents an expression that evaluates to true on when some condition is satisfied and false otherwise

type GeometricRollingAverage

type GeometricRollingAverage float64

GeometricRollingAverage is the value of a geometrically diminishing rolling average

func (*GeometricRollingAverage) GetGeometricRollingAverage

func (avg *GeometricRollingAverage) GetGeometricRollingAverage() float64

GetGeometricRollingAverage returns the result of the geometric rolling average

func (*GeometricRollingAverage) SetGeometricRollingAverage

func (avg *GeometricRollingAverage) SetGeometricRollingAverage(val float64)

SetGeometricRollingAverage adds a value to the geometric rolling average

type Seconds

type Seconds float64

Seconds is time as seconds, either relative or absolute since the epoch

func DurationToSeconds

func DurationToSeconds(t time.Duration) Seconds

DurationToSeconds converts a time.Duration to Seconds

type SequenceNumber

type SequenceNumber int64

SequenceNumber is an int64 number represents the sequence of messages in Extent

type UnixNanoTime

type UnixNanoTime int64

UnixNanoTime is Unix time as nanoseconds since Jan 1st, 1970, 00:00 GMT

func Now

func Now() UnixNanoTime

Now is the version to return UnixNanoTime

func (UnixNanoTime) ToSeconds

func (u UnixNanoTime) ToSeconds() Seconds

ToSeconds turns a relative or absolute UnixNanoTime to float Seconds

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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