constant

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 0 Imported by: 0

README

Constant

constant 包定义了微服务通信中通用的 HTTP Header / gRPC Metadata Key。

常用常量

这些常量主要用于 gRPC Metadata 或 HTTP Header 中传递上下文信息。

身份与追踪
  • TraceId:全链路追踪 ID(ff-trace-id
  • Session:会话标识(ff-session
  • Authorization:认证令牌(authorization
  • UserId:用户 ID(ff-user-id
  • AppId:应用 ID(ff-app-id
  • TenantId:租户 ID(ff-tenant-id
  • ClientIp:客户端 IP(ff-client-ip
  • XRealIp:反向代理透传真实 IP(x-real-ip
客户端信息
  • SystemName / SystemVersion:系统名称与版本
  • ClientName / ClientVersion:客户端名称与版本
  • SystemType / ClientType:系统/客户端类型
  • DeviceFormFactor:设备形态
  • AppVersion / AppLanguage:应用版本 / 语言
使用示例
import "github.com/fireflycore/go-micro/constant"

// 从 gRPC metadata 获取 TraceId
md, _ := metadata.FromIncomingContext(ctx)
traceId := md.Get(constant.TraceId)

Documentation

Overview

Package constant 定义微服务通用 header/metadata key。

Index

Constants

View Source
const (
	// DefaultNamespace 默认命名空间
	DefaultNamespace = "firefly"
	// DefaultNetworkSN 默认网卡命名
	DefaultNetworkSN = "firefly-main-network"
	// DefaultExternalNetworkAddress 默认外网地址
	DefaultExternalNetworkAddress = "127.0.0.1"
	// DefaultMaxRetry 默认重试次数
	DefaultMaxRetry = 3
	// DefaultTTL 默认心跳间隔
	DefaultTTL = 10
	// DefaultVersion 默认版本号
	DefaultVersion = "v0.0.1"
)
View Source
const (
	XRealIp           = "x-real-ip"
	Authorization     = "authorization"
	AuthorizationType = "authorization-type"

	AppLanguage = "ff-app-language"
	AppVersion  = "ff-app-version"

	TraceId  = "ff-trace-id"
	Session  = "ff-session"
	UserId   = "ff-user-id"
	AppId    = "ff-app-id"
	TenantId = "ff-tenant-id"
	ClientIp = "ff-client-ip"

	RoleIds = "ff-role-ids"
	OrgIds  = "ff-org-ids"

	SystemName       = "ff-system-name"
	ClientName       = "ff-client-name"
	SystemType       = "ff-system-type"
	ClientType       = "ff-client-type"
	DeviceFormFactor = "ff-device-form-factor"
	SystemVersion    = "ff-system-version"
	ClientVersion    = "ff-client-version"

	GrpcGatewayAuth = "ff-grpc-gateway-auth"
	HttpGatewayAuth = "ff-http-gateway-auth"
)
View Source
const (
	// KernelLanguage 内核开发语言
	KernelLanguage = "Golang"
)

Variables

This section is empty.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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