event

package
v2.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 6 Imported by: 0 modules, 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

Index

Constants

This section is empty.

Variables

View Source
var ErrMergeLimit = errors.New("event is full")

ErrMergeLimit: a Merge refuses a follow-up because the stored event is full; the follow-up is dropped.

View Source
var ErrNotFound = errors.New("event not found")

ErrNotFound: the event is not stored (e.g. deleted meanwhile).

Functions

func GenerateUUID

func GenerateUUID() string

Types

type DeleteOptions

type DeleteOptions struct {
	Type    string
	Project string
	UUIDs   []string
	// KeepPinned leaves pinned events in place.
	KeepPinned bool
}

DeleteOptions configures batch deletion.

type Event

type Event struct {
	UUID      string          `json:"uuid"`
	Type      string          `json:"type"`
	Payload   json.RawMessage `json:"payload"`
	Timestamp float64         `json:"timestamp"`
	Project   string          `json:"project,omitempty"`
	IsPinned  bool            `json:"is_pinned"`
}

Event represents a stored debugging event.

func NewEvent

func NewEvent(inc *Incoming) Event

NewEvent creates an Event from an Incoming with a generated timestamp.

type FindOptions

type FindOptions struct {
	Type    string
	Project string
	Limit   int
	Offset  int

	// From and To bound the selection by event time (unix seconds with a
	// fraction, same as Event.Timestamp). Zero means "no bound".
	From float64
	To   float64

	// PinnedFirst puts pinned events before the rest, so a limit never
	// pushes a pinned event out of the list.
	PinnedFirst bool
}

FindOptions configures event listing queries.

type Incoming

type Incoming struct {
	UUID    string
	Type    string
	Payload json.RawMessage
	Project string

	// Merge, when set, folds this payload into a stored event with the same
	// UUID and type instead of storing a new one (Ray sends follow-ups such
	// as trace or color under the uuid of the first payload). It gets the
	// stored payload and returns the merged one.
	Merge func(stored json.RawMessage) (json.RawMessage, error)
}

Incoming is what an ingestion handler produces before storage.

type Preview

type Preview struct {
	UUID           string          `json:"uuid"`
	Type           string          `json:"type"`
	Payload        json.RawMessage `json:"payload"`
	Timestamp      float64         `json:"timestamp"`
	Project        string          `json:"project,omitempty"`
	SearchableText string          `json:"searchable_text"`
	IsPinned       bool            `json:"is_pinned"`
}

Preview is the compact representation sent to the UI list and WebSocket.

type PreviewMapper

type PreviewMapper interface {
	ToPreview(payload json.RawMessage) (json.RawMessage, error)
	ToSearchableText(payload json.RawMessage) string
}

PreviewMapper transforms full event payloads into preview/searchable form.

type PreviewRegistry

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

PreviewRegistry maps event types to their PreviewMapper.

func NewPreviewRegistry

func NewPreviewRegistry() *PreviewRegistry

func (*PreviewRegistry) BuildPreview

func (r *PreviewRegistry) BuildPreview(ev Event) Preview

BuildPreview creates a Preview from an Event using the registered mapper.

func (*PreviewRegistry) Get

func (r *PreviewRegistry) Get(eventType string) PreviewMapper

func (*PreviewRegistry) Register

func (r *PreviewRegistry) Register(eventType string, mapper PreviewMapper)

type Store

type Store interface {
	Store(ctx context.Context, ev Event) error
	FindByUUID(ctx context.Context, uuid string) (*Event, error)
	FindAll(ctx context.Context, opts FindOptions) ([]Event, error)
	Delete(ctx context.Context, uuid string) error
	DeleteAll(ctx context.Context, opts DeleteOptions) error
	// UpdatePayload replaces the payload of a stored event; ErrNotFound when
	// there is none.
	UpdatePayload(ctx context.Context, uuid string, payload json.RawMessage) error
	Pin(ctx context.Context, uuid string) error
	Unpin(ctx context.Context, uuid string) error
}

Store persists and retrieves events.

Jump to

Keyboard shortcuts

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