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

epcmd

package
v1.152.0 Latest Latest
Warning

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

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

Documentation

Overview

Package epcmd is manage_script's endpoint binding commands (#2171): endpoint_set, endpoint_list, endpoint_enable and endpoint_disable, beside the schedule commands. internal/platform/scriptlayer resolves the script a command names, as it does for every command, and hands it here with who is asking; the input fields and their schema are spliced into manage_script's own.

Index

Constants

View Source
const (
	CmdSet     = "endpoint_set"
	CmdList    = "endpoint_list"
	CmdEnable  = "endpoint_enable"
	CmdDisable = "endpoint_disable"
)

The commands.

Variables

Commands is every endpoint command, in the order the schema lists them.

View Source
var ErrStore = errors.New("the endpoint store failed")

ErrStore marks a command that failed because a store could not be read or written, which is the platform's failure rather than the caller's.

Functions

func Properties

func Properties() map[string]any

Properties is the schema fragment manage_script splices in for the fields of Input.

func Writes

func Writes(cmd string) bool

Writes reports whether cmd changes a binding, which a script run may not do: a run that could bind a script would be able to publish a route.

Types

type FormSources added in v1.152.0

type FormSources interface {
	Ensure(ctx context.Context, req epsource.SourceRequest) (epsource.SourceResult, error)
	Find(ctx context.Context, scriptID string) (epsource.SourceResult, bool, error)
	ConnectionChoices() []string
}

FormSources makes the webhook source a form stores its submissions in (epcollect.Maker).

type Handler

type Handler struct {
	Store epbinding.Store
	// CheckUsable reports why a binding cannot name a bot check: none has
	// the name, or it cannot be issued here (internal/botcheck).
	CheckUsable func(ctx context.Context, name string) error
	// BaseURL is the deployment's public address, empty when it has none.
	BaseURL string
	// ScriptName names a script a listing found by id; nil leaves names out.
	ScriptName func(ctx context.Context, scriptID string) string
	// contains filtered or unexported fields
}

Handler carries the commands out.

func (*Handler) Bound

func (h *Handler) Bound(ctx context.Context, scriptID string) string

Bound names the endpoint a script is bound to, "" when it is bound to none or the binding cannot be read: the save gate's question (#2171).

func (*Handler) Run

func (h *Handler) Run(ctx context.Context, req Request) (map[string]any, error)

Run carries out req and returns the result manage_script answers with. An error is the caller's to read.

func (*Handler) SetForms added in v1.152.0

func (h *Handler) SetForms(f FormSources)

SetForms is what makes a form's source from here on: the webhook sources, which are assembled after the endpoint commands.

type Input

type Input struct {
	Endpoint        string   `json:"endpoint,omitempty"`
	Methods         []string `json:"methods,omitempty"`
	Path            *string  `json:"path,omitempty"`
	AuthMode        string   `json:"auth_mode,omitempty"`
	Callers         []string `json:"callers,omitempty"`
	BotCheck        string   `json:"bot_check,omitempty"`
	CheckedMethods  []string `json:"checked_methods,omitempty"`
	MaxMemoryBytes  int64    `json:"max_memory_bytes,omitempty"`
	MaxBodyBytes    int      `json:"max_body_bytes,omitempty"`
	AllowedOrigins  []string `json:"allowed_origins,omitempty"`
	RateLimit       int      `json:"rate_limit,omitempty"`
	CallerRateLimit int      `json:"caller_rate_limit,omitempty"`
	// Connection and DecryptPersonas are a form's (#2178, #2179): the Trino
	// connection its source's table is created on, and the personas a script
	// run may decrypt its sensitive fields as (nil keeps them).
	Connection      string   `json:"connection,omitempty"`
	DecryptPersonas []string `json:"decrypt_personas,omitempty"`
}

Input is the part of manage_script's input the endpoint commands read. endpoint_set also reads manage_script's timeout_seconds.

type Request

type Request struct {
	Command string
	Input   Input
	// TimeoutSeconds is manage_script's timeout_seconds.
	TimeoutSeconds int
	// Script is the script the command names, nil for a listing that names
	// none.
	Script *script.Script
	// Visible scopes a listing that names no script to the scripts the caller
	// may see; nil for an administrator, whose listing is every binding.
	Visible map[string]*script.Script
	Admin   bool
	Actor   string
	// Limit is how many bindings a listing returns, bounded by the store.
	Limit int
}

Request is one endpoint command.

Jump to

Keyboard shortcuts

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