whwrite

package
v1.163.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package whwrite files a webhook source's events as raw segments, the way the HTTP receiver writes a request's: one gzipped JSON-lines object per window, the window recorded before and after the write, its raw partition registered after, and the scripts naming the source told (#2332). The inputs the platform reads itself rather than being posted to, a mailbox (#2247) and an application database (#2408), write through it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Objects    Objects
	Bucket     string
	Recorder   Recorder
	RawWindows RawWindows
	// Writer names the writer in each segment's key: "imap-<replica>".
	Writer string
	Logger *slog.Logger
	Now    func() time.Time
}

Config assembles a writer.

type Objects

type Objects interface {
	PutObject(ctx context.Context, bucket, key string, data []byte, contentType string) error
}

Objects writes a segment to the managed-resources bucket.

type RawWindows

type RawWindows interface {
	EnsureRawWindow(ctx context.Context, src whsource.Source, start time.Time) error
}

RawWindows registers a window's raw partition so its events are queryable before compaction.

type Recorder

type Recorder interface {
	MarkSegment(ctx context.Context, source string, start time.Time, length time.Duration, bytes int64) error
}

Recorder records a window a segment was written to.

type Writer

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

Writer files events as segments.

func New

func New(cfg Config) *Writer

New returns a writer.

func (*Writer) SetStored

func (w *Writer) SetStored(fn func(ctx context.Context, source string, events []whevent.Event))

SetStored is what is told each written segment's events from here on: the hook the runs of an automation naming the source are enqueued through.

func (*Writer) Write

func (w *Writer) Write(ctx context.Context, src whsource.Source, events []whevent.Event) error

Write files events as segments, one per window, oldest window first.

Jump to

Keyboard shortcuts

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