Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BuildContextOptions ¶
BuildContextOptions 定义构建服务主上下文时需要补齐的服务自身身份。
type Context ¶
type Context struct {
UserId string
AppId string
TenantId string
OrgIds []string
RoleIds []string
// TraceId 表示从当前 OTel span 提取的 trace 标识快照,不对应自定义 header。
TraceId string
RouteMethod string
AccessMethod string
ServiceAppId string
ServiceInstanceId string
}
Context 表示当前请求在服务内部流转时的统一主上下文。
func BuildContext ¶
func BuildContext(ctx context.Context, options BuildContextOptions) *Context
BuildContext 从入站 metadata 与运行时信息构造服务主上下文。
它只负责把服务端入口已经拿到的 metadata 与 OTel span 信息结构化, 不负责缓存 transport 原文,也不参与出站调用语义。
func FromContext ¶
FromContext 从 ctx 读取服务主上下文。
func MustFromContext ¶
MustFromContext 从 ctx 读取服务主上下文,不存在时 panic。
Click to show internal directories.
Click to hide internal directories.