dispatch

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package dispatch runs a behavior's method for the endpoint layer: it sends the job to the host, or to each host, that the target names, and makes the answer of each host a result row. The handler that the behavior generator writes for each method in gen/group.go calls Run, and the endpoint server serves it.

Index

Constants

View Source
const RowStatusDoc = "What happened on the host: ok, the operation ran and succeeded; " +
	"failed, it ran and did not succeed; skipped, the host's OS family does not support it; " +
	"timeout, the host did not answer, so nobody knows whether it ran."

RowStatusDoc is the description of types.RowStatus in the spec.

Variables

View Source
var ErrInvalid = behavior.ErrInvalid

ErrInvalid is an input that the route's validate tags cannot see as wrong: a template that reads a var that its behavior does not have, or an input that the host refuses, such as a path that is a directory. The group of each method maps it to 400.

Functions

func Run

func Run[Out any](
	ctx context.Context,
	d Deps,
	b *behavior.Behavior,
	method string,
	target string,
	input any,
) (Out, error)

Run sends input to method of b on the host, or the hosts, that target names, and returns the answer as Out, the method's response type. On one host, a provider's behavior.ErrNotFound is a 404, its ErrNotManaged and ErrNotInstalled are a 409, and its ErrInvalid is a 400, as the group maps them; on a broadcast each host's row says it. A job that cannot be sent is a 500 that does not tell its cause.

Types

type Deps

type Deps struct {
	JobClient JobClient
}

Deps is what every behavior's endpoint group uses: the job client. The controller gives it to the endpoint server.

type JobClient

type JobClient interface {
	Query(
		ctx context.Context,
		target string,
		category string,
		operation job.OperationType,
		data any,
	) (string, *job.Response, error)
	QueryBroadcast(
		ctx context.Context,
		target string,
		category string,
		operation job.OperationType,
		data any,
	) (string, map[string]*job.Response, error)
	Modify(
		ctx context.Context,
		target string,
		category string,
		operation job.OperationType,
		data any,
	) (string, *job.Response, error)
	ModifyBroadcast(
		ctx context.Context,
		target string,
		category string,
		operation job.OperationType,
		data any,
	) (string, map[string]*job.Response, error)
}

JobClient is the part of the job client a behavior's routes use: a read or a write, on one host or broadcast.

Directories

Path Synopsis
Package servertest runs the HTTP cases each behavior's generated gen/api_<method>_public_test.go lists.
Package servertest runs the HTTP cases each behavior's generated gen/api_<method>_public_test.go lists.

Jump to

Keyboard shortcuts

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