internal

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 36 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, forwardHeaderConfig configuration.ForwardHeadersSettings) (*schema.SchemaResponse, rest.OperationInfo)

ApplyDefaultConnectorSchema adds default connector schema to the existing schema.

func IsSensitiveHeader added in v0.7.0

func IsSensitiveHeader(name string) bool

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

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 NewHTTPClient

func NewHTTPClient(upstreams *UpstreamManager, requests *RequestBuilderResults, forwardHeaders configuration.ForwardHeadersSettings) *HTTPClient

NewHTTPClient creates a http client wrapper

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
}

RequestBuilder builds requests to the remote service

func NewRequestBuilder

func NewRequestBuilder(restSchema *rest.NDCHttpSchema, operation *rest.OperationInfo, arguments map[string]any, runtime rest.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
	ContentLength int64
	Headers       http.Header
	Body          io.ReadSeeker
	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 {
	// 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

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) ExecuteRequest added in v0.5.0

func (um *UpstreamManager) ExecuteRequest(ctx context.Context, 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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