isolate

package
v0.7.21 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package isolate is the blank-workerd warm pool for the V8-isolate runtime (plans/isolate-runtime.md §4 Phase 3). Unlike the WASM pool (keyed by module digest), these slots are blank group hosts — the group router runs before the pool, so only a tenant's FIRST create claims a slot and injects a bundle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {
	Hits      atomic.Int64
	Misses    atomic.Int64
	Refilled  atomic.Int64
	SpawnFail atomic.Int64
}

Metrics are hit/miss/refill counters for expvar-style observation.

func (*Metrics) Stats

func (m *Metrics) Stats() Snapshot

Stats returns current counter values.

type Pool

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

Pool keeps pre-spawned blank workerd group hosts.

func New

func New(logger *slog.Logger) *Pool

New constructs an empty warm pool.

func (*Pool) Acquire

func (p *Pool) Acquire(_ context.Context) (isolateruntime.GroupHost, bool)

Acquire removes one blank host. ok=false on miss (caller cold-spawns).

func (*Pool) Close

func (p *Pool) Close()

Close stops every queued blank host.

func (*Pool) Metrics

func (p *Pool) Metrics() *Metrics

func (*Pool) ReadyCount

func (p *Pool) ReadyCount() int

ReadyCount returns how many blank hosts are queued.

func (*Pool) RunRefill

func (p *Pool) RunRefill(ctx context.Context, interval time.Duration)

RunRefill tops the pool up to depth on a ticker and on Acquire miss kicks.

func (*Pool) SetDepth

func (p *Pool) SetDepth(n int)

func (*Pool) SetSpawner

func (p *Pool) SetSpawner(s Spawner)

func (*Pool) WarmOne

func (p *Pool) WarmOne(ctx context.Context) error

WarmOne spawns one blank host into the pool (boot prewarm + refill).

type Snapshot

type Snapshot struct {
	Hits      int64
	Misses    int64
	Refilled  int64
	SpawnFail int64
}

Snapshot is a point-in-time view of pool counters.

type Spawner

type Spawner interface {
	Spawn(ctx context.Context) (isolateruntime.GroupHost, error)
}

Spawner creates a blank group host for the pool.

Jump to

Keyboard shortcuts

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