utils

package
v0.7.8 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildPeerInformer added in v0.5.0

func BuildPeerInformer(stopper chan struct{}, peerRing *ShardHelper, ringConfig consistent.Config, log logr.Logger) cache.SharedIndexInformer

func Jitter added in v0.4.1

func Jitter(t time.Duration, maxJitterPercent int) (time.Duration, error)

Jitter accepts a Duration and maximum percentage to jitter (as an int), and returns a random Duration in the range t +/- maxJitterPercent.

func JitterRequeue added in v0.4.1

func JitterRequeue(defaultDuration time.Duration, maxJitterPercent int, log logr.Logger) reconcile.Result

JitterRequeue accepts a default requeue time, a maximum percentage to jitter, and a logger, and returns a Result containing a requeue time which has been randomized with jitter.

func SliceContains

func SliceContains(s []string, value string) bool

Types

type ShardHelper added in v0.5.0

type ShardHelper struct {
	PodIP            string
	ServiceName      string
	ServiceNamespace string
	// contains filtered or unexported fields
}

func BuildPeerHashRing added in v0.5.0

func BuildPeerHashRing(consistentCfg consistent.Config, podIP string, serviceName string, serviceNamespace string) *ShardHelper

func (*ShardHelper) GetShardOwner added in v0.5.0

func (r *ShardHelper) GetShardOwner(input string) string

Returns the name (IP) of the shard which should own a provided object name.

func (*ShardHelper) MemberCount added in v0.5.0

func (r *ShardHelper) MemberCount() int

Returns the number of members/peers currently in the hash ring.

func (*ShardHelper) SetMembers added in v0.5.0

func (r *ShardHelper) SetMembers(newMembers map[string]struct{})

SetMembers accepts a map where the keys are member IPs and uses those IPs as the members for sharding.

func (*ShardHelper) SetMembersFromLists added in v0.5.0

func (r *ShardHelper) SetMembersFromLists(lists ...[]string)

SetMembersFromLists is a wrapper around SetMember which accepts slices instead of a map.

func (*ShardHelper) ShouldOwn added in v0.5.0

func (r *ShardHelper) ShouldOwn(input string) bool

Returns whether the current shard should own the object with the provided name.

Jump to

Keyboard shortcuts

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