client

package
v3.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 14 Imported by: 1 module, 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 client resolves invocation targets through the service registry and runs invocations over the control channel. It is the shared machinery under the Admin API's Invoke and any other fleet-internal consumer of invocations (e.g. the stats prometheus collector).

Index

Constants

View Source
const PerNodeTimeout = 10 * time.Second

PerNodeTimeout bounds a single peer invocation so one slow or offline node never stalls a fleet-wide fan-out.

Variables

This section is empty.

Functions

func ControlClientAt

func ControlClientAt(address string) (controlpb.ControlClient, error)

ControlClientAt returns a Control client for a peer control endpoint address, pooling the underlying connection.

func Route

func Route(eps []Endpoint, invocation string) [][]Endpoint

Route groups the endpoints into the calls an invocation makes, one call per group. A shared invocation needs one instance per service, so the instances of a service share a group. Any other invocation gets a group per instance. A node that does not advertise the invocation as shared gets its own group, as before shared invocations existed.

Types

type Endpoint

type Endpoint struct {
	Node     string
	Addr     string
	Target   string
	Err      string
	Service  string
	Draining bool
	Shared   []string
}

Endpoint is one resolved invocation target: the node id to report, the control address to dial, and the target the control channel routes on. Err set means the target could not be resolved. Service, Draining and Shared come from the node's registry entry and route the shared invocations.

func EndpointFor

func EndpointFor(n registry.Node) Endpoint

EndpointFor builds the endpoint dialing a node's control channel, routing by its id.

func Pick

func Pick(ctx context.Context, eps []Endpoint) Endpoint

Pick selects the endpoint of a group that gets the call: the first one that can take it now, with instances in rotation before draining ones. It moves on only before the call is sent, because a sent call can have run already. If no endpoint can take the call, the first one gets it and reports the failure.

func Resolve

func Resolve(reg registry.Registry, selector string) (string, []Endpoint, error)

Resolve maps a selector to its control endpoints. An instance is one service process running on a specific node, identified by its node id "host:port/service"; the fleet is every instance of every service in the registry. A node id targets one instance, a service name every live one, a partial id ("host:port" or a bare host) every instance at that address or on that machine, and "*" every live instance in the fleet. It returns the resolved service name when the selector was one.

type NodeResult

type NodeResult struct {
	Node       string
	ResultJSON string
	Error      string
}

NodeResult is the outcome of one peer invocation.

func FanOut

func FanOut(ctx context.Context, eps []Endpoint, invocation string, args map[string]string) []NodeResult

FanOut invokes every routed group in parallel, one result per group. An unreachable node is a per-node error rather than a failure of the whole call.

func InvokeOne

func InvokeOne(ctx context.Context, ep Endpoint, invocation string, args map[string]string) NodeResult

InvokeOne runs a single peer invocation with a bounded timeout.

Jump to

Keyboard shortcuts

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