resolve

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// Register 注册一个或多个解析策略实现
	Register(resolvers ...Resolver) Engine
	// Resolve 并发解析一组目标,任一目标解析失败即返回错误(底层调用 ResolveWithErrorHandling 并开启 failFast)
	Resolve(ctx context.Context, targets []Target) ([]user.User, error)
	// ResolveWithErrorHandling 提供更细粒度的解析控制,支持配置 failFast(快速失败)模式
	// failFast 为 true 时,任一解析任务失败将立即取消其他进行中的任务并返回
	ResolveWithErrorHandling(ctx context.Context, targets []Target, failFast bool) ([]user.User, error)
}

Engine 规则解析引擎接口,负责将各种维度的分配规则(Target)解析为具体的系统用户

func NewEngine

func NewEngine() Engine

NewEngine 构造解析引擎

type Resolver

type Resolver interface {
	// Name 返回该解析器所覆盖的规则唯一标识,用于匹配 Target.Type
	Name() string
	// Resolve 根据 Target 解析出对应的用户列表
	Resolve(ctx context.Context, target Target) ([]user.User, error)
}

Resolver 策略接口:每个实现都应自我声明其 Name(唯一规则类型标识),以及对应的 Resolve 逻辑

type Target

type Target struct {
	Type   string   `json:"type"`   // 匹配策略,例如: 'appoint', 'role', 'leader' 等
	Values []string `json:"values"` // 规则的目标值列表
}

Target 是一种分配策略抽象,代表向哪个维度(Type)分配哪些实体(Ids/Fields)

Directories

Path Synopsis
Package resolveblocks is a generated GoMock package.
Package resolveblocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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