entdriver

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package entdriver

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EntDriver

type EntDriver struct {
	Client *ent.Client
}

EntDriver provides storage operations using an ent client. It is database-agnostic and can be embedded by specific drivers.

func (*EntDriver) Ancestry

func (ed *EntDriver) Ancestry(ctx context.Context, hash string) ([]*merkle.Node, error)

Ancestry returns the path from a node back to its root (node first, root last). Uses the parent edge for traversal.

func (*EntDriver) Close

func (ed *EntDriver) Close() error

Close closes the database connection.

func (*EntDriver) Depth

func (ed *EntDriver) Depth(ctx context.Context, hash string) (int, error)

Depth returns the depth of a node (0 for roots).

func (*EntDriver) Get

func (ed *EntDriver) Get(ctx context.Context, hash string) (*merkle.Node, error)

Get retrieves a node by its hash.

func (*EntDriver) GetByParent

func (ed *EntDriver) GetByParent(ctx context.Context, parentHash *string) ([]*merkle.Node, error)

GetByParent retrieves all nodes that have the given parent hash. Uses the children edge for efficient lookups.

func (*EntDriver) Has

func (ed *EntDriver) Has(ctx context.Context, hash string) (bool, error)

Has checks if a node exists by its hash.

func (*EntDriver) Leaves

func (ed *EntDriver) Leaves(ctx context.Context) ([]*merkle.Node, error)

Leaves returns all leaf nodes (nodes with no children). Uses the children edge for efficient detection.

func (*EntDriver) List

func (ed *EntDriver) List(ctx context.Context) ([]*merkle.Node, error)

List returns all nodes in the store.

func (*EntDriver) Put

func (ed *EntDriver) Put(ctx context.Context, n *merkle.Node) (bool, error)

Put stores a node. Returns true if the node was newly inserted, false if it already existed. This is a no-op due to content-addressing.

func (*EntDriver) Roots

func (ed *EntDriver) Roots(ctx context.Context) ([]*merkle.Node, error)

Roots returns all root nodes (nodes with no parent).

func (*EntDriver) UpdateUsage

func (ed *EntDriver) UpdateUsage(ctx context.Context, hash string, usage *llm.Usage) error

UpdateUsage updates only the token usage fields on an existing node by hash.

Jump to

Keyboard shortcuts

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