Documentation
¶
Index ¶
- Constants
- func NormalizeAudience(name string) string
- func NormalizeCreator(name string) string
- func NormalizeSegment(name string) string
- type KeyCode
- type KeyGen
- func (g *KeyGen) Creator() string
- func (g *KeyGen) GlobalKey(domain string, k any) string
- func (g *KeyGen) GlobalKeyFrom(creatorIdentity, domain string, k any) string
- func (g *KeyGen) Init(creator string, opts ...Option)
- func (g *KeyGen) InstanceID() string
- func (g *KeyGen) Key(domain string, k any) string
- func (g *KeyGen) Prefix() string
- func (g *KeyGen) ShareFrom(creatorIdentity, audienceIdentity, domain string, k any) string
- func (g *KeyGen) ShareTo(audienceIdentity, domain string, k any) string
- func (g *KeyGen) SharedKey(domain string, k any) string
- func (g *KeyGen) SharedKeyFrom(creatorIdentity, domain string, k any) string
- type Option
Constants ¶
const ( AudiencePeer = "PEER" AudienceAny = "ANY" )
Audience reserved words.
Variables ¶
This section is empty.
Functions ¶
func NormalizeAudience ¶
NormalizeAudience normalizes audience identity for the audience segment; panics on empty or reserved words.
func NormalizeCreator ¶
NormalizeCreator normalizes creator identity for the creator segment; panics on empty or reserved words.
func NormalizeSegment ¶
NormalizeSegment normalises a key segment: TrimSpace, ToUpper, '-' to '_'.
Types ¶
type KeyGen ¶
type KeyGen struct {
// contains filtered or unexported fields
}
KeyGen generates structured cache keys using a four-segment convention. It must be initialized exactly once via KeyGen.Init before any key generation method is called.
func (*KeyGen) GlobalKeyFrom ¶
GlobalKeyFrom reads a cross-service key created by another creator identity.
func (*KeyGen) Init ¶
Init locks the creator identity and generates a per-process ULID instance ID. Subsequent calls are no-ops (the first result is retained).
func (*KeyGen) InstanceID ¶
InstanceID returns the per-process instance audience (ULID).
func (*KeyGen) ShareTo ¶
ShareTo returns a key shared with a target identity: {creator}:{audience}:{domain}:{biz}.