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

eventcode

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: 4 Imported by: 0

Documentation

Overview

Package eventcode 是 fleetly 平台事件名注册表(代码内唯一真源)。

契约纪律(架构 §2.8):事件与错误码同归注册表管理,稳定字符串、永不 复用、只新增;文档域清单(release-semantics §2.7、stateful-placement §2.8、state-model §2.9/§2.10、architecture §4.3)为定义性说明。 命名格式 `namespace.name`(小写 snake_case,如 deployment.rollback_failed)。

fail-fast:重复注册、非法格式在构造期(包初始化)panic。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Len

func Len() int

func Names

func Names() []string

Types

type Event

type Event struct {
	// Name 形如 "deployment.queued"。
	Name string
	// Summary 一句话语义(注册表内说明)。
	Summary string
}

Event 是一个已注册平台事件名。

func All

func All() []Event

func Get

func Get(name string) (Event, bool)

Get / Len / Names / All 的包级快捷方式(作用于 Default)。

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry 是事件名注册表(只增)。

func Default

func Default() *Registry

Default 返回包级默认注册表。

func NewRegistry

func NewRegistry() *Registry

NewRegistry 构造空注册表。

func (*Registry) All

func (r *Registry) All() []Event

All 返回全部事件(按 Name 字典序)。

func (*Registry) Get

func (r *Registry) Get(name string) (Event, bool)

Get 按事件名查询;未注册返回 false。

func (*Registry) Len

func (r *Registry) Len() int

Len 返回已注册事件数。

func (*Registry) MustRegister

func (r *Registry) MustRegister(e Event)

MustRegister 注册一个事件名:格式非法或重复注册时 panic(构造期 fail-fast)。

func (*Registry) Names

func (r *Registry) Names() []string

Names 返回全部事件名(字典序)。

func (*Registry) Snapshot

func (r *Registry) Snapshot() string

Snapshot 返回注册表的规范化文本快照(golden 测试用):每行 name \t summary,按 Name 字典序。

Jump to

Keyboard shortcuts

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