executor

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

IMPORTANT: this is all copy paste, but with some changes to fix data mutation, leading to race conditions in runtime

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractValueModifyingSource

func ExtractValueModifyingSource(
	extractor PointDataExtractor,
	source map[string]interface{},
	path []string,
) (map[string]interface{}, error)

ExtractValueModifyingSource gets object from source by path. If some fields in source are missing, it modifies source to fit the structure. for usage information check tests

func FindInsertionPoints

func FindInsertionPoints(
	targetPoints []string,
	selectionSet ast.SelectionSet,
	result map[string]interface{},
	startingPoints [][]string,
) ([][]string, error)

FindInsertionPoints returns the list of insertion points where provided step should be executed. for usage information check tests

func FindSelection

func FindSelection(matchString string, selectionSet ast.SelectionSet) *ast.Field

Types

type CachedPointDataExtractor

type CachedPointDataExtractor struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*CachedPointDataExtractor) Extract

func (e *CachedPointDataExtractor) Extract(point string) (*PointData, error)

type DepthExecutor

type DepthExecutor struct {
	QueryPlanSteps     []*planner.QueryPlanStep
	PointDataExtractor PointDataExtractor
	Depth              int
	// contains filtered or unexported fields
}

DepthExecutor uses provided QueryPlanSteps to execute against finite backend and provide requests for for DepthExecutor on next depth

func (*DepthExecutor) Execute

Execute takes execution requests and runs them async, gathering all errors and results

type DepthExecutorManager

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

func NewDepthExecutorManager

func NewDepthExecutorManager(ctx *ExecutionContext) *DepthExecutorManager

func (*DepthExecutorManager) Execute

func (dem *DepthExecutorManager) Execute() (map[string]interface{}, error)

Execute takes ExecutionContext and performs sequential execution for each depth in the plan.

type DepthExecutorResponse

type DepthExecutorResponse struct {
	ExecutionResults      []*ExecutionResult
	NextExecutionRequests []*ExecutionRequest
}

DepthExecutorResponse represents single response of DepthExecutor.Execute, containing all accumulated data

type ExecutionContext

type ExecutionContext struct {
	// RequestMiddlewares []graphql.NetworkMiddleware
	QueryPlan *planner.QueryPlan
	Request   *requests.Request
	Queryers  map[string]queryer.Queryer
}

type ExecutionRequest

type ExecutionRequest struct {
	QueryPlanStep  *planner.QueryPlanStep
	InsertionPoint []string
}

ExecutionRequest contains all data needed for DepthExecutor to execute request

func (ExecutionRequest) ToGqlError

func (er ExecutionRequest) ToGqlError(err error) *gqlerrors.Error

ToGqlError takes error and produces *gqlerrors.Error using er.InsertionPoint as path and err.Error as message. If err is already *gqlerrors.Error, it returns it as is.

type ExecutionResult

type ExecutionResult struct {
	InsertionPoint []string
	Result         map[string]interface{}
}

ExecutionResult contains result of DepthExecutor executing single ExecutionRequest

type Executor

type Executor interface {
	Execute(*ExecutionContext) (map[string]interface{}, error)
}

type ParallelExecutor

type ParallelExecutor func(*ExecutionContext) (map[string]interface{}, error)

ParallelExecutor executes the given query plan by starting at the root of the plan and walking down the path stitching the results together

func (ParallelExecutor) Execute

func (executor ParallelExecutor) Execute(ctx *ExecutionContext) (map[string]interface{}, error)

Execute returns the result of the query plan for more information about usage, take a look at tests.

type PointData

type PointData struct {
	Field string
	Index int
	ID    string
}

type PointDataExtractor

type PointDataExtractor interface {
	Extract(point string) (*PointData, error)
}

Jump to

Keyboard shortcuts

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