Help us shape the future of Go! Take the 2026 Go Developer Survey

eprun

package
v1.149.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package eprun runs a bound script inline on each request to its endpoint (#2172): handle(req) is called on the replica that received the request, in an in-memory MCP session presenting the roles its version's author held at the save, as a scheduled run presents them. Every platform call the handler makes is authorized, rate limited and audited as a script's. A request writes one audit row and its metrics, a failed one is kept for the script's owner to read, and no script_runs row is written.

The compiled module is kept per script version on each replica. Before a request runs, one read of when its binding and its script were last written (epbinding.Stamp) says whether what the replica holds is current, so the first request after a save, on any replica, runs the new version.

Index

Constants

View Source
const MaxConcurrent = 32

MaxConcurrent is how many requests a replica runs handlers for at once, across every endpoint. A request past it is answered 503 at once rather than held: a burst inside every endpoint's rate limit could otherwise hold as many executions as it sends, each with its own memory budget.

View Source
const MaxResponseBytes = 10 << 20

MaxResponseBytes bounds the body a handler answers with.

View Source
const SourceEndpoint = "endpoint"

SourceEndpoint is the audit source of the one row a request writes. The tool-call rows its handler's calls produce are the script source's, which is what every rule a script's calls answer to keys on.

Variables

This section is empty.

Functions

This section is empty.

Types

type Caller

type Caller struct {
	UserID   string
	Email    string
	AuthType string
}

Caller is who sent a request to a signed_in endpoint.

type Request

type Request struct {
	Method string
	Path   string
	Params map[string]string
	Query  map[string][]string
	Header http.Header
	Body   []byte
	// Caller is nil on a public endpoint.
	Caller *Caller
}

Request is one request to an endpoint, as the HTTP surface read it.

type Response

type Response struct {
	Status int
	Header http.Header
	Body   []byte
}

Response is what the endpoint answers.

type Runner

type Runner struct {
	Bindings epbinding.Store
	Scripts  Scripts
	// Server is the assembled MCP server a request's session opens against.
	Server  *mcp.Server
	Audit   middleware.AuditLogger
	Metrics *observability.Metrics
	// Subjects resolves the subject the version's author authenticates as,
	// for where a request's managed resources land; nil leaves it empty.
	Subjects interface {
		ForRun(ctx context.Context, address string) string
	}
	// Limits are a platform run's ceilings; a binding's timeout and memory
	// budget replace those two.
	Limits       scriptrun.PlatformLimits
	Destinations []script.Destination
	// Libraries is where the libraries a version loads are read from, given
	// the version; nil refuses every load.
	Libraries func(ctx context.Context, v *script.Version) (scriptlib.Source, error)
	// Tokens answers platform.mint_token and platform.verify_token, bound to
	// the endpoint a request reached (#2175); nil refuses them.
	Tokens *scripttoken.Issuer
	// contains filtered or unexported fields
}

Runner runs bound scripts.

func (*Runner) Resolve

func (r *Runner) Resolve(ctx context.Context, name string) (*Target, error)

Resolve is the endpoint a name serves, current as of this call. epbinding.ErrNotFound when no binding has the name.

func (*Runner) Serve

func (r *Runner) Serve(ctx context.Context, t *Target, req Request) Response

Serve runs t's handler for req and returns its response. It never fails: a request the script could not answer is answered with the status that says why, and recorded.

type Scripts

type Scripts interface {
	GetByID(ctx context.Context, id string) (*script.Script, error)
	GetVersion(ctx context.Context, scriptID string, version int) (*script.Version, error)
}

Scripts reads the script a binding binds and its saved versions.

type Target

type Target struct {
	Binding *epbinding.Binding
	Script  *script.Script
	Version *script.Version
	// contains filtered or unexported fields
}

Target is one endpoint as a replica holds it: the binding, the script and version it runs, and the module compiled for that version.

Jump to

Keyboard shortcuts

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