graphdb

package
v0.0.0-...-d7ba063 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNonUniqueNameError

func IsNonUniqueNameError(err error) bool

IsNonUniqueNameError 判读是否是重名错误

Types

type Database

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

Database 存储数据库连接和读写锁

func NewDatabase

func NewDatabase(conn *sql.DB, initDatabase bool) (*Database, error)

NewDatabase 创建 Database 对象,并且初始化表

func NewSqliteConn

func NewSqliteConn(root string) (*Database, error)

NewSqliteConn 新建 sqlite 连接

func (*Database) Close

func (db *Database) Close() error

func (*Database) Exists

func (db *Database) Exists(name string) bool

Exists 判断名为 name 的 entity 存不存在

func (*Database) Get

func (db *Database) Get(name string) *Entity

Get 根据路径层级 name,一直寻找到最后一层的 Entity

func (*Database) List

func (db *Database) List(name string, depth int) Entities

List 按名称列出所有实体 键将是实体的完整路径 根据深度找到所有 名为 name 的 实体

func (*Database) RootEntity

func (db *Database) RootEntity() *Entity

RootEntity 返回实体的根 "/",所有的实体都是从 0 实体开始

func (*Database) Set

func (db *Database) Set(fullPath, id string) (*Entity, error)

Set 根据 id 添加实体,并根据提供的 path 添加实体关系

type Edge

type Edge struct {
	EntityId string // 实体 id
	Name     string // 实体 名称
	ParentId string // 实体的父级
}

Edge 不同实体间的关联关系 edge 表主要用于定义这些实体之间的关系。在 Docker 的分层文件系统中,不同的镜像层(实体)会彼此依赖,edge 表用来维护这些依赖关系。

type Edges

type Edges []*Edge

type Entities

type Entities map[string]*Entity

func (*Entities) Paths

func (es *Entities) Paths() []string

Paths 返回按深度排序的路径

type Entity

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

Entity 通过 id 关联唯一存储实体 entity 表通常用来存储关于 Docker 镜像、容器或层 (layer) 的元数据。每个 entity 代表 Docker 存储中的一个组件,比如一个容器层或镜像层

func (*Entity) Id

func (e *Entity) Id() string

Id 获取 Entity 实例中的 id

type WalkMeta

type WalkMeta struct {
	Parent   *Entity // 父 Entity
	Entity   *Entity // 当前 Entity
	FullPath string  // 完成的路径,通过组合父实体的路径和当前边的名称来构建,便于追踪实体在树形结构中的位置。
	Edge     *Edge   // 当前 Entity 所有关联的 Entity,从父实体到当前实体的连接信息
}

Jump to

Keyboard shortcuts

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