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

dispatch

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 1 Imported by: 2

Documentation

Overview

Package dispatch 通用派发守卫:allow 矩阵 + 深度上限 + 自派发拒绝。 拓扑边由宿主经 EdgeSource 抽象提供(编译期校验过的 allow 矩阵),守卫运行期只读; 被拒绝的派发返回结构化 *DenyError——调用方不得转述、不得降级,按失败兜底如实上报。 沉淀自 bianque engine/dispatch(v0.9.5):注册表耦合改为 EdgeSource 接口。

Index

Constants

View Source
const (
	ReasonNotAllowed    = "not_allowed"    // caller→callee 不在 allow 矩阵
	ReasonDepthExceeded = "depth_exceeded" // 派发深度超限
	ReasonSelfDispatch  = "self_dispatch"  // 自派发
)

拒绝原因词表(DenyError.Reason 的取值全集,审计消费方按常量比对而非裸字符串)。

Variables

This section is empty.

Functions

This section is empty.

Types

type DenyError

type DenyError struct {
	Caller string
	Callee string
	Depth  int
	Reason string // ReasonNotAllowed | ReasonDepthExceeded | ReasonSelfDispatch
}

DenyError 结构化拒绝(宿主可原样落审计事件载荷)。

func (*DenyError) Error

func (e *DenyError) Error() string

type EdgeSource

type EdgeSource interface {
	Slugs() []string
	// DispatchAllow 返回 slug 允许派发的目标列表(slug 未登记返回 nil)。
	DispatchAllow(slug string) []string
}

EdgeSource 拓扑边来源:宿主注册表的最小投影(slug 全集 + 各 slug 允许派发的目标)。

type Guard

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

Guard 派发守卫:构建期物化 allow 矩阵,运行期只读。

func NewGuard

func NewGuard(src EdgeSource, maxDepth int) *Guard

NewGuard 从边来源构建守卫。

func (*Guard) Allowed

func (g *Guard) Allowed(caller, callee string) bool

Allowed 只读查询(供事件载荷/诊断面展示可达性)。

func (*Guard) Assert

func (g *Guard) Assert(caller, callee string, depth int) error

Assert 校验 caller→callee 派发;不合法返回 *DenyError。

func (*Guard) AssertDepth

func (g *Guard) AssertDepth(depth int) error

AssertDepth 仅校验深度(引擎内部环节推进用)。

Jump to

Keyboard shortcuts

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