Documentation
¶
Index ¶
- func Start[Configuration, State any](restConnector connector.Connector[Configuration, State], ...) error
- type CLI
- type NDCRestSchemaWithName
- type Option
- type RESTConnector
- func (c *RESTConnector) ApplyNDCRestSchemas(schemas []NDCRestSchemaWithName) map[string][]string
- func (c *RESTConnector) GetCapabilities(configuration *configuration.Configuration) schema.CapabilitiesResponseMarshaler
- func (c *RESTConnector) GetSchema(ctx context.Context, configuration *configuration.Configuration, _ *State) (schema.SchemaResponseMarshaler, error)
- func (c *RESTConnector) HealthCheck(ctx context.Context, configuration *configuration.Configuration, state *State) error
- func (c *RESTConnector) Mutation(ctx context.Context, configuration *configuration.Configuration, state *State, ...) (*schema.MutationResponse, error)
- func (c *RESTConnector) MutationExplain(ctx context.Context, configuration *configuration.Configuration, state *State, ...) (*schema.ExplainResponse, error)
- func (c *RESTConnector) ParseConfiguration(ctx context.Context, configurationDir string) (*configuration.Configuration, error)
- func (c *RESTConnector) Query(ctx context.Context, configuration *configuration.Configuration, state *State, ...) (schema.QueryResponse, error)
- func (c *RESTConnector) QueryExplain(ctx context.Context, configuration *configuration.Configuration, state *State, ...) (*schema.ExplainResponse, error)
- func (c *RESTConnector) TryInitState(ctx context.Context, configuration *configuration.Configuration, ...) (*State, error)
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CLI ¶
type CLI struct { connector.ServeCLI Convert command.ConvertCommandArguments `cmd:"" help:"Convert API spec to NDC schema. For example:\n ndc-rest-schema convert -f petstore.yaml -o petstore.json"` }
CLI extends the NDC SDK with custom commands
type NDCRestSchemaWithName ¶
type NDCRestSchemaWithName struct {
// contains filtered or unexported fields
}
NDCRestSchemaWithName wraps NDCRestSchema with identity name
func BuildSchemaFiles ¶
func BuildSchemaFiles(configDir string, files []configuration.ConfigItem, logger *slog.Logger) ([]NDCRestSchemaWithName, map[string][]string)
BuildSchemaFiles build NDC REST schema from file list
type Option ¶
type Option (func(*options))
Option is an interface to set custom REST connector options
func WithClient ¶
WithClient sets the custom HTTP client that satisfy the Doer interface
type RESTConnector ¶
type RESTConnector struct {
// contains filtered or unexported fields
}
RESTConnector implements the SDK interface of NDC specification
func NewRESTConnector ¶
func NewRESTConnector(opts ...Option) *RESTConnector
NewRESTConnector creates a REST connector instance
func (*RESTConnector) ApplyNDCRestSchemas ¶
func (c *RESTConnector) ApplyNDCRestSchemas(schemas []NDCRestSchemaWithName) map[string][]string
ApplyNDCRestSchemas applies slice of raw NDC REST schemas to the connector
func (*RESTConnector) GetCapabilities ¶
func (c *RESTConnector) GetCapabilities(configuration *configuration.Configuration) schema.CapabilitiesResponseMarshaler
GetCapabilities get the connector's capabilities.
func (*RESTConnector) GetSchema ¶
func (c *RESTConnector) GetSchema(ctx context.Context, configuration *configuration.Configuration, _ *State) (schema.SchemaResponseMarshaler, error)
GetSchema gets the connector's schema.
func (*RESTConnector) HealthCheck ¶
func (c *RESTConnector) HealthCheck(ctx context.Context, configuration *configuration.Configuration, state *State) error
HealthCheck checks the health of the connector.
For example, this function should check that the connector is able to reach its data source over the network.
Should throw if the check fails, else resolve.
func (*RESTConnector) Mutation ¶
func (c *RESTConnector) Mutation(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.MutationRequest) (*schema.MutationResponse, error)
Mutation executes a mutation.
func (*RESTConnector) MutationExplain ¶
func (c *RESTConnector) MutationExplain(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.MutationRequest) (*schema.ExplainResponse, error)
MutationExplain explains a mutation by creating an execution plan.
func (*RESTConnector) ParseConfiguration ¶
func (c *RESTConnector) ParseConfiguration(ctx context.Context, configurationDir string) (*configuration.Configuration, error)
ParseConfiguration validates the configuration files provided by the user, returning a validated 'Configuration', or throwing an error to prevents Connector startup.
func (*RESTConnector) Query ¶
func (c *RESTConnector) Query(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.QueryRequest) (schema.QueryResponse, error)
Query executes a query.
func (*RESTConnector) QueryExplain ¶
func (c *RESTConnector) QueryExplain(ctx context.Context, configuration *configuration.Configuration, state *State, request *schema.QueryRequest) (*schema.ExplainResponse, error)
QueryExplain explains a query by creating an execution plan.
func (*RESTConnector) TryInitState ¶
func (c *RESTConnector) TryInitState(ctx context.Context, configuration *configuration.Configuration, metrics *connector.TelemetryState) (*State, error)
TryInitState initializes the connector's in-memory state.
For example, any connection pools, prepared queries, or other managed resources would be allocated here.
In addition, this function should register any connector-specific metrics with the metrics registry.
type State ¶
type State struct {
Schema *rest.NDCRestSchema
}
State is the global state which is shared for every connector request.