Documentation
¶
Overview ¶
Package weather is a worked, runnable example of registering a Go function as a Harbor in-process tool.
It shows the canonical pattern: declare typed input/output structs, call inproc.RegisterFunc, and let the driver derive JSON Schemas from the types via reflection. The registered function is wrapped in Harbor's ToolPolicy shell (timeout + retry + validation) so a plain registration is production-resilient by construction.
The "lookup" function returns a canned, deterministic result — a real tool would call a weather API here. The value of this example is the registration SHAPE, not the data source. See docs/recipes/ define-a-tool.md for the companion how-to.
Index ¶
Constants ¶
const ToolName = "weather.lookup"
ToolName is the catalog name the example tool registers under.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(cat tools.ToolCatalog) error
Register adds the weather.lookup tool to cat. It returns the error from inproc.RegisterFunc unchanged so callers fail loudly on a duplicate name or a schema-derivation bug (CLAUDE.md §5).
A real deployment would register tools at boot from cmd/harbor; an example or a test calls Register against a tools.NewCatalog().
Types ¶
type LookupArgs ¶
type LookupArgs struct {
// City is the city name to look up.
City string `json:"city"`
}
LookupArgs is the tool's typed input. JSON Schema is derived from the struct tags by the inproc driver at registration time.
type LookupResult ¶
type LookupResult struct {
// City echoes the requested city.
City string `json:"city"`
// TempC is the temperature in degrees Celsius.
TempC float64 `json:"temp_c"`
// Summary is a short human-readable conditions string.
Summary string `json:"summary"`
}
LookupResult is the tool's typed output.