cypher

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse added in v0.2.0

func Parse(input string) (*ast.Query, error)

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 {
	Store *storage.DB
	Index *graph.Index
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(store *storage.DB) *Executor

func (*Executor) Execute

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

func (*Executor) ExecuteAST added in v0.2.0

func (e *Executor) ExecuteAST(ctx context.Context, query *ast.Query, params map[string]interface{}) (Result, error)

func (*Executor) ExecuteWithTx

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

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
}

func NewParser

func NewParser(input string) *Parser

func (*Parser) Parse

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

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

Jump to

Keyboard shortcuts

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