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 ¶
- type Adapter
- func (a *Adapter) AggregateVersions(ctx context.Context, tenantID string, ent *registry.Entity) (map[string]int64, error)
- func (a *Adapter) ApplyMutations(ctx context.Context, target string, muts []projection.Mutation) error
- func (a *Adapter) Close() error
- func (a *Adapter) DropTarget(ctx context.Context, target string) error
- func (a *Adapter) Query(ctx context.Context, cypher string, params map[string]any, into any) error
- func (a *Adapter) TraverseAndHydrate(ctx context.Context, cypher string, params map[string]any, into any) error
- type Config
- type Option
- type TargetResolver
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) DropTarget ¶
DropTarget removes a graph (rebuild old-target cleanup). Dropping a graph that never received a write is a no-op.
func (*Adapter) Query ¶
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.
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}).