epcmd

package
v1.148.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 7 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 Handler

type Handler struct {
	Store epbinding.Store
	// PublicAllowed reports whether the deployment lets a public endpoint be
	// bound (internal/botcheck).
	PublicAllowed func(ctx context.Context) (bool, 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
}

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.

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"`
	OpenReads       *bool    `json:"open_reads,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"`
}

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
}

Request is one endpoint command.

Jump to

Keyboard shortcuts

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