devtoolsproxy

package
v0.0.0-...-edaff49 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WebSocketProxyHandler

func WebSocketProxyHandler(mgr *UpstreamManager, logger *slog.Logger, logCDPMessages bool, ctrl scaletozero.Controller, publish EventPublisher, controlEnabled ControlEnabledFunc, excludedMethods ExcludedMethodsFunc, reg *wsdrain.Registry) http.Handler

WebSocketProxyHandler returns an http.Handler that upgrades incoming connections and proxies them to the current upstream websocket URL. It expects only websocket requests. If logCDPMessages is true, all CDP messages will be logged with their direction. publish is invoked on accept (cdp_connect) and on teardown (cdp_disconnect); pass nil to disable emission. controlEnabled gates cdp_command classification and is checked once per forwarded client frame; pass nil to disable it. excludedMethods names the control methods configured out of the stream; nil reports them all.

Types

type ControlEnabledFunc

type ControlEnabledFunc func() bool

ControlEnabledFunc reports whether control-category telemetry is currently captured. The proxy calls it once per forwarded client frame, so it must be cheap: telemetry.TelemetrySession.CategoryEnabled is lock-free for this.

type EventPublisher

type EventPublisher func(ev events.Event) (events.Envelope, bool)

EventPublisher publishes a telemetry event onto the in-VM events pipeline. nil disables emission. Signature matches TelemetrySession.Publish so it can be wired directly; the proxy ignores the returns.

type ExcludedMethodsFunc

type ExcludedMethodsFunc func() map[string]struct{}

ExcludedMethodsFunc returns the browser-control methods configured out of the cdp_command stream, or nil when none are. Consulted at admission, once the method is known, so an excluded command never occupies the queue.

type UpstreamManager

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

UpstreamManager tails the Chromium supervisord log and extracts the current DevTools websocket URL, updating it whenever Chromium restarts and emits a new line.

func NewUpstreamManager

func NewUpstreamManager(logFilePath string, logger *slog.Logger) *UpstreamManager

func (*UpstreamManager) Current

func (u *UpstreamManager) Current() string

Current returns the current upstream websocket URL if known, or empty string.

func (*UpstreamManager) Start

func (u *UpstreamManager) Start(ctx context.Context)

Start begins background tailing and updating the upstream URL until ctx is done.

func (*UpstreamManager) Stop

func (u *UpstreamManager) Stop()

Stop cancels the background tailer.

func (*UpstreamManager) Subscribe

func (u *UpstreamManager) Subscribe() (<-chan string, func())

Subscribe returns a channel that receives new upstream URLs as they are discovered. The returned cancel function should be called to unsubscribe and release resources.

func (*UpstreamManager) WaitForInitial

func (u *UpstreamManager) WaitForInitial(timeout time.Duration) (string, error)

WaitForInitial blocks until an initial upstream URL has been discovered or the timeout elapses.

Jump to

Keyboard shortcuts

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