Documentation
¶
Index ¶
- func UnwrapNullableType(input schema.Type) (schema.TypeEncoder, bool, error)
- type DistributedError
- type DistributedResponse
- type DistributedResult
- type HTTPClient
- type HTTPOptions
- type Key
- type Keys
- type MetadataCollection
- type ParameterItem
- func (ssp *ParameterItem) Add(key Key, value string)
- func (ssp *ParameterItem) AddKey(key Key)
- func (ssp *ParameterItem) AddKeys(keys []Key)
- func (ssp *ParameterItem) AddValue(value string)
- func (ssp *ParameterItem) AddValues(values []string)
- func (ssp ParameterItem) Keys() Keys
- func (ssp *ParameterItem) PrependKey(key Key)
- func (ssp *ParameterItem) PrependKeys(keys []Key)
- func (ssp *ParameterItem) PrependValue(value string)
- func (ssp *ParameterItem) PrependValues(values []string)
- func (ssp ParameterItem) String() string
- func (ssp ParameterItem) Values() []string
- type ParameterItems
- type RequestBuilder
- type RetryableRequest
- type Server
- type UpstreamManager
- func (sm *UpstreamManager) BuildDistributedRequestsWithOptions(request *RetryableRequest, httpOptions *HTTPOptions) ([]RetryableRequest, error)
- func (sm *UpstreamManager) ExecuteRequest(ctx context.Context, request *RetryableRequest, namespace string) (*http.Response, context.CancelFunc, error)
- func (sm *UpstreamManager) InjectMockRequestSettings(req *http.Request, namespace string, securities rest.AuthSecurities)
- func (sm *UpstreamManager) Register(ctx context.Context, namespace string, rawSettings *rest.NDCHttpSettings) error
- type UpstreamSetting
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnwrapNullableType ¶
UnwrapNullableType unwraps the underlying type of the nullable type
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, metadata *configuration.NDCHttpRuntimeSchema, forwardHeaders configuration.ForwardHeadersSettings, tracer *connector.Tracer) *HTTPClient
NewHTTPClient creates a http client wrapper
func (*HTTPClient) Send ¶
func (client *HTTPClient) Send(ctx context.Context, request *RetryableRequest, selection schema.NestedField, resultType schema.Type, httpOptions *HTTPOptions) (any, http.Header, error)
Send creates and executes the request and evaluate response selection
func (*HTTPClient) SetTracer ¶
func (client *HTTPClient) SetTracer(tracer *connector.Tracer)
SetTracer sets the tracer instance
type HTTPOptions ¶
type HTTPOptions struct {
Servers []string `json:"serverIds" yaml:"serverIds"`
Parallel bool `json:"parallel" yaml:"parallel"`
Explain bool `json:"-" yaml:"-"`
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 Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key represents a key string or index
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 ParameterItem ¶
type ParameterItem struct {
// contains filtered or unexported fields
}
ParameterItem represents the key-value slice pair
func NewParameterItem ¶
func NewParameterItem(keys Keys, values []string) ParameterItem
NewParameterItem creates a parameter value pair
func (*ParameterItem) Add ¶
func (ssp *ParameterItem) Add(key Key, value string)
func (*ParameterItem) AddKey ¶
func (ssp *ParameterItem) AddKey(key Key)
func (*ParameterItem) AddKeys ¶
func (ssp *ParameterItem) AddKeys(keys []Key)
func (*ParameterItem) AddValue ¶
func (ssp *ParameterItem) AddValue(value string)
func (*ParameterItem) AddValues ¶
func (ssp *ParameterItem) AddValues(values []string)
func (ParameterItem) Keys ¶
func (ssp ParameterItem) Keys() Keys
Keys returns keys of the parameter item
func (*ParameterItem) PrependKey ¶
func (ssp *ParameterItem) PrependKey(key Key)
func (*ParameterItem) PrependKeys ¶
func (ssp *ParameterItem) PrependKeys(keys []Key)
func (*ParameterItem) PrependValue ¶
func (ssp *ParameterItem) PrependValue(value string)
func (*ParameterItem) PrependValues ¶
func (ssp *ParameterItem) PrependValues(values []string)
func (ParameterItem) String ¶
func (ssp ParameterItem) String() string
String implements fmt.Stringer interface
func (ParameterItem) Values ¶
func (ssp ParameterItem) Values() []string
type ParameterItems ¶
type ParameterItems []ParameterItem
func (*ParameterItems) Add ¶
func (ssp *ParameterItems) Add(keys []Key, values []string)
func (ParameterItems) Find ¶
func (ssp ParameterItems) Find(keys []Key) *ParameterItem
func (ParameterItems) FindDefault ¶
func (ssp ParameterItems) FindDefault() *ParameterItem
func (ParameterItems) FindIndex ¶
func (ssp ParameterItems) FindIndex(keys []Key) int
func (ParameterItems) String ¶
func (ssp ParameterItems) String() string
String implements fmt.Stringer interface
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 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
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
}
func NewUpstreamManager ¶ added in v0.5.0
func NewUpstreamManager(httpClient *http.Client, config *configuration.Configuration) *UpstreamManager
func (*UpstreamManager) BuildDistributedRequestsWithOptions ¶ added in v0.5.0
func (sm *UpstreamManager) BuildDistributedRequestsWithOptions(request *RetryableRequest, httpOptions *HTTPOptions) ([]RetryableRequest, error)
BuildDistributedRequestsWithOptions builds distributed requests with options
func (*UpstreamManager) ExecuteRequest ¶ added in v0.5.0
func (sm *UpstreamManager) ExecuteRequest(ctx context.Context, request *RetryableRequest, namespace string) (*http.Response, context.CancelFunc, error)
func (*UpstreamManager) InjectMockRequestSettings ¶ added in v0.5.0
func (sm *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 (sm *UpstreamManager) Register(ctx context.Context, namespace string, rawSettings *rest.NDCHttpSettings) error
type UpstreamSetting ¶ added in v0.5.0
type UpstreamSetting struct {
// contains filtered or unexported fields
}