client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	WebhookCh chan WebhookEvent
	StatusCh  chan StatusEvent
	// contains filtered or unexported fields
}

Client orchestrates the tunnel connection and exposes event channels for the TUI to consume.

func New

func New(cfg Config, logger *slog.Logger) *Client

func (*Client) Run

func (c *Client) Run(ctx context.Context) error

Run starts the tunnel and blocks until ctx is cancelled.

type Config

type Config struct {
	ServerAddr           string        `mapstructure:"server"`
	Token                string        `mapstructure:"token"`
	ForwardURL           string        `mapstructure:"forward"`
	TLS                  bool          `mapstructure:"tls"`
	ReconnectInterval    time.Duration `mapstructure:"reconnect_interval"`
	MaxReconnectInterval time.Duration `mapstructure:"max_reconnect_interval"`
	ForwardTimeout       time.Duration `mapstructure:"forward_timeout"`
}

func DefaultConfig

func DefaultConfig() Config

type Forwarder

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

Forwarder replays incoming webhook requests against a local HTTP target.

func NewForwarder

func NewForwarder(targetURL string, timeout time.Duration) *Forwarder

func (*Forwarder) Forward

Forward replays a WebhookRequest to the local target and returns the captured response. The returned WebhookResponse has request_id set for correlation in sync mode.

type StatusEvent

type StatusEvent struct {
	Connected  bool
	EndpointID string
	ServerAddr string
	Message    string
}

StatusEvent communicates connection state changes to the TUI.

type Tunnel

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

Tunnel maintains a persistent gRPC connection to the server.

func NewTunnel

func NewTunnel(cfg Config, logger *slog.Logger, webhookCh chan WebhookEvent, statusCh chan StatusEvent) *Tunnel

func (*Tunnel) Run

func (t *Tunnel) Run(ctx context.Context) error

Run connects to the server and processes webhooks until ctx is cancelled. It automatically reconnects with exponential backoff on failures.

type WebhookEvent

type WebhookEvent struct {
	Request    *hookerv1.WebhookRequest
	Response   *hookerv1.WebhookResponse
	Error      error
	ReceivedAt time.Time
	Duration   time.Duration
}

WebhookEvent is sent to the TUI whenever a webhook is received and forwarded.

Jump to

Keyboard shortcuts

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