preview

package
v0.205.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 17 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 preview implements server-local job preview leases and loopback proxying.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotActive = errors.New("preview lease is not active")

ErrNotActive is returned when an operation needs a live lease and the lease is gone.

Functions

This section is empty.

Types

type Lease

type Lease struct {
	ID          string `json:"id"`
	JobID       string `json:"job_id"`
	CallerID    string `json:"caller_id"`
	WorkerID    string `json:"worker_id"`
	Port        int    `json:"port"`
	State       string `json:"state"`
	CreatedAt   int64  `json:"created_at"`
	ExpiresAt   int64  `json:"expires_at"`
	CloseReason string `json:"close_reason,omitempty"`
}

Lease is the non-secret view of a preview lease. Port is the preview port the browser opens (not the job's target port).

type Manager

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

func New

func New(store *jobstore.Store, cfg config.PreviewConfig) *Manager

func (*Manager) Close

func (m *Manager) Close(id, reason string) error

func (*Manager) CloseAll

func (m *Manager) CloseAll()

func (*Manager) CloseJob

func (m *Manager) CloseJob(jobID string)

func (*Manager) Create

func (m *Manager) Create(ctx context.Context, jobID, caller, host string, port, ttl int, jobRunning bool) (Lease, string, error)

func (*Manager) Get

func (m *Manager) Get(id string) (Lease, bool, error)

func (*Manager) List

func (m *Manager) List(jobID string) ([]Lease, error)

func (*Manager) Renew added in v0.205.0

func (m *Manager) Renew(id string, ttl int, actor string) (Lease, error)

Renew moves an active lease's expiry to now + ttl (ttl defaults and is capped like on create, so a lease never runs longer than max_ttl_sec from the renewal) and restarts its timer.

func (*Manager) Revoke added in v0.205.0

func (m *Manager) Revoke(id, actor string) error

Revoke closes a lease on behalf of a caller; the audit row names who did it.

func (*Manager) String

func (m *Manager) String() string

func (*Manager) Sweep

func (m *Manager) Sweep()

Jump to

Keyboard shortcuts

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