target

package
v0.0.0-...-c671013 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 8 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

Index

Constants

View Source
const (
	SerializationHessian2 = "hessian2"
	SerializationJSON     = "json"
)

Serializations the pure-Go direct transport can put inside a BOLT frame.

View Source
const DefaultBoltPort = "12200"
View Source
const (
	ModeDirect = "direct"
)

Variables

This section is empty.

Functions

func FormatConfigErrors

func FormatConfigErrors(errors []ConfigError) string

FormatConfigErrors renders project config errors as one human-readable line. It is the single formatter shared by the policy layer and the MCP tools so both report a config problem identically.

func InvocationPropertySources

func InvocationPropertySources(input invocationprops.Declarations, profile string, sources Sources) []invocationprops.Source

InvocationPropertySources returns the invocation-property declaration sources in descending precedence, inserting the active Target Profile's declarations above the base declarations so a profile value beats a base value:

input
  > project-local:profiles[P] > project:profiles[P]
  > project-local (base) > project (base)

profile is the already-resolved per-call/session selection; an empty profile falls back to sources.DefaultProfile. input carries the caller's per-call declarations and always ranks highest. This is the single definition of the invocation-property layer order, shared by plan building and doctor.

func IsTRDirectURL

func IsTRDirectURL(raw string) bool

IsTRDirectURL reports whether the address explicitly selects the TR protocol.

func ParseDirectDialAddress

func ParseDirectDialAddress(raw string) (string, error)

ParseDirectDialAddress canonicalizes a direct SOFARPC target into host:port. It accepts bolt://host[:port], host[:port], and bracketed IPv6 literals.

func SupportsDirectBolt

func SupportsDirectBolt(cfg Config) bool

SupportsDirectBolt reports whether cfg picks out an invoke shape the pure-Go runtime can execute today: a direct bolt target carrying one of the supported serializations. Empty Protocol / Serialization are treated as "accept defaults"; callers that want to surface a precise reason to the user should inspect the direct URL scheme, protocol, and serialization.

func WireSerialization

func WireSerialization(cfg Config) string

WireSerialization returns the serialization cfg executes with: the configured value, or the built-in default when none is set.

Types

type Config

type Config struct {
	Mode             string `json:"mode,omitempty"`
	DirectURL        string `json:"directUrl,omitempty"`
	Protocol         string `json:"protocol,omitempty"`
	Serialization    string `json:"serialization,omitempty"`
	UniqueID         string `json:"uniqueId,omitempty"`
	TimeoutMS        int    `json:"timeoutMs,omitempty"`
	ConnectTimeoutMS int    `json:"connectTimeoutMs,omitempty"`
}

Config is the resolved wire target handed to invoke/replay/worker.

func Normalize

func Normalize(cfg Config) Config

Normalize trims whitespace on target fields and infers Mode from DirectURL. It is the canonical pre-step for code paths that receive a Config from outside the Resolve pipeline (Probe, direct-transport support checks).

type ConfigError

type ConfigError struct {
	Path  string `json:"path"`
	Error string `json:"error"`
}

ConfigError records a project config file that existed but could not be parsed. Missing config files are not errors.

type FieldTrace

type FieldTrace struct {
	Field    string       `json:"field"`
	Winner   TraceValue   `json:"winner"`
	Shadowed []TraceValue `json:"shadowed,omitempty"`
}

FieldTrace records which layer won for a field and which lower priority layers were shadowed.

type Input

type Input struct {
	Service          string
	DirectURL        string
	Protocol         string
	Serialization    string
	UniqueID         string
	TimeoutMS        int
	ConnectTimeoutMS int
	Explain          bool
	// Profile names the Target Profile to select. Empty means fall back to
	// the project's DefaultProfile, then to base-only resolution.
	Profile string
}

Input is the per-call target override surface exposed to MCP tools. Empty fields fall through to the ambient Sources and then defaults.

type Layer

type Layer struct {
	Name          string   `json:"name"`
	AppliedFields []string `json:"appliedFields,omitempty"`
}

Layer records which output fields a resolution layer contributed.

type ProbeResult

type ProbeResult struct {
	Reachable bool   `json:"reachable"`
	Target    string `json:"target,omitempty"`
	Message   string `json:"message,omitempty"`
}

ProbeResult reports whether the resolved target answered a TCP dial.

func Probe

func Probe(cfg Config) ProbeResult

Probe dials the target's host:port with the configured connect timeout. It does NOT speak SOFARPC — it only verifies that something is listening. A reachable=false with a specific message is how we surface problems to the agent (address parse errors, DNS, connect refused).

A default is applied when ConnectTimeoutMS is 0 so the probe never hangs on zero-valued configs.

type Report

type Report struct {
	Target       Config        `json:"target"`
	Service      string        `json:"service,omitempty"`
	Layers       []Layer       `json:"layers,omitempty"`
	ConfigErrors []ConfigError `json:"configErrors,omitempty"`
	Explain      []string      `json:"explain,omitempty"`
	Trace        []FieldTrace  `json:"trace,omitempty"`
	// ActiveProfile is the selected Target Profile (per-call input, else
	// DefaultProfile). AvailableProfiles lists every profile defined across
	// both config files. ProfileError is set, and no target is resolved,
	// when ActiveProfile names a profile defined in neither file.
	ActiveProfile     string   `json:"activeProfile,omitempty"`
	AvailableProfiles []string `json:"availableProfiles,omitempty"`
	ProfileError      string   `json:"profileError,omitempty"`
}

Report is the full diagnostic payload produced by Resolve.

func Resolve

func Resolve(input Input, sources Sources) Report

Resolve merges the target layers in descending priority. When a Target Profile is active, its layers sit above the base layers so a profile-specific value beats a base value:

input
  > project-local:profiles[P] > project:profiles[P]
  > project-local (base) > project (base)
  > mcp-env > built-in defaults

A profile that is named but defined in neither config file is a hard error: Resolve returns a Report with ProfileError set and no resolved target rather than silently falling through to the base layers.

type Sources

type Sources struct {
	Env                              Config
	Project                          Config
	ProjectLocal                     Config
	ProjectInvocationProperties      invocationprops.Declarations
	ProjectLocalInvocationProperties invocationprops.Declarations
	ProjectRoot                      string
	ConfigErrors                     []ConfigError
	// ProjectProfiles / ProjectLocalProfiles hold the named Target Profile
	// target configs from the shared and local config files. DefaultProfile
	// is the resolved fallback profile (local declaration wins over shared).
	ProjectProfiles      map[string]Config
	ProjectLocalProfiles map[string]Config
	DefaultProfile       string
	// ProjectProfileInvocationProperties / ProjectLocalProfileInvocationProperties
	// hold each Target Profile's invocation-property declarations, keyed by
	// profile name, from the shared and local config files.
	ProjectProfileInvocationProperties      map[string]invocationprops.Declarations
	ProjectLocalProfileInvocationProperties map[string]invocationprops.Declarations
}

Sources is the ambient, already-materialised config surface available to resolution. ProjectLocal and Project are loaded from .sofarpc/config.local.json and .sofarpc/config.json respectively.

func ProjectSources

func ProjectSources(projectRoot string, env Config) Sources

ProjectSources builds a Sources value for projectRoot by reading the optional project-level target config files. Config load errors are carried in the returned Sources so callers can surface them in target/open/doctor output without making missing files fatal.

type TraceValue

type TraceValue struct {
	Layer string `json:"layer"`
	Value string `json:"value,omitempty"`
}

TraceValue is one field contribution rendered as a stable string so agents can surface it without guessing Go/JSON scalar types.

Jump to

Keyboard shortcuts

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