Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BuildContextOptions ¶
BuildContextOptions 定义构建服务主上下文时需要补齐的服务自身身份。
type Config ¶ added in v1.4.3
type Config struct {
// Service 表示业务服务名,例如 auth。
Service string `json:"service"`
// Namespace 表示命名空间,例如 default。
Namespace string `json:"namespace"`
// ServiceType 表示服务类型片段,默认值通常为 svc。
ServiceType string `json:"service_type"`
// ClusterDomain 表示集群域,默认值通常为 cluster.local。
ClusterDomain string `json:"cluster_domain"`
// Port 表示业务服务监听端口,默认值通常为 9090。
Port uint16 `json:"port"`
}
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.