Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
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.
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)
// Respond, when set, writes the HTTP answer after the event is stored,
// instead of the default acknowledgement (a provider API the client
// expects to answer in its own shape, e.g. Twilio's 201 with a sid).
Respond func(w http.ResponseWriter)
}
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.