cypher

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package cypher provides Cypher query parsing and execution capabilities for gograph. It includes a parser for Cypher syntax and an executor that coordinates the various clause handlers to process queries.

Package cypher provides Cypher query parsing and execution capabilities for gograph.

Package cypher provides Cypher query parsing and execution capabilities for gograph.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attribute

type Attribute struct {
	Key   string
	Value any
}

Attribute represents a key-value attribute for tracing and metrics.

type Executor

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

Executor coordinates the execution of Cypher queries by delegating to specialized clause handlers for CREATE, MATCH, SET, DELETE, and REMOVE operations.

func NewExecutor

func NewExecutor(store *storage.DB, opts ...ExecutorOption) *Executor

NewExecutor creates a new Executor instance that operates on the given storage.

func (*Executor) Execute

func (e *Executor) Execute(ctx context.Context, a *ast.AST, params map[string]interface{}) (Result, error)

Execute runs a Cypher query and returns the result. It automatically manages transactions, committing write operations and rolling back read-only operations.

func (*Executor) ExecuteWithTx

func (e *Executor) ExecuteWithTx(t *tx.Transaction, a *ast.AST, params map[string]interface{}) (Result, error)

ExecuteWithTx runs a Cypher query within an existing transaction. It is intended for advanced use cases where transaction management is handled externally.

type ExecutorOption

type ExecutorOption func(*Executor)

ExecutorOption configures optional parameters for the executor.

func WithObservability

func WithObservability(o *Observability) ExecutorOption

WithObservability sets the observability handler for tracing and metrics.

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
}

Logger defines the interface for logging operations.

type Meter

type Meter interface {
	RecordHistogram(ctx context.Context, name string, value float64, attrs ...Attribute)
	RecordCounter(ctx context.Context, name string, value float64, attrs ...Attribute)
}

Meter defines the interface for recording metrics.

type Observability

type Observability struct {
	Logger Logger
	Tracer Tracer
	Meter  Meter
}

Observability contains the logging, tracing, and metering interfaces used throughout the Cypher execution pipeline.

func NewObservability

func NewObservability(opts ...ObservabilityOption) *Observability

NewObservability creates a new Observability instance with default (no-op) implementations.

type ObservabilityOption

type ObservabilityOption func(*Observability)

ObservabilityOption configures optional parameters for observability.

func WithLogger

func WithLogger(l Logger) ObservabilityOption

WithLogger sets the Logger implementation.

func WithMeter

func WithMeter(m Meter) ObservabilityOption

WithMeter sets the Meter implementation.

func WithTracer

func WithTracer(t Tracer) ObservabilityOption

WithTracer sets the Tracer implementation.

type Parser

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

Parser parses Cypher query strings into AST structures.

func NewParser

func NewParser(input string) *Parser

NewParser creates a new Parser for the given Cypher query string.

func (*Parser) Parse

func (p *Parser) Parse() (*ast.AST, error)

Parse parses the Cypher query and returns the AST representation.

type Result

type Result struct {
	// AffectedNodes is the number of nodes created, modified, or deleted.
	AffectedNodes int
	// AffectedRels is the number of relationships created or deleted.
	AffectedRels int
	// Rows contains matched data rows for MATCH queries.
	Rows []map[string]interface{}
	// Columns contains the names of columns returned in Rows.
	Columns []string
}

Result contains the count of affected graph elements after executing a data-modifying Cypher query (CREATE, SET, DELETE, REMOVE).

func (*Result) AddAffected

func (r *Result) AddAffected(nodes, rels int)

AddAffected increments the count of affected nodes and relationships.

type Span

type Span interface {
	End()
	AddEvent(name string, attrs ...Attribute)
	SetAttributes(attrs ...Attribute)
}

Span represents a tracing span for observing execution.

type SpanOption

type SpanOption func(*spanConfig)

SpanOption configures span creation.

type Tracer

type Tracer interface {
	StartSpan(ctx context.Context, name string, opts ...SpanOption) (context.Context, Span)
	RecordError(ctx context.Context, err error, attrs ...Attribute)
}

Tracer defines the interface for distributed tracing.

Directories

Path Synopsis
Package ast defines the abstract syntax tree (AST) representation for Cypher queries.
Package ast defines the abstract syntax tree (AST) representation for Cypher queries.
Package creators provides executors for Cypher data creation clauses.
Package creators provides executors for Cypher data creation clauses.
Package matchers provides executors for Cypher MATCH clauses and pattern matching.
Package matchers provides executors for Cypher MATCH clauses and pattern matching.
Package modifiers provides executors for Cypher data modification clauses including SET, DELETE, and REMOVE operations.
Package modifiers provides executors for Cypher data modification clauses including SET, DELETE, and REMOVE operations.

Jump to

Keyboard shortcuts

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