scriptwiring

package
v1.158.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Overview

Package scriptwiring assembles the managed-script feature: the execution handle the lifecycle starts, and the tool layer that authors and enqueues onto it.

It is a seam rather than a method on the facade for the reason every other composition seam here is one, and the reason its own construction comment already gave: composition is not behavior the facade should own, and the facade is at its size budget.

Index

Constants

View Source
const ToolManageSite = sitetool.ToolName

ToolManageSite is the sites tool's name, for the platform's listing.

Variables

This section is empty.

Functions

func Wire

func Wire(deps Deps) *scriptexec.Handle

Wire assembles the managed-script feature and returns its execution handle for the lifecycle to start and stop. The handle also owns the schedule materializer, which runs wherever the run worker does.

The two halves are wired together here because only one of them can exist without the other: the tool layer registers manage_script on any database deployment, while run_script appears only where there is a queue to enqueue onto, so a deployment that cannot execute scripts still authors them and says plainly that nothing will run them.

The handle is built whether or not this replica runs the worker: the serving half of a split deployment still owns the queue it enqueues onto.

Wire builds both halves and registers the tool layer, returning the handle.

Types

type Deps

type Deps struct {
	DB     *sql.DB
	DSN    string
	Server *mcp.Server

	Assets   portal.AssetStore
	Versions portal.VersionStore
	S3       portal.S3Client
	// Sites is the sites: section, and CookieDomain the browser session
	// cookie's Domain (#2517, #2518).
	Sites        siteconfig.Config
	CookieDomain string
	// ReservedURLs are the platform's other addresses, which no domain may claim.
	ReservedURLs []string
	Bucket       string
	Prefix       string
	FollowTables func(ctx context.Context, assetID string, version int) []string
	Lander       *resourcewrite.Ref
	// Sources reads managed-resource text a script is saved from or loads
	// (#2113, #2114). Nil refuses both.
	Sources *scriptsrc.Reader
	// Authority resolves what the roles a run presents act as (#2080).
	Authority scriptexec.Authority

	Audit    middleware.AuditLogger
	Subjects scriptexec.SubjectResolver
	Metrics  *observability.Metrics

	Destinations []script.Destination
	RunRetention time.Duration
	// Worker is the scripts.worker capacity settings: admission and a
	// platform run's ceilings (#1843).
	Worker scriptadmit.Config
	// SQL is the scripts.sql section: the most a statement may run (#2073).
	SQL scriptstmt.Config
	// Draft is the scripts.draft section: how long an administrator's draft
	// may run (#2117).
	Draft                scriptbgdraft.Config
	WorkerEnabled        bool
	NotificationsEnabled bool
	DigestHourUTC        int
	PortalURL            string
	Toolkits             *registry.Registry
	// BindSiteContent hands manage_asset what answers a site reference, and
	// SitePersonas says which personas hold manage_site (#2588).
	BindSiteContent func(portalkit.SiteContent)
	SitePersonas    *persona.Registry

	// BotCheckKey signs a bot_check endpoint's proof-of-work challenges
	// (botcheck.Key), and Encryptor decrypts the stored secret a bot check
	// provider's key is kept in (#2173).
	BotCheckKey []byte
	Encryptor   secretstore.Encryptor
	// AppDBReach lists the application database connections an actor may
	// hold an application's schema on (#2539); nil adds no schema.
	AppDBReach func(ctx context.Context, actor application.Actor) ([]string, error)

	// Bind hands the assembled tool layer back to the facade, which keeps it
	// because the index queue binds its write-path producer (#1370).
	Bind func(*scriptlayer.Handle)
}

Deps are what the facade hands over: values it already holds, and one callback for the handle it keeps.

type SitesConfig added in v1.155.0

type SitesConfig = siteconfig.Config

SitesConfig is the sites: configuration section.

Jump to

Keyboard shortcuts

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