core

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectionFailed     = errors.New("etcd connection failed")
	ErrConnectionClosed     = errors.New("etcd connection closed")
	ErrConnectionTimeout    = errors.New("etcd connection timeout")
	ErrAuthenticationFailed = errors.New("etcd authentication failed")
)

预定义错误 - 连接相关

View Source
var (
	ErrInvalidConfig  = errors.New("invalid config")
	ErrConfigNotFound = errors.New("config not found in cache")
	ErrConfigEmpty    = errors.New("config is empty")
	ErrEndpointsEmpty = errors.New("etcd endpoints cannot be empty")
)

预定义错误 - 配置相关

View Source
var (
	ErrPutFailed     = errors.New("etcd put operation failed")
	ErrDeleteFailed  = errors.New("etcd delete operation failed")
	ErrGetFailed     = errors.New("etcd get operation failed")
	ErrWatchFailed   = errors.New("etcd watch failed")
	ErrWatchCanceled = errors.New("etcd watch canceled")
)

预定义错误 - 操作相关

View Source
var (
	ErrMarshalFailed   = errors.New("json marshal failed")
	ErrUnmarshalFailed = errors.New("json unmarshal failed")
)

预定义错误 - 序列化相关

Functions

This section is empty.

Types

type EventType

type EventType string

EventType 事件类型

const (
	EventTypePut    EventType = "PUT"
	EventTypeDelete EventType = "DELETE"
)

func (EventType) IsDelete

func (e EventType) IsDelete() bool

IsDelete 是否为 DELETE 事件

func (EventType) IsPut

func (e EventType) IsPut() bool

IsPut 是否为 PUT 事件

func (EventType) String

func (e EventType) String() string

String 返回事件类型的字符串表示

type LogContext

type LogContext struct {
	PodName     string
	ServiceName string
}

LogContext 日志上下文

func (*LogContext) WithModule

func (c *LogContext) WithModule(module, operation string) logx.Logger

WithModule 创建带模块和操作的日志记录器

type PrefixWatchCallback

type PrefixWatchCallback func(key string, eventType EventType)

PrefixWatchCallback 前缀监听回调函数类型 用于处理某个前缀下的键值变更事件

type WatchCallback

type WatchCallback func(event *WatchEvent) error

WatchCallback 监听回调函数类型 用于处理单个键值变更事件

type WatchConfig

type WatchConfig struct {
	Path   string // 监听路径(支持前缀)
	Struct any    // 绑定的结构体实例(用于 JSON 反序列化,可为 nil)
}

WatchConfig 监听配置项 用于定义需要监听的键及其绑定的结构体类型

type WatchEvent

type WatchEvent struct {
	Key       string    // 键
	Value     []byte    // 值(原始字节)
	EventType EventType // 事件类型
}

WatchEvent 监听事件

Jump to

Keyboard shortcuts

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