Help us shape the future of Go! Take the 2026 Go Developer Survey

naming

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package naming 是 fleetly 平台对象命名与最小 label 集的唯一定义点 (state-model §2.4 对象标记契约 + architecture §2.4 服务命名与网络行)。

纪律:

  • 命名公式逐字对齐设计文档,任何字符串改动都意味着契约破坏(表驱动 测试对照文档原文钉死,naming_test.go);
  • 平台命名只存在于适配器——归一化 compose 不出现平台名(§2.4「平台 命名不进归一化 compose」);调用方 = internal/substrate / 发布引擎;
  • label 密钥/payload 永不进 label(state-model §2.4)。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppID8

func AppID8(appID string) (string, error)

AppID8 返回 app 平台 ID 的前 8 位(卷命名防撞尾缀)。ULID 为 26 位, 前 8 位已含高精度时间戳成分。

func ContainerLabels

func ContainerLabels(app string) (map[string]string, error)

ContainerLabels 构造容器归属 label(state-model §2.4 表 Container 行: 仅 fleetly.app——人工排障识别归属,不参与决策;执行中继的容器准入 判定同用此 label,architecture §2.6 D19)。

func Hash8

func Hash8(content string) string

Hash8 返回内容 sha256 hex 前 8 位(secret 命名尾缀:值轮换即换名)。

func NetworkAlias

func NetworkAlias(service string) (string, error)

NetworkAlias 返回服务在 app 网络内的别名 = compose 服务名(app 内短名 互访与 compose 语义一致;跨 app 不可见——隔离由每 app 专属网络保证)。

func NetworkName

func NetworkName(app string) (string, error)

NetworkName 返回 app 专属 overlay 网络名(保守补全 `fleetly-<app>-net`; 文档钉死的是「每 app 专属 overlay 网络 + 服务别名 = compose 服务名」语义, 未钉网络名字符串——命名与前缀纪律保持一致,跨 app 网络隔离由专属网络 承载,architecture §2.4 服务命名与网络行)。

func SecretName

func SecretName(app, name, hash8 string) (string, error)

SecretName 返回 Swarm secret 名 `fleetly-<app>-<name>-<hash8>`。hash8 由调用方经 Hash8(内容) 计算——**值轮换即换名换引用**(architecture §2.4 密钥行;desired-hash 以 secret 引用参与,轮换天然触发重部署)。

func ServiceLabels

func ServiceLabels(app, service, deploymentID string) (map[string]string, error)

ServiceLabels 构造 Swarm 服务的平台 label 最小集(state-model §2.4 对象 标记契约,表 Service 行:managed=true、app、process、deployment;cron 为 v0.2 契约、调用方经 state 常量另行附加)。写者唯一 = 适配器 Marker 端口; 密钥/payload 永不入 label。返回 map 无序,消费方(Docker API)对顺序无 语义依赖;需要稳定序列化时用 SortedServiceLabels。

app/compose 服务名经过 validateComponent 校验(与命名函数同一字符集—— 两者最终都落到 Swarm 对象名/label 值)。

func ServiceName

func ServiceName(app, service string) (string, error)

ServiceName 返回 Swarm 服务名 `fleetly-<app>-<service>`:两个 app 各有 同名服务(web/db)不冲突;服务别名 = compose 服务名(app 内短名互访与 compose 语义一致,见 NetworkAlias)。

func SortedServiceLabels

func SortedServiceLabels(labels map[string]string) [][2]string

SortedServiceLabels 返回键序稳定的 label 序列(golden 测试与日志脱敏 渲染用)。

func VolumeName

func VolumeName(app, key, appID string) (string, error)

VolumeName 返回平台卷名 `fleetly-<app>-<key>-<appid8>`:卷无 label, 用命名约定承载归属(state-model §2.4;VolumeOptions.Labels 生效前的 收敛路径,stateful-placement §6)。appid8 = app 平台 ID 前 8 位。

Types

This section is empty.

Jump to

Keyboard shortcuts

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