proxy

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2026 License: Apache-2.0 Imports: 25 Imported by: ? 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DeviceName is the name of the device sent to Hookdeck to help identify the device
	DeviceName string
	// Key is the API key used to authenticate with Hookdeck
	Key              string
	ProjectID        string
	ProjectMode      string
	URL              *url.URL
	APIBaseURL       string
	DashboardBaseURL string
	ConsoleBaseURL   string
	WSBaseURL        string
	Log              *log.Logger
	// Force use of unencrypted ws:// protocol instead of wss://
	NoWSS    bool
	Insecure bool
	// Disable periodic health checks of the local server
	NoHealthcheck bool
	// Output mode: interactive, compact, quiet
	Output   string
	GuestURL string
	// MaxConnections allows tuning the maximum concurrent connections per host.
	// Default: 50 concurrent connections
	// This can be increased for high-volume testing scenarios where the local
	// endpoint can handle more concurrent requests.
	// Example: Set to 100+ when load testing with many parallel webhooks.
	// Warning: Setting this too high may cause resource exhaustion.
	MaxConnections int
	// Filters for this CLI session
	Filters *hookdeck.SessionFilters
}

Config provides the configuration of a Proxy

type EventResponse

type EventResponse struct {
	StatusCode int
	Headers    map[string][]string
	Body       string
	Duration   time.Duration
}

EventResponse contains the HTTP response data

type InteractiveRenderer

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

InteractiveRenderer renders events using Bubble Tea TUI

func NewInteractiveRenderer

func NewInteractiveRenderer(cfg *RendererConfig) *InteractiveRenderer

NewInteractiveRenderer creates a new interactive renderer with Bubble Tea

func (*InteractiveRenderer) Cleanup

func (r *InteractiveRenderer) Cleanup()

Cleanup gracefully stops the TUI and restores terminal

func (*InteractiveRenderer) Done

func (r *InteractiveRenderer) Done() <-chan struct{}

Done returns a channel that is closed when the renderer wants to quit

func (*InteractiveRenderer) OnConnected

func (r *InteractiveRenderer) OnConnected()

OnConnected is called when websocket connects

func (*InteractiveRenderer) OnConnecting

func (r *InteractiveRenderer) OnConnecting()

OnConnecting is called when starting to connect

func (*InteractiveRenderer) OnConnectionWarning

func (r *InteractiveRenderer) OnConnectionWarning(activeRequests int32, maxConns int)

OnConnectionWarning is called when approaching connection limits

func (*InteractiveRenderer) OnDisconnected

func (r *InteractiveRenderer) OnDisconnected()

OnDisconnected is called when websocket disconnects

func (*InteractiveRenderer) OnError

func (r *InteractiveRenderer) OnError(err error)

OnError is called when an error occurs

func (*InteractiveRenderer) OnEventComplete

func (r *InteractiveRenderer) OnEventComplete(eventID string, attempt *websocket.Attempt, response *EventResponse, startTime time.Time)

OnEventComplete is called when an event completes successfully

func (*InteractiveRenderer) OnEventError

func (r *InteractiveRenderer) OnEventError(eventID string, attempt *websocket.Attempt, err error, startTime time.Time)

OnEventError is called when an event encounters an error

func (*InteractiveRenderer) OnEventPending

func (r *InteractiveRenderer) OnEventPending(eventID string, attempt *websocket.Attempt, startTime time.Time)

OnEventPending is called when an event starts (after 100ms delay)

func (*InteractiveRenderer) OnServerHealthChanged added in v1.5.0

func (r *InteractiveRenderer) OnServerHealthChanged(healthy bool, err error)

OnServerHealthChanged is called when server health status changes

type Proxy

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

A Proxy opens a websocket connection with Hookdeck, listens for incoming webhook events, forwards them to the local endpoint and sends the response back to Hookdeck.

func New

func New(cfg *Config, connections []*hookdecksdk.Connection, renderer Renderer) *Proxy

New creates a new Proxy

func (*Proxy) Run

func (p *Proxy) Run(parentCtx context.Context) error

Run manages the connection to Hookdeck. The connection is established in phases:

  • Create a new CLI session
  • Create a new websocket connection

type Renderer

type Renderer interface {
	// Lifecycle events
	OnConnecting()
	OnConnected()
	OnDisconnected()
	OnError(err error)

	// Event handling
	OnEventPending(eventID string, attempt *websocket.Attempt, startTime time.Time) // For interactive mode (100ms delay)
	OnEventComplete(eventID string, attempt *websocket.Attempt, response *EventResponse, startTime time.Time)
	OnEventError(eventID string, attempt *websocket.Attempt, err error, startTime time.Time)

	// Connection warnings
	OnConnectionWarning(activeRequests int32, maxConns int)

	// Server health monitoring
	OnServerHealthChanged(healthy bool, err error)

	// Cleanup is called before exit to clean up resources (e.g., stop TUI, stop spinner)
	Cleanup()

	// Done returns a channel that signals when user wants to quit
	Done() <-chan struct{}
}

Renderer is the interface for handling proxy output Implementations handle different output modes (interactive, compact, quiet)

func NewRenderer

func NewRenderer(cfg *RendererConfig) Renderer

NewRenderer creates the appropriate renderer based on output mode

type RendererConfig

type RendererConfig struct {
	DeviceName       string
	APIKey           string
	APIBaseURL       string
	DashboardBaseURL string
	ConsoleBaseURL   string
	ProjectMode      string
	ProjectID        string
	GuestURL         string
	TargetURL        *url.URL
	Output           string
	Sources          []*hookdecksdk.Source
	Connections      []*hookdecksdk.Connection
	Filters          *hookdeck.SessionFilters
}

RendererConfig contains configuration for creating renderers

type SimpleRenderer

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

SimpleRenderer renders events to stdout for compact and quiet modes

func NewSimpleRenderer

func NewSimpleRenderer(cfg *RendererConfig, quietMode bool) *SimpleRenderer

NewSimpleRenderer creates a new simple renderer

func (*SimpleRenderer) Cleanup

func (r *SimpleRenderer) Cleanup()

Cleanup stops the spinner and cleans up resources

func (*SimpleRenderer) Done

func (r *SimpleRenderer) Done() <-chan struct{}

Done returns a channel that is closed when the renderer wants to quit

func (*SimpleRenderer) OnConnected

func (r *SimpleRenderer) OnConnected()

OnConnected is called when websocket connects

func (*SimpleRenderer) OnConnecting

func (r *SimpleRenderer) OnConnecting()

OnConnecting is called when starting to connect

func (*SimpleRenderer) OnConnectionWarning

func (r *SimpleRenderer) OnConnectionWarning(activeRequests int32, maxConns int)

OnConnectionWarning is called when approaching connection limits

func (*SimpleRenderer) OnDisconnected

func (r *SimpleRenderer) OnDisconnected()

OnDisconnected is called when websocket disconnects

func (*SimpleRenderer) OnError

func (r *SimpleRenderer) OnError(err error)

OnError is called when an error occurs

func (*SimpleRenderer) OnEventComplete

func (r *SimpleRenderer) OnEventComplete(eventID string, attempt *websocket.Attempt, response *EventResponse, startTime time.Time)

OnEventComplete is called when an event completes successfully

func (*SimpleRenderer) OnEventError

func (r *SimpleRenderer) OnEventError(eventID string, attempt *websocket.Attempt, err error, startTime time.Time)

OnEventError is called when an event encounters an error

func (*SimpleRenderer) OnEventPending

func (r *SimpleRenderer) OnEventPending(eventID string, attempt *websocket.Attempt, startTime time.Time)

OnEventPending is called when an event starts (not used in simple renderer)

func (*SimpleRenderer) OnServerHealthChanged added in v1.5.0

func (r *SimpleRenderer) OnServerHealthChanged(healthy bool, err error)

OnServerHealthChanged is called when server health status changes

Jump to

Keyboard shortcuts

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