internal

package
v0.12.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 5, 2025 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
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,
	config *configuration.Configuration,
) (*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

func IsSensitiveHeader(name string) bool

IsSensitiveHeader checks if the header name is sensitive.

func WrapTelemetryTransport added in v0.11.0

func WrapTelemetryTransport(baseTransport *http.Transport, logger *slog.Logger) http.RoundTripper

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.

func (*HTTPClient) Send

func (client *HTTPClient) Send(
	ctx context.Context,
	selection schema.NestedField,
) (any, http.Header, error)

Send creates and executes the request and evaluate response selection.

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

GetFunction gets the NDC function by name.

func (MetadataCollection) GetProcedure

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

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 {
	*HTTPOptions

	OperationName string
	Requests      []*RetryableRequest
	Operation     *rest.OperationInfo
	Schema        *configuration.NDCHttpRuntimeSchema
}

RequestBuilderResults hold the result of built requests.

type ResponseTransformer added in v0.10.0

type ResponseTransformer struct {
	// contains filtered or unexported fields
}

ResponseTransformer is a processor to transform the response body from a template.

func NewResponseTransformer added in v0.10.0

func NewResponseTransformer(
	setting rest.ResponseTransformSetting,
	strict bool,
) *ResponseTransformer

NewResponseTransformer creates a ResponseTransformer instance.

func (*ResponseTransformer) Transform added in v0.10.0

func (rt *ResponseTransformer) Transform(responseBody any) (any, error)

Transform evaluates and transform the response body.

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 *rest.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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL