debugger

package
v0.0.1-alpha.44 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: MIT Imports: 28 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

Overview

Package debugger attaches a step debugger to user code running inside emulated compute — a Lambda function's handler, an ECS container's process — without touching the AWS-facing API (docs/plans/compute-debugger.md).

It exists once, shared by every compute service, because hot reload was implemented twice and drifted. A service touches only Spec, Registry.Resolve, Manager.Ensure, Target.SetUpstream/ClearUpstream, Manager.Release and WithDeadline; everything protocol-specific — the flag to inject, how to tell a pause from a running program, what to paste into an editor — lives behind Protocol, so adding a runtime is one file that registers itself.

Index

Constants

View Source
const (
	EditorVSCode    = "vscode"
	EditorJetBrains = "jetbrains"
	EditorDevTools  = "devtools"
	EditorCLI       = "cli"
)

Editor ids and labels, shared so every protocol names them identically.

View Source
const (
	KindJSON  = "json"
	KindSteps = "steps"
	KindShell = "shell"
)

Editor kinds. json is JSONC — VS Code's launch.json accepts // comments, which is where a leading hint or a code snippet goes.

View Source
const (
	// TagDebug enables debugging with an auto-allocated port.
	TagDebug = "overcast:debug"
	// TagPort enables debugging on a fixed port; it implies TagDebug.
	TagPort = "overcast:debug-port"
	// TagProtocol overrides protocol resolution: inspector, jdwp, dap or
	// passthrough. Required for images and custom runtimes when nothing in
	// the environment gives the protocol away.
	TagProtocol = "overcast:debug-protocol"
	// TagWait holds an invocation whose target has no attached client until
	// one attaches (Target.AwaitClient), so a console or editor that attaches
	// on the cold start sees its breakpoints bind before the handler runs.
	// It is parsed for every service because the spec is shared, but only
	// Lambda has an invocation to hold: an ECS task starts and runs, so on a
	// task definition the tag reaches the descriptor and nothing else.
	TagWait = "overcast:debug-wait"
	// TagSourcePath is the local root editors map the container's code root
	// to. It falls back to TagHotReloadPath, which usually names the same tree.
	TagSourcePath = "overcast:source-path"
	// TagHotReloadPath is hot reload's tag, read here only as the fallback
	// for TagSourcePath — and only for Lambda. On an ECS task definition its
	// suffix names a volume, not a container, so SpecsFromTaskTags leaves it
	// alone and the ECS service supplies the local root from the redirected
	// mount itself.
	TagHotReloadPath = "overcast:hot-reload-path"
)

Tag keys. They are overcast: tags because a tag is inert metadata AWS stores and ignores, so nothing here can change what a deploy does.

View Source
const DebugPortEnv = "OVERCAST_DEBUG_PORT"

DebugPortEnv is set in every debugged container so user code and images can read the port without knowing the protocol.

View Source
const ReasonNotTagged = "not tagged"

ReasonNotTagged is the reason on a synthesised entry for a resource no tag ever mentioned.

View Source
const SettleAfterAttach = 750 * time.Millisecond

SettleAfterAttach is how long an invocation held for a client keeps waiting after one attaches, so the client's first messages — enabling the debugger domain, setting its breakpoints — reach the runtime before the event does. A client that has been attached longer than this when the invocation arrives is not waited on at all.

Variables

View Source
var Default = NewRegistry(inspector{}, jdwp{}, dap{}, passthrough{})

Default is the registry every service uses: the protocols this package ships, with passthrough last so it never shadows a real detection.

View Source
var ErrClosed = errors.New("debugger: manager closed")

ErrClosed is returned by Ensure after Close.

View Source
var ErrNothingToDebug = errors.New("debugger: nothing to debug")

ErrNothingToDebug is returned by Ensure when the resolution names no protocol and no tag asked for one: there is no target to make.

Functions

func BridgePath

func BridgePath(service Service, resource, container string) string

BridgePath is the path of a target's WebSocket bridge on the API listener: GET /_overcast/debugger/targets/{service}/{resource}/ws, with ?container= for an ECS task's container. The BFF serves the same path under /api, so the console prefixes it and nothing else.

func SpecFromTags

func SpecFromTags(service Service, tags map[string]string, flagOn bool) (Spec, []Problem)

SpecFromTags reads a Lambda function's tags. Every value that cannot be honoured is reported and dropped, so the function runs as it would without that tag: AWS accepts any tag, so nothing here may fail a deploy.

func TargetID

func TargetID(service Service, resource, container string) string

TargetID builds the id services register under: "lambda/<function>" or "ecs/<task id>/<container>". Ensure parses it back, so the id is the one place a target's identity is spelled.

func WarnProblems

func WarnProblems(log Warner, problems []Problem, resource ...zap.Field)

WarnProblems logs every problem at WARN, one line each, with fields naming the resource the caller is about: the one place the "tag could not be honoured" line is spelled for every compute service.

func WithDeadline

func WithDeadline(ctx context.Context, clk clock.Clock, timeout time.Duration, t *Target, policy TimeoutPolicy) (context.Context, context.CancelFunc)

WithDeadline bounds ctx by timeout of *running* time: time during which the policy says the target is suspended — a client attached, or the program paused — does not count. Deadline() still reports the nominal deadline, start + timeout, because the Lambda Runtime API derives the deadline header it sends once from it, and that header must stay what AWS would send.

With no target, a target that is not listening, or the strict policy, it is exactly context.WithTimeout: nothing here runs, and the invoke hot path for an undebugged function gains only the nil check.

Types

type ConsoleProtocol

type ConsoleProtocol interface {
	ConsoleDebug() bool
}

ConsoleProtocol is optional. A protocol implementing it says whether the web console ships a client for it, which is what turns the Debug tab's "Debug in console" on. Only the inspector does in this phase: its client is CDP over the bridge, and a DAP client for Python follows on the same surface (docs/plans/compute-debugger-console.md § 6).

type ContainerInspector

type ContainerInspector interface {
	ConnectNetwork(ctx context.Context, networkID, containerID string) error
	InspectContainer(ctx context.Context, id string) (*docker.ContainerInspect, error)
}

ContainerInspector is the slice of the Docker client Bind needs: what dataplane.ContainerAddr reads, plus the inspect that reports a published port.

type Describer

type Describer interface {
	DescribeUntagged(ctx context.Context, service Service, resource string) (Descriptor, bool)
}

Describer synthesises the entry for a resource no tag ever mentioned, so GET /_overcast/debugger/targets/{service}/{resource} always has something for the console to render: enabled false, reason "not tagged", and the setup block. Each compute service implements it for the resources it owns; it is optional, and without one an unknown resource is a 404. ctx is the request's: a service reads its store with it, and the region the request names travels in it.

type Descriptor

type Descriptor struct {
	ID        string `json:"id"`
	Service   string `json:"service"`   // "lambda" | "ecs"
	Resource  string `json:"resource"`  // function name, or task id
	Container string `json:"container"` // ECS container name
	Enabled   bool   `json:"enabled"`
	Reason    string `json:"reason"` // why not, when !enabled

	Protocol       string `json:"protocol"`
	ProtocolSource string `json:"protocolSource"` // "tag" | "runtime" | "env" | "fallback"
	Listen         Listen `json:"listen"`
	State          string `json:"state"` // "inert" | "unbound" | "listening" | "attached" | "paused" | "error"
	AttachedSince  string `json:"attachedSince"`
	PausedSince    string `json:"pausedSince"`
	ContainerID    string `json:"containerId"`
	Upstream       string `json:"upstream"`
	RemoteRoot     string `json:"remoteRoot"`
	LocalRoot      string `json:"localRoot"` // as the user wrote it; "" when unknown
	TimeoutPolicy  string `json:"timeoutPolicy"`

	// WaitForDebugger is TagWait as parsed: an invocation of this target
	// with no client attached is held for one before its event is
	// dispatched (Lambda only; see TagWait). The console toggles it with
	// TagResource/UntagResource and reads it back here.
	WaitForDebugger bool `json:"waitForDebugger"`

	// ConsoleDebug says the console can open a session of its own on this
	// target — true only for a protocol it ships a client for (the
	// inspector). BridgePath is where: the /_overcast/... path of the
	// WebSocket bridge, which the BFF serves under /api as well, so the
	// console never spells the path itself (docs/plans/compute-debugger-console.md
	// § 3.1–3.2). Empty for an entry synthesised for an untagged resource.
	ConsoleDebug bool   `json:"consoleDebug"`
	BridgePath   string `json:"bridgePath"`

	Setup   Setup    `json:"setup"` // always present
	Editors []Editor `json:"editors"`
}

Descriptor is one target as the console and the CLI see it — the JSON shape in docs/plans/compute-debugger.md § 6. Field types stay plain (strings, ints, bools, nested structs, slices) because cmd/tsgen renders this struct for the web console; there is deliberately no custom MarshalJSON to hide anything from it.

func UntaggedDescriptor

func UntaggedDescriptor(service Service, resource, container, arn string) Descriptor

UntaggedDescriptor is the entry the endpoint synthesises for a resource that exists but carries no debug tag, so the console tab always has something to render: off, why, and how to turn it on. Services implement Describer with it.

type Editor

type Editor struct {
	ID       string `json:"id"`
	Label    string `json:"label"`
	Kind     string `json:"kind"` // "json" | "steps" | "shell"
	Body     string `json:"body"`
	Verified bool   `json:"verified"`
}

Editor is one rendered editor tab.

type EditorTemplate

type EditorTemplate struct {
	ID       string // "vscode" | "jetbrains" | "devtools" | "cli"
	Label    string
	Kind     string // "json" | "steps" | "shell"
	Body     string // template source
	Verified bool   // false renders as a note: the template has not been tried end to end
	// contains filtered or unexported fields
}

EditorTemplate is one editor's instructions for one protocol. Body is a text/template rendered with editorData; Kind tells the console how to show it and which comment syntax a leading hint line uses.

type Event

type Event struct {
	Kind   EventKind
	Target *Target
	At     time.Time
}

Event is delivered to subscribers, in order, from the goroutine that caused the transition.

type EventKind

type EventKind string

EventKind is what changed on a target.

const (
	// EventAttach fires when the attach count goes 0→1.
	EventAttach EventKind = "attach"
	// EventDetach fires when the attach count goes 1→0.
	EventDetach EventKind = "detach"
	// EventPause fires when the first connection reports a pause.
	EventPause EventKind = "pause"
	// EventResume fires when the last paused connection resumes or drops.
	EventResume EventKind = "resume"
	// EventUpstream fires when the container behind the port changes — bound,
	// replaced by hot reload, or gone. Target.Upstream reads the new address.
	EventUpstream EventKind = "upstream"
)

type Handler

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

Handler serves the emulator-only endpoints under /_overcast/debugger: the target list, one target's descriptor, and the console's WebSocket bridge. Routes are registered by internal/router; this only provides the handlers.

func NewHandler

func NewHandler(m *Manager, describer Describer) *Handler

NewHandler builds the handler. describer may be nil.

func (*Handler) Bridge

func (h *Handler) Bridge(w http.ResponseWriter, r *http.Request)

Bridge is GET /_overcast/debugger/targets/{service}/{resource}/ws, the console's WebSocket session on a registered target (bridge.go). A resource with no target is a 404 before the upgrade: there is nothing to attach to, and the console only asks once the descriptor said consoleDebug.

func (*Handler) GetTarget

func (h *Handler) GetTarget(w http.ResponseWriter, r *http.Request)

GetTarget is GET /_overcast/debugger/targets/{service}/{resource}, with an optional ?container= for an ECS task's containers. Without one, an ECS task answers with its first container by id, so the console has something to show before it asks for a specific one.

func (*Handler) ListTargets

func (h *Handler) ListTargets(w http.ResponseWriter, r *http.Request)

ListTargets is GET /_overcast/debugger/targets: every registered target, ordered by id — after the describer has had its one chance to register what its store already held (TaggedScanner).

type Listen

type Listen struct {
	Host string `json:"host"`
	Port int    `json:"port"`
}

Listen is the host and port an editor attaches to.

type Manager

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

Manager is the registry of live targets and the owner of their ports. Services call Ensure when a resource is about to run and Release when it is gone; Close is shutdown.

func NewManager

func NewManager(clk clock.Clock, log *zap.Logger, host string, ports [2]int, policy TimeoutPolicy) *Manager

NewManager builds a manager binding on host, allocating auto ports from the inclusive range ports, and applying policy to deadlines.

func (*Manager) Close

func (m *Manager) Close()

Close releases every target and refuses further Ensure calls.

func (*Manager) Ensure

func (m *Manager) Ensure(id string, spec Spec, res Resolution) (*Target, error)

Ensure returns the target for id, creating it on first call. A second call with the same spec and resolution returns the same target; a call with a different one — the tags changed — replaces it, which is how a port change takes effect without a service tracking the old value.

A spec whose flag is off yields an inert target: no listener, no goroutine, a reason the console shows. A spec whose fixed port is taken yields a target in StateError with the reason — never a silent fallback port, because the user typed that port into an editor.

func (*Manager) Get

func (m *Manager) Get(id string) (*Target, bool)

Get returns the target registered under id.

func (*Manager) List

func (m *Manager) List() []*Target

List returns every target, ordered by id, so the console's list is stable between polls.

func (*Manager) Release

func (m *Manager) Release(id string)

Release closes the target's listener and every connection through it and forgets it. A second Release, or one for an unknown id, does nothing.

type MessageObserver

type MessageObserver interface {
	FromServerMessage(msg []byte) (paused, resumed bool)
}

MessageObserver is optional on an Observer. The console's bridge relays a WebSocket protocol message by message, so it hands the observer each whole container→client message rather than re-encoding it into the frames FromServer would parse. The two entry points share one state: a pause seen either way is the same pause.

type Observer

type Observer interface {
	FromServer(b []byte) (paused, resumed bool)
}

Observer sees one connection's bytes. FromServer is fed the container→client direction; it must tolerate arbitrary chunking and never block or fail — an unparseable stream simply reports nothing.

type PauseObserver

type PauseObserver interface {
	NewObserver() Observer
}

PauseObserver is optional. A protocol implementing it can tell a pause from a running program, which OVERCAST_DEBUGGER_TIMEOUT=paused uses.

type Problem

type Problem struct {
	// Key is the tag key as written, including any container suffix.
	Key string
	// Value is the offending value, empty when the key itself is the problem.
	Value string
	// Reason is one sentence saying what could not be honoured.
	Reason string
	// Hint names the fix.
	Hint string
}

Problem is one tag the parser could not honour, in a shape the caller logs at WARN. The caller owns the logger and the log line — this package only says what was wrong and what fixes it, mirroring how hot reload reports its tags.

func SpecsFromTaskTags

func SpecsFromTaskTags(tags map[string]string, containers []string, flagOn bool) (map[string]Spec, []Problem)

SpecsFromTaskTags reads an ECS task definition's tags for the named containers. A key suffixed "/<container>" names its container and wins; the bare key is a convenience for the single-container task and is refused, naming the candidates, when it would have to guess. The result holds only containers a tag addressed, so the common untagged task allocates nothing.

func (Problem) Fields

func (p Problem) Fields() []zap.Field

Fields renders the problem as structured log fields, so every service logs it the same way.

type Protocol

type Protocol interface {
	Name() string                             // "inspector", "jdwp", "dap", "passthrough"
	Runtimes() []string                       // AWS runtime prefixes: "nodejs", "java", "python"; nil for none
	Inject(env map[string]string, port int)   // append the listen flag; never clobber a user value
	Detect(env map[string]string) (int, bool) // an existing user flag → implicit enable
	Editors() []EditorTemplate                // per-editor templates, rendered by descriptor.go
}

Protocol is one debugger wire protocol. Adding one is a file that registers itself in Default; no service, proxy or console code changes.

type Registry

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

Registry is the ordered set of protocols resolution consults. Order matters only for Detect, where the first protocol to recognise the environment wins.

func NewRegistry

func NewRegistry(protocols ...Protocol) *Registry

NewRegistry builds a registry from the given protocols, in order.

func (*Registry) Lookup

func (r *Registry) Lookup(name string) (Protocol, bool)

Lookup finds a protocol by name.

func (*Registry) Names

func (r *Registry) Names() []string

Names lists the registered protocol names, for messages that tell the user what overcast:debug-protocol accepts.

func (*Registry) Resolve

func (r *Registry) Resolve(spec Spec, runtime string, env map[string]string) Resolution

Resolve picks the protocol for a resource, in the order the plan fixes: the tag, then the runtime, then a flag already present in the environment, then passthrough for anything tagged, then nothing.

Only the environment step applies to an untagged resource: a runtime match alone would give every Node function a target, and the whole point of the tag is that nothing costs anything until someone asks.

Whenever a protocol is chosen by tag or runtime, its Detect still runs: Inject never clobbers a user's own flag, so the port that flag names is the port the container will actually listen on, and the proxy must dial it.

type Resolution

type Resolution struct {
	Protocol Protocol
	// Port is the container-side port: the tag's fixed port, or the one a
	// pre-existing user flag names, or 0 for auto-allocation.
	Port   int
	Source Source
}

Resolution is the protocol a target speaks and the port the container will listen on. A nil Protocol means there is nothing to debug.

type Service

type Service string

Service is a compute service the debugger attaches to. It picks the per-service flag a warning names, the tagging command the console shows, and the first segment of a target id.

const (
	// ServiceLambda is the Lambda function service.
	ServiceLambda Service = "lambda"
	// ServiceECS is the ECS task service.
	ServiceECS Service = "ecs"
)

func (Service) FlagEnv

func (s Service) FlagEnv() string

FlagEnv is the environment variable that enables the debugger for this service, named in every "requested but off" warning so the fix is one copy-paste away.

type Setup

type Setup struct {
	Flag   string `json:"flag"`
	TagCLI string `json:"tagCli"`
	TagCDK string `json:"tagCdk"`
}

Setup is how to turn the debugger on: the flag, and the tag as a CLI command and a CDK line. Present even when everything is already on, so the console never has to know how to spell them.

func SetupFor

func SetupFor(service Service, arn string) Setup

SetupFor renders the setup block for a service. arn is the ARN of the resource that carries the tag — the function, or the task definition — and may be empty, in which case a placeholder says what belongs there.

type Source

type Source string

Source says how a target's protocol was chosen, so the console can explain a surprising choice ("env: NODE_OPTIONS already carried --inspect").

const (
	// SourceTag means overcast:debug-protocol named the protocol.
	SourceTag Source = "tag"
	// SourceRuntime means the AWS runtime identifier matched a protocol.
	SourceRuntime Source = "runtime"
	// SourceEnv means a debug flag already in the environment was recognised.
	SourceEnv Source = "env"
	// SourceFallback means nothing matched and passthrough was chosen, which
	// is where images and custom runtimes land.
	SourceFallback Source = "fallback"
)

type Spec

type Spec struct {
	// Service the resource belongs to.
	Service Service
	// Container is the ECS container the spec applies to; empty for Lambda.
	Container string
	// Tagged reports that a tag asked for debugging.
	Tagged bool
	// FlagOn is the service's OVERCAST_<SERVICE>_DEBUGGER flag.
	FlagOn bool
	// Port is the fixed port from TagPort; 0 means auto-allocate.
	Port int
	// Protocol is the TagProtocol override, validated against the default
	// registry; empty means resolve.
	Protocol string
	// Wait is TagWait: hold an invocation for a client before dispatching
	// its event. Lambda only, in effect; see TagWait.
	Wait bool
	// SourcePath is the local root as the daemon would see it (normalised
	// through hostpath), used to decide whether a root is known.
	SourcePath string
	// SourcePathRaw is the local root exactly as the user wrote it — the
	// form their editor wants, which on Windows is not the normalised one.
	SourcePathRaw string
}

Spec is what the tags asked for, for one resource (or one ECS container), after validation. It carries the service flag too, so a target can be registered as inert — present in the console, explaining why it is off — when a tag asks for a debugger the server has not enabled.

func (Spec) Enabled

func (s Spec) Enabled() bool

Enabled reports whether a debugger will actually be offered: a tag asked and the server allows it.

type State

type State string

State is where a target is in its life. It is a string so the descriptor carries it unchanged.

const (
	// StateInert is a tagged resource the server flag keeps off: registered
	// so the console can say why, with no listener.
	StateInert State = "inert"
	// StateUnbound is a listener with no container behind it yet.
	StateUnbound State = "unbound"
	// StateListening is a listener with an upstream and no client.
	StateListening State = "listening"
	// StateAttached is at least one client connected.
	StateAttached State = "attached"
	// StatePaused is a connected client whose protocol reports a pause.
	StatePaused State = "paused"
	// StateError is a listener that could not be bound; Reason says why.
	StateError State = "error"
)

type TaggedScanner

type TaggedScanner interface {
	ScanTagged(ctx context.Context)
}

TaggedScanner is the optional second half of a Describer: a service that can register every tagged resource its store already holds, so the first ListTargets after a start lists resources tagged before a restart without a describe or a run first. The service owns the once-only: the handler calls it on every list, and a service that has scanned returns at once. A describer that does not implement it is simply not scanned.

type Target

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

Target is one debuggable resource: its loopback listener, the container behind it, and who is attached. Every method is safe to call from any goroutine.

func (*Target) ApplyPortBinding

func (t *Target) ApplyPortBinding(cfg *docker.ContainerConfig, hc *docker.HostConfig)

ApplyPortBinding exposes the debug port on the container and publishes it on an ephemeral loopback port of the Docker host. It is added whether or not Overcast will use it (a containerised Overcast dials the container's IP instead): it is cheap, and it avoids a second decision at create time.

func (*Target) Attached

func (t *Target) Attached() bool

Attached reports whether at least one client is connected.

func (*Target) AwaitClient

func (t *Target) AwaitClient(ctx context.Context, timeout time.Duration) WaitResult

AwaitClient holds the caller until a client is attached to the target, for an invocation whose TagWait asks for it: an editor or the console attaching on the cold start then sees its breakpoints bind before the handler runs (docs/plans/compute-debugger-console.md § 6). It returns at once, WaitSkipped, when there is nothing to wait for; otherwise it waits for the attach event — subscribed, not polled — then for SettleAfterAttach measured from the moment of the attach, whether that attach happened during the hold or shortly before it.

The hold is bounded by timeout, after which the invocation proceeds undebugged (WaitExpired), and ends with ctx (WaitCancelled): a caller that disconnects releases the environment it was holding. Under the strict timeout policy nothing may hold an invocation, so the tag is ignored — said once when the target is registered, not here.

The invocation clock is not running during the hold: a caller bounds its invocation only after AwaitClient returns, so the budget starts, and the nominal deadline the Runtime API reports is computed, at dispatch.

func (*Target) Bind

func (t *Target) Bind(ctx context.Context, dc ContainerInspector, cfg *config.Config, networkOwnerID, containerID string)

Bind points the proxy at a container that has just started, per docs/plans/compute-debugger.md § 3.6: the container's own address when Overcast can route to it (Overcast in Docker), else the ephemeral loopback port Docker published for the binding ApplyPortBinding asked for. Both are read from networkOwnerID, the container whose network the debugged process runs in — the container itself, or the namespace container an ECS awsvpc task's containers share — while containerID is what the console names and what ClearContainer later matches. A target with no listener has nothing to bind and is left alone; failing to find the port leaves the target unbound with a WARN, and the container runs undebugged.

func (*Target) Bound

func (t *Target) Bound() bool

Bound reports whether the target has a listener an editor could attach to: enabled, not in error, not released. It is the precondition for injecting, publishing ports, dialling a container and suspending a deadline, and what a service checks before it pays anything — an image inspect, an instance cap — on the target's behalf.

func (*Target) ClearContainer

func (t *Target) ClearContainer(id string)

ClearContainer forgets the upstream and the container id, but only while id is still the container behind the port. A service calls it when a container goes away; a retired container closing after its replacement was bound must not blind the proxy to the replacement, which is what an unconditional ClearUpstream from that container's Close would do.

func (*Target) ClearUpstream

func (t *Target) ClearUpstream()

ClearUpstream makes new connections close immediately, which editors that poll treat as "not yet", until SetUpstream is called again.

func (*Target) Container

func (t *Target) Container() string

Container is the ECS container name; empty for Lambda.

func (*Target) Descriptor

func (t *Target) Descriptor() Descriptor

Descriptor renders the target for the console and the CLI.

func (*Target) Enabled

func (t *Target) Enabled() bool

Enabled reports whether the target has (or tried to bind) a listener.

func (*Target) Host

func (t *Target) Host() string

Host is the address the listener binds.

func (*Target) HostPortFrom

func (t *Target) HostPortFrom(inspect *docker.ContainerInspect) (int, bool)

HostPortFrom reads the ephemeral host port ApplyPortBinding asked for from an inspect response, for the native case where the container's own IP is not routable from Overcast.

func (*Target) ID

func (t *Target) ID() string

ID is the id the target was registered under.

func (*Target) Inject

func (t *Target) Inject(env map[string]string)

Inject adds the protocol's listen flag and OVERCAST_DEBUG_PORT to a container environment. A target without a listener injects nothing: a flag that makes the runtime wait for a debugger nobody can reach would hang the function.

func (*Target) Paused

func (t *Target) Paused() bool

Paused reports whether a connected client's protocol reports a pause.

func (*Target) Port

func (t *Target) Port() int

Port is the port editors attach to and the container listens on — the same number on both sides, so the inspector's own URLs match what the editor asked for. Zero while unbound or inert.

func (*Target) Protocol

func (t *Target) Protocol() Protocol

Protocol is the resolved protocol; nil for an inert target with no resolution.

func (*Target) Reason

func (t *Target) Reason() string

Reason says why the target is inert or in error; empty otherwise.

func (*Target) RemoteRoot

func (t *Target) RemoteRoot() string

RemoteRoot is the container path editors map the local root to, or empty until a service sets it.

func (*Target) Resource

func (t *Target) Resource() string

Resource is the function name or task id.

func (*Target) ServeWebSocket

func (t *Target) ServeWebSocket(w http.ResponseWriter, r *http.Request)

ServeWebSocket is the bridge for one console session on the target: GET /_overcast/debugger/targets/{service}/{resource}/ws, upgraded. The session lasts until the console closes it, the container goes away (1011), the container is replaced (1012), the console stops answering pings (1001), or the target is released — and every goroutine it started has exited when it returns.

func (*Target) Service

func (t *Target) Service() Service

Service is the compute service the target belongs to.

func (*Target) SetContainerID

func (t *Target) SetContainerID(id string)

SetContainerID records the container behind the upstream, for the console.

func (*Target) SetRemoteRoot

func (t *Target) SetRemoteRoot(path string)

SetRemoteRoot records the container path editors map the local root to: /var/task for a zip, the image's working directory otherwise.

func (*Target) SetResourceARN

func (t *Target) SetResourceARN(arn string)

SetResourceARN records the ARN of the resource that carries the tag, so the setup block's CLI command is copy-paste ready.

func (*Target) SetUpstream

func (t *Target) SetUpstream(addr string)

SetUpstream points new connections at the container's debug port. It may be called again when the container is replaced; connections to the old one are left to close on their own, which is what lets an editor's reconnect find the new container on the same port.

func (*Target) Source

func (t *Target) Source() Source

Source is how the protocol was chosen.

func (*Target) Spec

func (t *Target) Spec() Spec

Spec is what the tags asked for, as of the last Ensure.

func (*Target) State

func (t *Target) State() State

State is the target's current state.

func (*Target) Subscribe

func (t *Target) Subscribe(fn func(Event)) (unsubscribe func())

Subscribe registers fn for attach, detach, pause and resume events and returns a function that removes it. Callbacks run synchronously on the goroutine that caused the transition and must return promptly; they must not call back into the Manager, whose Release, Close and replacing Ensure wait for those goroutines.

func (*Target) Upstream

func (t *Target) Upstream() string

Upstream is the address new connections are forwarded to; empty when none.

func (*Target) UpstreamFor

func (t *Target) UpstreamFor(containerAddr string, inspect *docker.ContainerInspect) (string, bool)

UpstreamFor is the address the proxy dials for a started container, per docs/plans/compute-debugger.md § 3.6: containerAddr on the debug port when Overcast can reach the container directly (dataplane.ContainerAddr, only ever non-empty for a containerised Overcast), else the loopback host port inspect reports for the binding ApplyPortBinding asked for. inspect must be of the container whose HostConfig carries that binding — the container itself, or the namespace container an ECS awsvpc task's containers share. ok is false when neither is known, which is reported rather than guessed.

func (*Target) Wait

func (t *Target) Wait() bool

Wait reports TagWait: an invocation with no client attached is held for one before its event is dispatched. See AwaitClient.

type TargetList

type TargetList struct {
	Targets []Descriptor `json:"targets"`
}

TargetList is the GET /_overcast/debugger/targets body.

type TimeoutPolicy

type TimeoutPolicy = config.DebuggerTimeoutPolicy

TimeoutPolicy is config.DebuggerTimeoutPolicy under the name this package uses; the enum lives in config so it is parsed once and never redeclared.

type WaitResult

type WaitResult string

WaitResult says how AwaitClient ended.

const (
	// WaitSkipped is an invocation that was never held: the target does not
	// ask for it (no TagWait, not bound, or the strict policy), or a client
	// was already attached for longer than the settle.
	WaitSkipped WaitResult = "skipped"
	// WaitAttached is a client attaching while held, plus the settle.
	WaitAttached WaitResult = "attached"
	// WaitExpired is the timeout passing with nobody attached. The caller
	// proceeds as if untagged, and says so.
	WaitExpired WaitResult = "expired"
	// WaitCancelled is the caller's context ending during the hold.
	WaitCancelled WaitResult = "cancelled"
)

type Warner

type Warner interface {
	Warn(msg string, fields ...zap.Field)
}

Warner is the one method of a logger WarnProblems needs, so a service's own logger wrapper and a bare *zap.Logger both serve.

Directories

Path Synopsis
Package debuggertest holds what a compute service's tests need to stand up a debugger.Manager: a port range the OS just proved free, so a manager under test binds without touching the real 9229-9329 range or any fixed port.
Package debuggertest holds what a compute service's tests need to stand up a debugger.Manager: a port range the OS just proved free, so a manager under test binds without touching the real 9229-9329 range or any fixed port.

Jump to

Keyboard shortcuts

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