actor

package
v2.10.51 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package actor carries the typed principal that caused a request or an event.

It is a leaf package on purpose: lib/history already imports lib/events, so a type shared by both cannot live in either. It imports nothing but context.

DEV-NOTE: the actor is audit information, never an authorization input - a downstream service must not decide anything from it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithActor

func WithActor(ctx context.Context, a Actor) context.Context

WithActor returns a context carrying the actor.

Types

type Actor

type Actor struct {
	Type Type `json:"type,omitempty"`

	// Id is stable per principal: playerId, Keycloak subject, client id, or
	// service id depending on Type.
	Id string `json:"id,omitempty"`

	// Label is a human-readable hint for support, e.g. a staff email. It is
	// display only and may be empty.
	Label string `json:"label,omitempty"`
}

Actor is the principal that caused a request or an event. An anonymous visitor has no Actor at all; the request id is the only provenance there.

func FromContext

func FromContext(ctx context.Context) (Actor, bool)

FromContext returns the actor carried by ctx, if any.

func (Actor) Zero

func (a Actor) Zero() bool

Zero reports whether the actor carries no principal.

type Type

type Type string

Type is the kind of principal an Actor describes. It is typed rather than a bare id so "everything this staff member did" is answerable without guessing id shapes, and a player ULID is never mistaken for a Keycloak subject.

const (
	// TypePlayer is a guest or verified customer, identified by playerId.
	TypePlayer Type = "player"

	// TypeUser is a staff member, identified by the Keycloak subject.
	TypeUser Type = "user"

	// TypeService is another platform service acting on its own authority,
	// identified by its Keycloak client id.
	TypeService Type = "service"

	// TypeSystem is a scheduler or consumer with no external trigger,
	// identified by the service id.
	TypeSystem Type = "system"
)

Jump to

Keyboard shortcuts

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