Help us shape the future of Go! Take the 2026 Go Developer Survey

events

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package events distributes best-effort resource invalidation hints. REST and the underlying stores remain authoritative; hints are neither replayable nor proof that a background operation or result export succeeded.

Index

Constants

View Source
const (
	Queries         = "queries"
	Carves          = "carves"
	Console         = "console"
	FileExplorer    = "file_explorer"
	Alerts          = "alerts"
	ServiceCommands = "service_commands"
	Fleet           = "fleet"
	ChangeMetadata  = "metadata"
	ChangeResults   = "results"
	ChangeFiles     = "files"
	ChangeRules     = "rules"
	ChangeChannels  = "channels"
	ChangeHistory   = "history"
	ChangeActivity  = "activity"
)

Variables

View Source
var (
	ErrUnavailable = errors.New("event transport unavailable")
	ErrLimit       = errors.New("event connection limit reached")
)

Functions

This section is empty.

Types

type Bus

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

Bus owns one Redis subscription per API process and bounded subscriber queues. A TLS process constructs a publish-only Bus. Call Close before HTTP draining.

func New

func New(client *redis.Client, namespace string, consume bool) (*Bus, error)

func (*Bus) Close

func (b *Bus) Close()

func (*Bus) Dropped

func (b *Bus) Dropped() uint64

Dropped includes failed publication and slow-subscriber disconnections.

func (*Bus) Publish

func (b *Bus) Publish(h Hint)

func (*Bus) Snapshot

func (b *Bus) Snapshot() Stats

func (*Bus) Subscribe

func (b *Bus) Subscribe(user string, environmentID uint, topics []string) (<-chan Hint, func(), error)

type Hint

type Hint struct {
	EnvironmentID uint   `json:"environment_id"`
	Topic         string `json:"topic"`
	Name          string `json:"name"`
	Change        string `json:"change,omitempty"`
	SessionID     uint   `json:"session_id,omitempty"`
	ResourceID    uint   `json:"resource_id,omitempty"`
}

Hint is an internal routing envelope. Numeric environment IDs never leave the API, which resolves and authorizes the requested environment separately.

func (Hint) Valid

func (h Hint) Valid() bool

type Publisher

type Publisher interface{ Publish(Hint) }

type Stats

type Stats struct {
	Enabled     bool   `json:"enabled"`
	Healthy     bool   `json:"healthy"`
	Subscribers int    `json:"subscribers"`
	Dropped     uint64 `json:"dropped"`
}

Stats is safe to expose to operators. It deliberately avoids user names, environment UUIDs, query names, and event payload data.

type Subscriber

type Subscriber interface {
	Subscribe(string, uint, []string) (<-chan Hint, func(), error)
}

Jump to

Keyboard shortcuts

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