tenant

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package tenant 提供租户上下文信息的存取。

设计约定(与外部机制的分工):

  • 本包只做「结构体 + context 存取」,不做任何 proto/反射注入逻辑;
  • ctx 中的 *Info 由外部机制(网关入口 / 上游调用方)通过 WithInfo 写入, 各服务 logic 层通过 GetInfo 读取,并把 info.TenantID 手动复制进 proto Req。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithInfo

func WithInfo(ctx context.Context, info *Info) context.Context

WithInfo 将 info 写入 ctx 并返回新 ctx。

Types

type Info

type Info struct {
	TenantID   string         // 租户 ID(写入 proto Req 的 tenant_id)
	Language   string         // 业务语言(可选)
	UILanguage string         // 界面语言(可选)
	Extra      map[string]any // 扩展字段(预留,按需扩展)
}

Info 租户上下文信息。

func GetInfo

func GetInfo(ctx context.Context) *Info

GetInfo 从 ctx 读取 *Info;未写入或 ctx 为 nil 时返回 nil。

Jump to

Keyboard shortcuts

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