identity

package
v0.112.4 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashString added in v0.112.4

func HashString(vs ...any) string

HashString returns a hash from the given elements. It will panic if the hash cannot be calculated. Note that this hash should be used primarily for identity, not for change detection as it in the more complex values (e.g. Page) will not hash the full content.

func HashUint64 added in v0.112.4

func HashUint64(vs ...any) uint64

HashUint64 returns a hash from the given elements. It will panic if the hash cannot be calculated. Note that this hash should be used primarily for identity, not for change detection as it in the more complex values (e.g. Page) will not hash the full content.

Types

type Identities

type Identities map[Identity]Provider

Identities stores identity providers.

type IdentitiesProvider

type IdentitiesProvider interface {
	GetIdentities() Identities
}

IdentitiesProvider provides all Identities.

type Identity

type Identity interface {
	Provider
	Name() string
}

Identity represents an thing that can provide an identify. This can be any Go type, but the Identity returned by GetIdentify must be hashable.

type IncrementByOne

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

IncrementByOne implements Incrementer adding 1 every time Incr is called.

func (*IncrementByOne) Incr

func (c *IncrementByOne) Incr() int

type Incrementer

type Incrementer interface {
	Incr() int
}

Incrementer increments and returns the value. Typically used for IDs.

type KeyValueIdentity

type KeyValueIdentity struct {
	Key   string
	Value string
}

A KeyValueIdentity a general purpose identity.

func (KeyValueIdentity) GetIdentity

func (id KeyValueIdentity) GetIdentity() Identity

GetIdentity returns itself.

func (KeyValueIdentity) Name

func (id KeyValueIdentity) Name() string

Name returns the Key.

type Manager

type Manager interface {
	SearchProvider
	Add(ids ...Provider)
	Reset()
}

Manager manages identities, and is itself a Provider of Identity.

func NewManager

func NewManager(id Provider) Manager

NewManager creates a new Manager starting at id.

type PathIdentity

type PathIdentity struct {
	Type string
	Path string
}

A PathIdentity is a common identity identified by a type and a path, e.g. "layouts" and "_default/single.html".

func NewPathIdentity

func NewPathIdentity(typ, pat string) PathIdentity

NewPathIdentity creates a new Identity with the two identifiers type and path.

func (PathIdentity) GetIdentity

func (id PathIdentity) GetIdentity() Identity

GetIdentity returns itself.

func (PathIdentity) Name

func (id PathIdentity) Name() string

Name returns the Path.

type Provider

type Provider interface {
	// GetIdentity is for internal use.
	GetIdentity() Identity
}

Provider provides the comparable Identity.

type SearchProvider added in v0.5.0

type SearchProvider interface {
	Provider
	IdentitiesProvider
	Search(id Identity) Provider
}

SearchProvider provides access to the chained set of identities.

Jump to

Keyboard shortcuts

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