planner

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternalPlanner = errors.New("internal planner error")
)

Functions

func ContextWithRawResultsFlag added in v0.1.5

func ContextWithRawResultsFlag(ctx context.Context) context.Context

func IsRawResultsQuery added in v0.1.5

func IsRawResultsQuery(ctx context.Context, field *ast.Field) bool

Types

type Catalog

type Catalog interface {
	Engine(name string) (engines.Engine, error)
}

type NodeBeforeExecFunc

type NodeBeforeExecFunc func(ctx context.Context, db *db.Pool, node *QueryPlanNode) error

type NodeFunc

type NodeFunc func(node *QueryPlanNode, children Results, params []any) (string, []any, error)

type QueryPlan

type QueryPlan struct {
	Query    *ast.Field
	RootNode *QueryPlanNode

	CompiledQuery string
	Params        []any
}

func (*QueryPlan) Compile

func (p *QueryPlan) Compile() error

func (*QueryPlan) Execute

func (p *QueryPlan) Execute(ctx context.Context, db *db.Pool) (data interface{}, err error)

func (*QueryPlan) Log

func (p *QueryPlan) Log() string

type QueryPlanNode

type QueryPlanNode struct {
	Name        string
	Query       *ast.Field
	Nodes       QueryPlanNodes
	Comment     string
	CollectFunc NodeFunc

	BeforeParamsLen int
	AddedParams     int
	Parent          *QueryPlanNode

	Before NodeBeforeExecFunc
	// contains filtered or unexported fields
}

QueryPlan represents the execution plan for a query

func (*QueryPlanNode) Compile

func (n *QueryPlanNode) Compile(parent *QueryPlanNode, res *Result) (*Result, error)

func (*QueryPlanNode) Engine

func (n *QueryPlanNode) Engine(name string) (engines.Engine, error)

func (*QueryPlanNode) Schema

func (n *QueryPlanNode) Schema() *ast.Schema

func (*QueryPlanNode) TypeDefs

type QueryPlanNodes

type QueryPlanNodes []*QueryPlanNode

func (*QueryPlanNodes) Add

func (n *QueryPlanNodes) Add(node *QueryPlanNode)

func (*QueryPlanNodes) ForName

func (n *QueryPlanNodes) ForName(name string) *QueryPlanNode

type Result

type Result struct {
	Name     string
	Result   string
	Params   []any
	Children Results
}

type Results

type Results []*Result

func (*Results) FirstResult

func (r *Results) FirstResult() *Result

func (*Results) ForName

func (r *Results) ForName(name string) *Result

type Service

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

func New

func New(c Catalog) *Service

func (*Service) Plan

func (s *Service) Plan(ctx context.Context, schema *ast.Schema, query *ast.Field, vars map[string]interface{}) (*QueryPlan, error)

Jump to

Keyboard shortcuts

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