random

package
v3.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedRandomIdGenerator added in v3.3.0

type BufferedRandomIdGenerator struct {
	// contains filtered or unexported fields
}

BufferedRandomIdGenerator is used to fetch random generator ids while avoiding a mutex. The random ids are prefetched ina single goroutine in the background. You have to call close to stop this goroutine.

func NewBufferedRandomIdGenerator

func NewBufferedRandomIdGenerator(idLength int, bufferSize int) *BufferedRandomIdGenerator

NewBufferedRandomIdGenerator instantiates a new generator with the given buffer size. The BufferedRandomIdGenerator has to be closed to avoid leaking the prefetch go routine.

func (*BufferedRandomIdGenerator) Close added in v3.3.0

func (gen *BufferedRandomIdGenerator) Close() error

Close stops the background prefetch process. Does not error.

func (*BufferedRandomIdGenerator) GetRandomId added in v3.3.0

func (gen *BufferedRandomIdGenerator) GetRandomId() string

GetRandomId returns a prefetched random id. Blocks till one is received.

Jump to

Keyboard shortcuts

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