ablyutil

package
v1.2.17 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func After added in v1.2.0

func After(ctx context.Context, d time.Duration) <-chan time.Time

After returns a channel that is sent the current time once the given duration has passed. If the context is cancelled before that, the channel is immediately closed.

func BaseID added in v1.1.0

func BaseID() (string, error)

BaseID returns a base64 encoded 9 random bytes to be used in idempotent rest publishing as part of message id.

Spec RSL1k1

func ContextWithTimeout added in v1.2.0

func ContextWithTimeout(ctx context.Context, after TimerFunc, timeout time.Duration) (context.Context, context.CancelFunc)

ContextWithTimeout is like context.WithTimeout, but using the provided TimerFunc for setting the timer.

func Copy added in v1.2.16

func Copy(list []string) []string

func Empty added in v1.2.16

func Empty(s string) bool

func GenerateRandomString added in v1.2.16

func GenerateRandomString(length int) string

func MarshalMsgpack added in v1.2.0

func MarshalMsgpack(v interface{}) ([]byte, error)

MarshalMsgpack returns msgpack encoding of v

func MatchDerivedChannel added in v1.2.12

func MatchDerivedChannel(name string) (*derivedChannelMatch, error)

This regex check is to retain existing channel params if any e.g [?rewind=1]foo to [filter=xyz?rewind=1]foo. This is to keep channel compatibility around use of channel params that work with derived channels.

func Merge

func Merge(orig, v interface{}, defaults bool)

Merge iterates over fields of struct pointed by v and when it's non-zero, copies its value to corresponding filed in orig.

merge assumes both orig and v are pointers to a struct value of the same type.

When defaults is true, merge uses v as the source of default values for each field; the default is copied when orig's field is a zero-value.

func Shuffle added in v1.2.16

func Shuffle(list []string) []string

func SliceContains added in v1.2.16

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

func Sort added in v1.2.16

func Sort(list []string) []string

func UnmarshalMsgpack added in v1.2.0

func UnmarshalMsgpack(data []byte, v interface{}) error

UnmarshalMsgpack decodes the MessagePack-encoded data and stores the result in the value pointed to by v.

Types

type HashSet added in v1.2.16

type HashSet map[string]struct{} // struct {} has zero space complexity

func NewHashSet added in v1.2.16

func NewHashSet() HashSet

func (HashSet) Add added in v1.2.16

func (s HashSet) Add(item string)

func (HashSet) Has added in v1.2.16

func (s HashSet) Has(item string) bool

func (HashSet) Remove added in v1.2.16

func (s HashSet) Remove(item string)

type TimerFunc added in v1.2.0

type TimerFunc func(context.Context, time.Duration) <-chan time.Time

func NewTicker added in v1.2.0

func NewTicker(after TimerFunc) TimerFunc

NewTicker repeatedly calls the given TimerFunc, which should behave like After, until the context it cancelled. It returns a channel to which it sends every value produced by the TimerFunc.

Jump to

Keyboard shortcuts

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