auditstate

package
v3.0.0-rc49 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrActive is the refusal of a session while another one runs, and
	// the session beginning does not preempt it.
	ErrActive = errors.New("an audit session is already running")

	// ErrBusy is the refusal of a session that waited too long for the
	// one beginning before it: that one is activating, which waits for
	// the bus to accept its publication.
	ErrBusy = errors.New("another audit session is beginning")
)

Functions

This section is empty.

Types

type Registry

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

func (*Registry) Active

func (r *Registry) Active() bool

func (*Registry) Begin

func (r *Registry) Begin(ctx context.Context, q chan plog.LogMessage, subsystems []string, preemptC chan struct{}, user string, preempt bool, activate func()) (Session, error)

Begin makes a session the current one, or says why it did not: there is at most one. A current session is returned and kept, with ErrActive, unless preempt asks to end it: it is then told so, by the close of its PreemptC, and replaced.

The check and the replacement are one step, so two sessions beginning at once can not both find none.

activate, when not nil, is called for a session that begins, before the next session can begin: it tells the subsystems to send their logs to q. A session preempted right after it registered has then told them before the session preempting it, which they hear last and keep. The stop of the preempted session, naming a queue they no longer send to, changes nothing.

A session waits for the one beginning before it until ctx is done, and is then refused with ErrBusy.

func (*Registry) Snapshot

func (r *Registry) Snapshot() (Session, bool)

func (*Registry) Stop

func (r *Registry) Stop(q chan plog.LogMessage)

type Session

type Session struct {
	Q chan plog.LogMessage

	// PreemptC is closed when another session preempts this one.
	PreemptC   chan struct{}
	Subsystems []string
	User       string
}

Jump to

Keyboard shortcuts

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