impl

package
v1.1.34 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package impl 实现 gRPC CommonWorker:P=0 明文;s=SHA256(规范字段);e=ML-DSA.Sign(SHA256(规范字段));Cipher 为 *crypto.MLDSA87Object。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearAllHandlers

func ClearAllHandlers()

ClearAllHandlers 清空所有已注册的业务处理器 注意: 此方法主要用于测试场景,在生产环境中应谨慎使用

func GetAllHandlers

func GetAllHandlers() map[string]HandlerEntry

GetAllHandlers 获取所有已注册的业务处理器 返回: 包含所有路由和对应处理器映射的map副本,防止外部修改原始数据

func GetHandler

func GetHandler(router string) (RequestHandler, RequestConstructor)

GetHandler 根据路由获取对应的业务处理器 router: 路由标识符,用于匹配具体的业务处理逻辑 返回: 如果找到对应的处理器则返回,否则返回nil GetHandler 获取:返回处理器 + 构造函数(确保非 nil)

func SetHandler

func SetHandler(router string, handler RequestHandler, constructor RequestConstructor)

SetHandler 注册:同时传入处理器 + 构造函数

Types

type CipherHook

type CipherHook func(usr int64) (crypto.Cipher, error)

CipherHook 按客户端用户 ID 动态解析 ML-DSA Cipher(本端私钥 + 对端公钥)。

type CommonWorker

type CommonWorker struct {
	pb.UnimplementedCommonWorkerServer
	ConfigProvider ConfigProvider // 配置提供者接口
}

func (*CommonWorker) Do

func (*CommonWorker) GetLocalCache

func (self *CommonWorker) GetLocalCache() cache.Cache

func (*CommonWorker) GetRedisCache

func (self *CommonWorker) GetRedisCache() cache.Cache

type ConfigProvider

type ConfigProvider interface {
	GetCipherHook() CipherHook
	GetLocalCache() cache.Cache
	GetRedisCache() cache.Cache
}

ConfigProvider 配置提供者接口

type HandlerEntry

type HandlerEntry struct {
	Handler     RequestHandler     // 原业务处理器
	Constructor RequestConstructor // 请求对象构造函数(new object 方法)
}

2. 定义路由项:绑定处理器 + 构造函数

type RequestConstructor

type RequestConstructor func() proto.Message

1. 定义请求对象构造函数:负责返回非 nil 的业务请求实例(核心) 替代原来的 RequestType(),编译期保证返回非 nil

type RequestHandler

type RequestHandler func(ctx context.Context, req proto.Message) (proto.Message, error)

Jump to

Keyboard shortcuts

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