Documentation
¶
Overview ¶
Package graphgateway provides graph-gateway, a read-only GraphQL view of the graph. Its schema (schema.graphql) is the contract: a request is parsed and validated against it before anything is asked of the graph, it names one root field besides __typename, and its answer holds exactly the fields it selected, under their aliases and through fragments. A root field whose reply does not fit the schema answers null with an error naming the path; the rest of the answer stands.
The component answers POST <prefix>/graphql, mounted by the service manager at /<instance>. Each root field asks one graph.query.* verb of graph.QueryVerbs: entity, prefix, predicate and pathSearch. A classified refusal answers HTTP 200 with its class and code in the error's extensions; a request with no responder answers 500 naming the subject, one past query_timeout_ms 504, and every request before Start or once Stop begins 503. Stop returns once no admitted request runs.
Index ¶
- func CreateGraphGateway(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)
- func DeclarePorts(rawConfig json.RawMessage, _ string) (component.PortConfig, error)
- func Register(registry *component.Registry) error
- type Component
- func (c *Component) DataFlow() component.FlowMetrics
- func (c *Component) Health() component.HealthStatus
- func (c *Component) Initialize() error
- func (c *Component) InputPorts() []component.Port
- func (c *Component) OutputPorts() []component.Port
- func (c *Component) RegisterHTTPHandlers(prefix string, mux *http.ServeMux)
- func (c *Component) Start(ctx context.Context) error
- func (c *Component) Stop(ctx context.Context) error
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateGraphGateway ¶
func CreateGraphGateway(rawConfig json.RawMessage, deps component.Dependencies) (component.Discoverable, error)
CreateGraphGateway is the factory function for creating graph-gateway components. It opens no connection. Each root field's subject comes from graph.QueryVerbs; a root field with no declared verb is refused here.
func DeclarePorts ¶
func DeclarePorts(rawConfig json.RawMessage, _ string) (component.PortConfig, error)
DeclarePorts is the component.PortDeclarer for graph-gateway: the ports CreateGraphGateway will report for rawConfig, computed without dependencies.
Types ¶
type Component ¶
type Component struct {
// contains filtered or unexported fields
}
Component implements graph-gateway. It holds no NATS state and runs no goroutine of its own: each admitted HTTP request makes its one NATS request on the handler's goroutine (design D5).
func (*Component) DataFlow ¶
func (c *Component) DataFlow() component.FlowMetrics
DataFlow reports the shell's flow metrics (component.Lifecycle.DataFlow).
func (*Component) Health ¶
func (c *Component) Health() component.HealthStatus
Health reports the shell's verdict (component.Lifecycle.Health).
func (*Component) Initialize ¶
Initialize marks the component initialized (no I/O); the factory validated the configuration.
func (*Component) InputPorts ¶
InputPorts returns no ports: graph-gateway has none.
func (*Component) OutputPorts ¶
OutputPorts returns a new slice of the output ports. The ports share their Interface pointer with the component; no code writes through it.
func (*Component) RegisterHTTPHandlers ¶
RegisterHTTPHandlers mounts the GraphQL route at <prefix>/graphql. The service manager calls it with /<instance> (service/service_manager_http.go).
type Config ¶
type Config struct {
Ports *component.PortConfig `json:"ports" schema:"type:ports,description:The one required graph_queries output,category:basic"`
// QueryTimeoutMs bounds each request the gateway sends for a root field, in milliseconds; 0 means
// the default, 60000. A request past it answers HTTP 504.
QueryTimeoutMs int `` /* 177-byte string literal not displayed */
}
Config holds the graph-gateway configuration. Decoding is strict: a key it does not define is refused, naming the key.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a valid default configuration.
func (*Config) ApplyDefaults ¶
func (c *Config) ApplyDefaults()
ApplyDefaults sets default values. A configuration with no ports takes DefaultConfig's; a ports block that is present is used as written, never merged with the defaults.
func (*Config) Validate ¶
Validate implements component.Validatable. It only checks; a Config that has not had its defaults applied has no ports and is refused.
The gateway requests only the graph.query.* verbs graph.QueryVerbs declares, so its one output must match queriesPort in name, required and everything under config, as graph-query checks its input (processor/graph-query/config.go). Its description and external statement change nothing it requests, and are the operator's.