Documentation ¶
Index ¶
- Constants
- Variables
- func ApplyEncoders(resources domain.Resources, log restql.Logger) domain.Resources
- func ApplyModifiers(resources domain.Resources, modifiers domain.Modifiers) domain.Resources
- func GetEmptyChainedParams(statement domain.Statement) []string
- func MakeRequest(defaultResourceTimeout time.Duration, forwardPrefix string, ...) restql.HTTPRequest
- func MultiplexStatements(resources domain.Resources) domain.Resources
- func NewDoneResource(request restql.HTTPRequest, response restql.HTTPResponse, ...) restql.DoneResource
- func NewEmptyChainedResponse(log restql.Logger, params []string, options DoneResourceOptions) restql.DoneResource
- func NewErrorResponse(log restql.Logger, err error, request restql.HTTPRequest, ...) restql.DoneResource
- func NewNewDependsOnUnresolvedResponse(log restql.Logger, stmt domain.Statement, options DoneResourceOptions) restql.DoneResource
- func ResolveChainedValues(resources domain.Resources, doneResources domain.Resources) domain.Resources
- func ResolveDependsOn(resources domain.Resources, doneResources domain.Resources) domain.Resources
- func UnwrapNoMultiplex(resources domain.Resources) domain.Resources
- func ValidateChainedValues(resources domain.Resources) error
- func ValidateDependsOnTarget(resources domain.Resources) error
- type DoneResourceOptions
- type Executor
- type Options
- type Runner
- type State
- func (s *State) Available() domain.Resources
- func (s *State) Done() domain.Resources
- func (s *State) HasFinished() bool
- func (s *State) Requested() domain.Resources
- func (s *State) SetAsRequest(resourceID domain.ResourceID)
- func (s *State) UpdateDone(resourceID domain.ResourceID, response interface{})
Constants ¶
const EmptyChained = "__EMPTY_CHAINED__"
EmptyChained in a token used to represent a chained parameter value that could not be resolved due to a failed response from the upstream dependency.
Variables ¶
var ( // ErrQueryTimedOut represents the event of a query that // exceed the maximum execution time for it. ErrQueryTimedOut = errors.New("query timed out") // ErrMaxQueryDenied represents the event when restQL reaches the maximum // number of concurrent queries and cannot process anymore. ErrMaxQueryDenied = errors.New("max concurrent query reached: query execution denied") // ErrMaxGoroutineDenied represents the event when restQL reaches the maximum // number of concurrent goroutines and cannot process anymore. ErrMaxGoroutineDenied = errors.New("max concurrent goroutine reached: statement execution denied") )
var ErrInvalidChainedParameter = errors.New("chained parameter targeting unknown statement")
ErrInvalidChainedParameter represents an error when a chain parameter value references an unknown statement.
var ErrInvalidDependsOnTarget = errors.New("depends-on targets an unknown resource")
ErrInvalidDependsOnTarget represents an error when a depends-on target references an unknown statement.
Functions ¶
func ApplyEncoders ¶
ApplyEncoders transform parameter values with encoder functions applied into a Resource collection with the values processed.
func ApplyModifiers ¶
ApplyModifiers transforms an unresolved Resources collection and set the query level cache directives into each statement without cache directives.
func GetEmptyChainedParams ¶
GetEmptyChainedParams returns the chain parameters that could not be resolved.
func MakeRequest ¶
func MakeRequest(defaultResourceTimeout time.Duration, forwardPrefix string, statement domain.Statement, queryCtx restql.QueryContext) restql.HTTPRequest
MakeRequest builds a HTTPRequest from a statement.
func MultiplexStatements ¶
MultiplexStatements creates a statement for each value in a list parameter value. In case of multiple list parameter values it makes the cartesian product of all the lists and makes a statement for each value in a result product.
func NewDoneResource ¶
func NewDoneResource(request restql.HTTPRequest, response restql.HTTPResponse, options DoneResourceOptions) restql.DoneResource
NewDoneResource constructs a DoneResourceOptions value.
func NewEmptyChainedResponse ¶
func NewEmptyChainedResponse(log restql.Logger, params []string, options DoneResourceOptions) restql.DoneResource
NewEmptyChainedResponse builds a DoneResource for a statement with unresolved chain parameters.
func NewErrorResponse ¶
func NewErrorResponse(log restql.Logger, err error, request restql.HTTPRequest, response restql.HTTPResponse, options DoneResourceOptions) restql.DoneResource
NewErrorResponse builds a DoneResource value for a failed HTTP call.
func NewNewDependsOnUnresolvedResponse ¶
func NewNewDependsOnUnresolvedResponse(log restql.Logger, stmt domain.Statement, options DoneResourceOptions) restql.DoneResource
func ResolveChainedValues ¶
func ResolveChainedValues(resources domain.Resources, doneResources domain.Resources) domain.Resources
ResolveChainedValues takes an unresolved Resource collection and replace chain parameter values by data present in the done Resource collection.
func ResolveDependsOn ¶
ResolveDependsOn takes an unresolved Resource collection and find if a resource dependency was successfully resolved
func UnwrapNoMultiplex ¶
UnwrapNoMultiplex transform a collection of unresolved Resources with `no-multiplex` functions into a collection of Resources without it.
func ValidateChainedValues ¶
ValidateChainedValues returns an error if a chain parameter value references an unknown statement.
func ValidateDependsOnTarget ¶
ValidateDependsOnTarget returns an error if a depends-on target references an unknown statement.
Types ¶
type DoneResourceOptions ¶
type DoneResourceOptions struct { Debugging bool IgnoreErrors bool MaxAge interface{} SMaxAge interface{} }
DoneResourceOptions represents information from the statement that should be passed to the result.
type Executor ¶
type Executor struct {
// contains filtered or unexported fields
}
Executor process statements into a result by executing the relevant HTTP calls to the upstream dependency.
func NewExecutor ¶
func NewExecutor(log restql.Logger, client domain.HTTPClient, resourceTimeout time.Duration, forwardPrefix string) Executor
NewExecutor constructs an instance of Executor.
func (Executor) DoStatement ¶
func (e Executor) DoStatement(ctx context.Context, statement domain.Statement, queryCtx restql.QueryContext) restql.DoneResource
DoStatement process a single statement into a result by executing the relevant HTTP calls to the upstream dependency.
type Options ¶
type Options struct { GlobalQueryTimeout time.Duration MaxConcurrentQueries int MaxConcurrentGoroutines int }
Options wraps all configuration parameters for the Runner
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner process a query into a Resource collection with the results in the most efficient way. All statements that can be executed in parallel, hence not having co-dependency, are done so.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State tracks the status of the statements to be resolved being resolved and done.
func (*State) Available ¶
Available return all statements to be resolved that have no dependency or which dependency was resolved.
func (*State) HasFinished ¶
HasFinished returns true if all Resources are set as done.
func (*State) SetAsRequest ¶
func (s *State) SetAsRequest(resourceID domain.ResourceID)
SetAsRequest define an to be resolved Resource into a being resolved Resource.
func (*State) UpdateDone ¶
func (s *State) UpdateDone(resourceID domain.ResourceID, response interface{})
UpdateDone set a being resolved Resource as done.