falkordb

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package falkordb is fabriq's graph adapter. FalkorDB speaks RESP, so it rides go-redis (GRAPH.QUERY / GRAPH.RO_QUERY); the Cypher dialect lives exclusively in mutate.go and stays inside the openCypher common subset gated by adapters/graphtest — the engine-swap contract.

Tenancy: reads resolve the tenant's LIVE graph through the injected resolver (fabriq.Open wires one over projection_state, so blue-green rebuilds flip readers atomically); projection writes receive an explicit target ("" = live). Graph names only ever come from core/registry derivations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

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

Adapter implements query.GraphQuerier against FalkorDB.

func Open

func Open(ctx context.Context, cfg Config, reg *registry.Registry, rel query.RelationalQuerier, opts ...Option) (*Adapter, error)

Open dials FalkorDB.

func (*Adapter) AggregateVersions

func (a *Adapter) AggregateVersions(ctx context.Context, tenantID string, ent *registry.Entity) (map[string]int64, error)

AggregateVersions reads id -> version for one entity's nodes from the tenant's live graph — the reconciler's projection side (projection.ProjectedVersions).

func (*Adapter) ApplyMutations

func (a *Adapter) ApplyMutations(ctx context.Context, target string, muts []projection.Mutation) error

ApplyMutations implements the projection write path: engine-neutral mutations onto an explicit target graph ("" = the tenant's live graph, resolved from the event's tenant on ctx). Version gating in the dialect makes replays idempotent.

func (*Adapter) Close

func (a *Adapter) Close() error

Close releases the client.

func (*Adapter) DropTarget

func (a *Adapter) DropTarget(ctx context.Context, target string) error

DropTarget removes a graph (rebuild old-target cleanup). Dropping a graph that never received a write is a no-op.

func (*Adapter) Query

func (a *Adapter) Query(ctx context.Context, cypher string, params map[string]any, into any) error

Query implements query.GraphQuerier: a read-only openCypher query against the tenant's live graph. into may be *[]string (single-column traversals) or *[]map[string]any (column-keyed rows).

Scope-aware reads: FalkorDB has no RLS; scope is a node property. This adapter operates on raw caller-supplied Cypher, so it CANNOT auto-inject a scope predicate. Instead, when a scope is present on ctx, it is injected into params as "$scope" so callers can reference it directly in their Cypher: WHERE n.scope_id IS NULL OR n.scope_id = $scope. An unscoped context omits "scope" from params (absent key = see all within tenant). The graph consumer (kgkit) adds the predicate in its generated traversals.

func (*Adapter) TraverseAndHydrate

func (a *Adapter) TraverseAndHydrate(ctx context.Context, cypher string, params map[string]any, into any) error

TraverseAndHydrate implements query.GraphQuerier: traversal returns ids, hydration is ONE batched relational query. Never N+1.

type Config

type Config struct {
	Addr     string
	Username string
	Password string
}

Config locates the FalkorDB instance.

type Option

type Option func(*Adapter)

Option customizes the adapter.

func WithLiveTargetResolver

func WithLiveTargetResolver(fn TargetResolver) Option

WithLiveTargetResolver overrides live-graph resolution (production wires a projection_state-backed resolver; the default derives tenant_{id}).

type TargetResolver

type TargetResolver func(ctx context.Context, tenantID string) (string, error)

TargetResolver maps a tenant onto its live graph name.

Jump to

Keyboard shortcuts

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