utils

package
v0.0.0-...-7055b2f Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallFactory

func CallFactory(items ...FactoryType) ([]interface{}, error)

CallFactory invokes the list of factories and returns the obtained instances

func ExponentialBackoff

func ExponentialBackoff(retries int, total time.Duration) ([]time.Duration, error)

ExponentialBackoff computes the exponential backoff intervals summing to provided total duration

func FormatMetricName

func FormatMetricName(str string) string

FormatMetricName returns the metric name with reserved chars removed

func GetLocalIPv4

func GetLocalIPv4() string

GetLocalIPv4 will return this hosts IPv4 address. It will not return the loopback address and it will panic if no address is found.

func IsCanceledError

func IsCanceledError(err error) bool

IsCanceledError returns true if the provided value is a cancellation error

func LifecycleStart

func LifecycleStart(logger core.Logger, instances ...interface{}) error

LifecycleStart executes startup procedure

func LifecycleStop

func LifecycleStop(logger core.Logger, instances ...interface{})

LifecycleStop executes shutdown procedure

func NewUUID

func NewUUID() uuid.UUID

NewUUID returns a randomly generated UUID

func SetDefaultBreaker

func SetDefaultBreaker(dest *core.Breaker, defaultValue core.Breaker)

SetDefaultBreaker sets the default value for provided location

func SetDefaultDuration

func SetDefaultDuration(dest *time.Duration, defaultValue time.Duration)

SetDefaultDuration sets the default value for provided location

func SetDefaultInt

func SetDefaultInt(dest *int, defaultValue int)

SetDefaultInt sets the default value for provided location

func SetDefaultRetrier

func SetDefaultRetrier(dest *core.Retrier, defaultValue core.Retrier)

SetDefaultRetrier sets the default value for provided location

func SetDefaultString

func SetDefaultString(dest *string, defaultValue string)

SetDefaultString sets the default value for provided location

func SetDefaultUint64

func SetDefaultUint64(dest *uint64, defaultValue uint64)

SetDefaultUint64 sets the default value for provided location

func Validate

func Validate(instance interface{}) string

Validate performs tag-based validation for the provided instance.

Types

type DelayEvent

type DelayEvent time.Duration

DelayEvent is a helper Kafka event used during tests

func (DelayEvent) Delay

func (d DelayEvent) Delay()

Delay blocks for the specified duration

func (DelayEvent) String

func (d DelayEvent) String() string

type FactoryType

type FactoryType struct {
	Factory core.Factory
	Type    interface{}
}

FactoryType could have been avoided if Go had generics

type SegmentHeap

type SegmentHeap binaryheap.Heap

SegmentHeap is the heap of segments ordered by offset

func NewSegmentHeap

func NewSegmentHeap() *SegmentHeap

NewSegmentHeap returns a new SegmentHeap instance

func (*SegmentHeap) Empty

func (h *SegmentHeap) Empty() bool

Empty returns true if heap does not contain any segments.

func (*SegmentHeap) Peek

func (h *SegmentHeap) Peek() *core.SegmentInfo

Peek returns top segment without removing it, or nil if heap is empty.

func (*SegmentHeap) Pop

func (h *SegmentHeap) Pop() core.SegmentInfo

Pop removes top segment and returns it. It panics if the heap is empty.

func (*SegmentHeap) Push

func (h *SegmentHeap) Push(segment core.SegmentInfo)

Push adds a segment to the heap

func (*SegmentHeap) Size

func (h *SegmentHeap) Size() int

Size returns number of segments in the heap.

Jump to

Keyboard shortcuts

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