Documentation
¶
Overview ¶
Package identifier provides a way to identify users across different systems.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // GenericEmail is any email address not associated with a specific namespace or system. GenericEmail = NamespaceAndKind(KindEmail) // GenericUsername is any username not associated with a specific namespace or system. GenericUsername = NamespaceAndKind(KindUsername) // GenericID is any ID not associated with a specific namespace or system. GenericID = NamespaceAndKind(KindID) )
Functions ¶
This section is empty.
Types ¶
type Identifier ¶
type Identifier struct { NamespaceAndKind Value string }
An Identifier is a unique reference to some user or group.
func New ¶
func New[T1 ~string, T2 valueType](namespaceAndKind T1, value T2) Identifier
New creates a new Identifier for a given namespaceAndKind and a value.
type Kind ¶
type Kind string
Kind represents the type of identifier, such as an "email" or "username". This is used in conjunction with a namespace to uniquely identify a user in some system.
type NamespaceAndKind ¶
type NamespaceAndKind string
NamespaceAndKind is a combination of a namespace and a kind. For example, in "slack.com/email", "slack.com" is the namespace and "email" is the kind. The namespace part is considered optional, and if it is not present, it is represented as an empty string. This is useful when a user is known by different emails, usernames, or IDs across different systems.
func NewNamespaceAndKind ¶
func NewNamespaceAndKind[T ~string](namespace string, kind T) NamespaceAndKind
NewNamespaceAndKind creates a new NamespaceAndKind from a namespace and a Kind.
func (NamespaceAndKind) Kind ¶
func (n NamespaceAndKind) Kind() Kind
func (NamespaceAndKind) Namespace ¶
func (n NamespaceAndKind) Namespace() string
func (NamespaceAndKind) Split ¶
func (n NamespaceAndKind) Split() (string, string)
Split returns the namespace and kind parts of the NamespaceAndKind.
type Set ¶
type Set interface { Get(NamespaceAndKind) (string, bool) MustGet(NamespaceAndKind) string Add(Identifier) Merge(Set) Intersect(Set) Set ToList() []Identifier String() string ToMap() map[NamespaceAndKind]string Len() int }
Set holds a thread-safe map of NamespaceAndKind to a value. Each entry is basically an Identifier.
func MergeAndDeduplicate ¶
MergeAndDeduplicate merges any sets that share overlapping identifiers, returning a slice of distinct sets, each representing a unique collection of identifiers without duplicates. Note that this function does not modify the input sets, nor does it guarantee the order of the output sets.
func NewSet ¶
func NewSet(ids ...Identifier) Set
NewSet creates a new Set from a slice of Identifier objects
func NewSetFromMap ¶
func NewSetFromMap(ids map[NamespaceAndKind]string) Set
NewSetFromMap creates a new Set from a map of NamespaceAndKind to value.