annotator

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package annotator is the official example Interseptor extension (see docs/extensions.md and issue #25). It is intentionally small and dependency-light: a working demonstration of the Phase-1 in-process hook API that a third-party author can copy.

What it does: when a flow is captured, if its host contains any of the configured substrings, it adds a tag to that flow — so an operator can, for example, auto-label every request that touches an internal admin host.

It follows the two rules every hook must follow:

  • never block the proxy hot path — the hook body just hands off to a goroutine and returns immediately;
  • never import proxy/control types — it talks to the host through the small Store interface below, so it stays decoupled and unit-testable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enable

func Enable(st Store, cfg Config)

Enable registers the annotator against the plugin registry. Call once at startup (see cmd/interseptor wiring). It is a no-op when st is nil or the config matches nothing, so an accidental enable can never tag every flow.

Types

type Config

type Config struct {
	// HostContains: a flow is annotated when its host contains any of these
	// (case-insensitive) substrings. Empty means "match nothing".
	HostContains []string
	// Tag applied to matching flows. Defaults to "annotated" when empty.
	Tag string
}

Config declares which flows to tag and with what.

type Store

type Store interface {
	GetFlow(id int64) (*store.Flow, error)
	AddFlowTags(flowID int64, tags []string) ([]string, error)
}

Store is the slice of the host the annotator needs. *store.Store satisfies it.

Jump to

Keyboard shortcuts

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