Documentation
¶
Index ¶
- Constants
- func ApplyDefaultConnectorSchema(input *schema.SchemaResponse, ...) (*schema.SchemaResponse, rest.OperationInfo)
- func ApplyPromptQLSettingsToSchema(ndcSchema *schema.SchemaResponse, config configuration.RuntimeSettings) *schema.SchemaResponse
- func IsSensitiveHeader(name string) bool
- type DistributedError
- type DistributedResponse
- type DistributedResult
- type HTTPClient
- type HTTPOptions
- type MetadataCollection
- type RawRequestBuilder
- type RequestBuilder
- type RequestBuilderResults
- type RetryableRequest
- type Server
- type UpstreamManager
- func (um *UpstreamManager) BuildRequests(runtimeSchema *configuration.NDCHttpRuntimeSchema, operationName string, ...) (*RequestBuilderResults, error)
- func (um *UpstreamManager) CreateHTTPClient(requests *RequestBuilderResults) *HTTPClient
- func (um *UpstreamManager) ExecuteRequest(ctx context.Context, span trace.Span, request *RetryableRequest, ...) (*http.Response, context.CancelFunc, error)
- func (um *UpstreamManager) InjectMockRequestSettings(req *http.Request, namespace string, securities rest.AuthSecurities)
- func (um *UpstreamManager) Register(ctx context.Context, runtimeSchema *configuration.NDCHttpRuntimeSchema, ...) error
- type UpstreamSetting
Constants ¶
const ( ProcedureSendHTTPRequest string = "sendHttpRequest" ScalarRawHTTPMethod rest.ScalarName = "RawHttpMethod" )
Variables ¶
This section is empty.
Functions ¶
func ApplyDefaultConnectorSchema ¶ added in v0.7.0
func ApplyDefaultConnectorSchema(input *schema.SchemaResponse, forwardHeaderConfig configuration.ForwardHeadersSettings) (*schema.SchemaResponse, rest.OperationInfo)
ApplyDefaultConnectorSchema adds default connector schema to the existing schema.
func ApplyPromptQLSettingsToSchema ¶ added in v0.9.0
func ApplyPromptQLSettingsToSchema(ndcSchema *schema.SchemaResponse, config configuration.RuntimeSettings) *schema.SchemaResponse
ApplyPromptQLSettingsToSchema applies settings to the connector schema to be compatible with PromptQL.
func IsSensitiveHeader ¶ added in v0.7.0
IsSensitiveHeader checks if the header name is sensitive.
Types ¶
type DistributedError ¶
type DistributedError struct {
schema.ConnectorError
// Identity of the remote server
Server string `json:"server" yaml:"server"`
}
DistributedError represents the error response of the remote request.
func (DistributedError) Error ¶
func (de DistributedError) Error() string
Error implements the Error interface.
type DistributedResponse ¶
type DistributedResponse[T any] struct { Results []DistributedResult[T] `json:"results" yaml:"results"` Errors []DistributedError `json:"errors" yaml:"errors"` }
DistributedResponse represents the response object of distributed operations.
func NewDistributedResponse ¶
func NewDistributedResponse[T any]() *DistributedResponse[T]
NewDistributedResponse creates an empty DistributedResponse instance.
func (DistributedResponse[T]) ToMap ¶ added in v0.8.1
func (dr DistributedResponse[T]) ToMap() map[string]any
ToMap serializes the distributed response to a map.
type DistributedResult ¶
type DistributedResult[T any] struct { Server string `json:"server" yaml:"server"` Data T `json:"data" yaml:"data"` }
DistributedResult contains the success response of remote requests with a server identity.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient represents a http client wrapper with advanced methods.
type HTTPOptions ¶
type HTTPOptions struct {
Servers []string `json:"serverIds" yaml:"serverIds"`
Parallel bool `json:"parallel" yaml:"parallel"`
Distributed bool `json:"-" yaml:"-"`
Concurrency uint `json:"-" yaml:"-"`
}
HTTPOptions represent execution options for HTTP requests.
func (*HTTPOptions) FromValue ¶
func (ro *HTTPOptions) FromValue(value any) error
FromValue parses http execution options from any value.
type MetadataCollection ¶
type MetadataCollection []configuration.NDCHttpRuntimeSchema
MetadataCollection stores list of HTTP metadata with helper methods.
func (MetadataCollection) GetFunction ¶
func (rms MetadataCollection) GetFunction(name string) (*rest.OperationInfo, *configuration.NDCHttpRuntimeSchema, error)
GetFunction gets the NDC function by name.
func (MetadataCollection) GetProcedure ¶
func (rms MetadataCollection) GetProcedure(name string) (*rest.OperationInfo, *configuration.NDCHttpRuntimeSchema, error)
GetProcedure gets the NDC procedure by name.
type RawRequestBuilder ¶ added in v0.7.0
type RawRequestBuilder struct {
// contains filtered or unexported fields
}
RawRequestBuilder represents a type to build a raw HTTP request.
func NewRawRequestBuilder ¶ added in v0.7.0
func NewRawRequestBuilder(operation schema.MutationOperation, forwardHeaders configuration.ForwardHeadersSettings) *RawRequestBuilder
NewRawRequestBuilder create a new RawRequestBuilder instance.
func (*RawRequestBuilder) Build ¶ added in v0.7.0
func (rqe *RawRequestBuilder) Build() (*RequestBuilderResults, error)
Build evaluates and builds the raw request.
func (*RawRequestBuilder) Explain ¶ added in v0.7.0
func (rqe *RawRequestBuilder) Explain() (*schema.ExplainResponse, error)
type RequestBuilder ¶
type RequestBuilder struct {
Schema *rest.NDCHttpSchema
Operation *rest.OperationInfo
Arguments map[string]any
Runtime rest.RuntimeSettings
GlobalRuntime configuration.RuntimeSettings
}
RequestBuilder builds requests to the remote service.
func NewRequestBuilder ¶
func NewRequestBuilder(restSchema *rest.NDCHttpSchema, operation *rest.OperationInfo, arguments map[string]any, runtime rest.RuntimeSettings, globalRuntime configuration.RuntimeSettings) *RequestBuilder
NewRequestBuilder creates a new RequestBuilder instance.
func (*RequestBuilder) Build ¶
func (c *RequestBuilder) Build() (*RetryableRequest, error)
Build evaluates and builds a RetryableRequest.
type RequestBuilderResults ¶ added in v0.6.0
type RequestBuilderResults struct {
Requests []*RetryableRequest
Operation *rest.OperationInfo
Schema *configuration.NDCHttpRuntimeSchema
*HTTPOptions
}
RequestBuilderResults hold the result of built requests.
type RetryableRequest ¶
type RetryableRequest struct {
RawRequest *rest.Request
URL url.URL
Namespace string
ServerID string
ContentType string
Headers http.Header
Body []byte
Runtime rest.RuntimeSettings
}
RetryableRequest wraps the raw request with retryable.
func (*RetryableRequest) CreateRequest ¶
func (r *RetryableRequest) CreateRequest(ctx context.Context) (*http.Request, context.CancelFunc, error)
CreateRequest creates an HTTP request with body copied.
type Server ¶ added in v0.5.0
type Server struct {
URL *url.URL
Headers map[string]string
Credentials map[string]security.Credential
ArgumentPresets *argument.ArgumentPresets
Security rest.AuthSecurities
HTTPClient *http.Client
}
Server contains server settings.
type UpstreamManager ¶ added in v0.5.0
type UpstreamManager struct {
RuntimeSettings configuration.RuntimeSettings
// contains filtered or unexported fields
}
UpstreamManager represents a manager for an upstream.
func NewUpstreamManager ¶ added in v0.5.0
func NewUpstreamManager(httpClient *http.Client, config *configuration.Configuration) (*UpstreamManager, error)
NewUpstreamManager creates a new UpstreamManager instance.
func (*UpstreamManager) BuildRequests ¶ added in v0.6.0
func (um *UpstreamManager) BuildRequests(runtimeSchema *configuration.NDCHttpRuntimeSchema, operationName string, operation *rest.OperationInfo, rawArgs map[string]any) (*RequestBuilderResults, error)
func (*UpstreamManager) CreateHTTPClient ¶ added in v0.8.0
func (um *UpstreamManager) CreateHTTPClient(requests *RequestBuilderResults) *HTTPClient
CreateHTTPClient create an HTTP client with requests.
func (*UpstreamManager) ExecuteRequest ¶ added in v0.5.0
func (um *UpstreamManager) ExecuteRequest(ctx context.Context, span trace.Span, request *RetryableRequest, namespace string) (*http.Response, context.CancelFunc, error)
ExecuteRequest executes a request to the upstream server.
func (*UpstreamManager) InjectMockRequestSettings ¶ added in v0.5.0
func (um *UpstreamManager) InjectMockRequestSettings(req *http.Request, namespace string, securities rest.AuthSecurities)
InjectMockCredential injects mock credential into the request for explain APIs.
func (*UpstreamManager) Register ¶ added in v0.5.0
func (um *UpstreamManager) Register(ctx context.Context, runtimeSchema *configuration.NDCHttpRuntimeSchema, ndcSchema *schema.NDCHttpSchema) error
Register evaluates and registers an upstream from config.
type UpstreamSetting ¶ added in v0.5.0
type UpstreamSetting struct {
// contains filtered or unexported fields
}
UpstreamSetting represents a setting for upstream servers.