Help us shape the future of Go! Take the 2026 Go Developer Survey

deletion

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package deletion 定义删除前阻塞项的通用契约与组合器。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Blocker

type Blocker struct {
	Kind  string `json:"kind"`
	ID    int64  `json:"id"`
	Label string `json:"label"`
}

Blocker 是阻止删除的一条入站关系。 Kind、ID 与 Label 用于调用方展示并定位引用来源。

type Checker

type Checker func(ctx context.Context, novelID, targetID int64) ([]Blocker, error)

Checker 查询某一种目标实体的删除阻塞项。

type EntityKind

type EntityKind string

EntityKind 标识待删除或引用来源的实体类型。

const (
	EntityChapter   EntityKind = "chapter"
	EntityCharacter EntityKind = "character"
	EntityLocation  EntityKind = "location"
	EntityStoryArc  EntityKind = "story_arc"
)

type Guard

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

Guard 查询目标实体的全部删除阻塞项。 Guard 构造后只读,可由多个调用方并发使用。

func NewGuard

func NewGuard(registrations ...Registration) *Guard

NewGuard 组合按目标实体类型注册的检查器。

func (*Guard) Blockers

func (g *Guard) Blockers(ctx context.Context, target Target) ([]Blocker, error)

type Registration

type Registration struct {
	TargetKind EntityKind
	Checker    Checker
}

Registration 将一个 Checker 注册到目标实体类型。

func For

func For(targetKind EntityKind, checker Checker) Registration

For 为指定目标实体类型创建一条检查注册。

type Target

type Target struct {
	NovelID int64
	Kind    EntityKind
	ID      int64
}

Target 描述一次删除检查的目标实体。

Jump to

Keyboard shortcuts

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