Documentation ¶
Overview ¶
Package uid provides a common interface for generating unique identifiers
Index ¶
- Constants
- func AsInt64(u UID) (int64, bool)
- func RegisterProvider(ctx context.Context, scheme string, init_func ProviderInitializationFunc) error
- func Schemes() []string
- type Int64UID
- type MultiUID
- type NullProvider
- type NullUID
- type Provider
- func NewNullProvider(ctx context.Context, uri string) (Provider, error)
- func NewProvider(ctx context.Context, uri string) (Provider, error)
- func NewRandomProvider(ctx context.Context, uri string) (Provider, error)
- func NewStringProvider(ctx context.Context, uri string) (Provider, error)
- func NewYMDProvider(ctx context.Context, uri string) (Provider, error)
- type ProviderInitializationFunc
- type RandomProvider
- type StringProvider
- type StringUID
- type UID
- type YMDProvider
- type YMDUID
Constants ¶
const NULL_SCHEME string = "null"
NULL_SCHEME is the URI scheme used to identify NullProvider instances.
const RANDOM_SCHEME string = "random"
const STRING_SCHEME string = "string"
const YMD_SCHEME string = "ymd"
Variables ¶
This section is empty.
Functions ¶
func RegisterProvider ¶
func RegisterProvider(ctx context.Context, scheme string, init_func ProviderInitializationFunc) error
RegisterProvider registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `Provider` instances by the `NewProvider` method.
Types ¶
type Int64UID ¶ added in v0.4.0
type Int64UID struct { UID // contains filtered or unexported fields }
type MultiUID ¶ added in v0.4.0
type MultiUID struct { UID // contains filtered or unexported fields }
type NullProvider ¶
type NullProvider struct {
Provider
}
type NullProvider implements the Provider interface to return empty (null) identifiers.
type NullUID ¶
type NullUID struct {
UID
}
type NullProvider implements the UID interface to return empty (null) identifiers.
type Provider ¶
type Provider interface { UID(context.Context, ...interface{}) (UID, error) SetLogger(context.Context, *log.Logger) error }
func NewProvider ¶
NewProvider returns a new `Provider` instance configured by 'uri'. The value of 'uri' is parsed as a `url.URL` and its scheme is used as the key for a corresponding `ProviderInitializationFunc` function used to instantiate the new `Provider`. It is assumed that the scheme (and initialization function) have been registered by the `RegisterProvider` method.
type ProviderInitializationFunc ¶
ProviderInitializationFunc is a function defined by individual provider package and used to create an instance of that provider
type RandomProvider ¶
type RandomProvider struct {
Provider
}
type StringProvider ¶
type StringProvider struct { Provider // contains filtered or unexported fields }
type YMDProvider ¶
type YMDProvider struct {
Provider
}