Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRetryable = errors.New("cannot create unique value but retryable")
ErrRetryable indicates that the generation of a unique value has temporarily failed, but may succeed by retrying.
Functions ¶
func StringFunc ¶
StringFunc is an n-digit random string generator. It uses upper/lower case alphanumeric characters.
Types ¶
type Option ¶
func WithBeacon ¶
WithBeacon configures Unique to integrate with a starting beacon server. It enables us to generate unique values through all tests that reference the same beacon server and storeName.
See confort.WithBeacon.
type Unique ¶
type Unique[T comparable] struct { // contains filtered or unexported fields }
func Must ¶ added in v1.1.0
func Must[T comparable](u *Unique[T], err error) *Unique[T]
Must is a helper that wraps a call to a function returning (*Unique[T], error) and panics if the error is non-nil. It is intended for use in variable initializations such as
var u = unique.Must(unique.String(context.Background(), 10))
func New ¶
func New[T comparable](ctx context.Context, fn func() (T, error), opts ...Option) (*Unique[T], error)
New creates unique value generator. Argument fn is an arbitrary generator function. When the generated value by fn is not unique or fn returns ErrRetryable, Unique retries. By default, Unique retries 10 times.