puppet

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2026 License: GPL-3.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 Collector

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

Collector uses a Pool of headless Chromium instances to visit target URLs and extract browser telemetry by evaluating the embedded collect.js script.

func NewCollector

func NewCollector(pool *Pool, navTimeout time.Duration, logger *slog.Logger) *Collector

NewCollector creates a Collector backed by the given pool.

func (*Collector) CollectTelemetry

func (c *Collector) CollectTelemetry(ctx context.Context, targetURL string) (map[string]any, error)

func (*Collector) Shutdown

func (c *Collector) Shutdown(ctx context.Context) error

type NoOpCollector

type NoOpCollector struct{}

NoOpCollector is a puppet implementation that does nothing. Used when puppet is disabled or Chromium is unavailable.

func (*NoOpCollector) CollectTelemetry

func (n *NoOpCollector) CollectTelemetry(_ context.Context, _ string) (map[string]any, error)

func (*NoOpCollector) Shutdown

func (n *NoOpCollector) Shutdown(_ context.Context) error

type OverrideBuilder

type OverrideBuilder struct{}

OverrideBuilder converts raw telemetry into a JS IIFE that overrides browser properties to match a real Chromium visit.

func (*OverrideBuilder) BuildOverride

func (b *OverrideBuilder) BuildOverride(telemetry map[string]any) string

BuildOverride generates a self-executing JS snippet that overrides navigator and screen properties with the values collected from the real target site.

type Pool

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

Pool manages a fixed set of reusable Chromium browser contexts backed by a shared ExecAllocator. Acquire returns a context for a new tab; Release returns it for reuse.

func NewPool

func NewPool(cfg config.PuppetConfig, logger *slog.Logger) (*Pool, error)

NewPool creates a Chromium instance pool. It pre-spawns cfg.MinInstances browser contexts and allows up to cfg.MaxInstances.

func (*Pool) Acquire

func (p *Pool) Acquire(ctx context.Context) (context.Context, context.CancelFunc, error)

Acquire returns a browser context from the pool, spawning a new one if the pool is empty and capacity allows.

func (*Pool) Release

func (p *Pool) Release(browserCtx context.Context, cancel context.CancelFunc)

Release returns a browser context to the pool. If the pool is shut down or full, the context is cancelled and discarded.

func (*Pool) Shutdown

func (p *Pool) Shutdown(_ context.Context) error

Shutdown cancels the allocator context, killing all Chromium processes.

Jump to

Keyboard shortcuts

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