Documentation
¶
Index ¶
- Constants
- func FormatConfigErrors(errors []ConfigError) string
- func InvocationPropertySources(input invocationprops.Declarations, profile string, sources Sources) []invocationprops.Source
- func IsTRDirectURL(raw string) bool
- func ParseDirectDialAddress(raw string) (string, error)
- func SupportsDirectBolt(cfg Config) bool
- func WireSerialization(cfg Config) string
- type Config
- type ConfigError
- type FieldTrace
- type Input
- type Layer
- type ProbeResult
- type Report
- type Sources
- type TraceValue
Constants ¶
const ( SerializationHessian2 = "hessian2" SerializationJSON = "json" )
Serializations the pure-Go direct transport can put inside a BOLT frame.
const DefaultBoltPort = "12200"
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 ¶
IsTRDirectURL reports whether the address explicitly selects the TR protocol.
func ParseDirectDialAddress ¶
ParseDirectDialAddress canonicalizes a direct SOFARPC target into host:port. It accepts bolt://host[:port], host[:port], and bracketed IPv6 literals.
func SupportsDirectBolt ¶
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 ¶
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.
type ConfigError ¶
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 ¶
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 ¶
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 ¶
TraceValue is one field contribution rendered as a stable string so agents can surface it without guessing Go/JSON scalar types.