types

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientStream

type ClientStream interface {
	Header() (md.MD, error)
	Trailer() md.MD
	CloseSend() error
	Context() context.Context
	SendMsg(m interface{}) error
	RecvMsg(m interface{}) error
}

type Config

type Config interface {
	ConfigValues
	Close() error
	LoadSource(...ConfigSource) error
	AddWatcher(string, func(ConfigWatchEvent)) error
	DelWatcher(string, func(ConfigWatchEvent)) error
}

type ConfigPriority

type ConfigPriority uint8
const (
	ConfigPriorityFile ConfigPriority = iota
	ConfigPriorityEnv
	ConfigPriorityFlag
	ConfigPriorityCli
	ConfigPriorityRemote
	ConfigPriorityMemory
	ConfigPriorityMax
)

type ConfigSource

type ConfigSource interface {
	Name() string
	Read() (ConfigSourceData, error)
	Changeable() bool
	Watch() (<-chan ConfigSourceData, error)
	io.Closer
}

Source is the source from which conf is loaded

type ConfigSourceData

type ConfigSourceData interface {
	Priority() ConfigPriority
	Data() []byte
	Unmarshal(v interface{}) error
}

type ConfigValue

type ConfigValue interface {
	Bool(def ...bool) bool
	Int(def ...int) int
	Int64(def ...int64) int64
	String(def ...string) string
	Float64(def ...float64) float64
	Duration(def ...time.Duration) time.Duration
	StringSlice(def ...[]string) []string
	StringMap(def ...map[string]string) map[string]string
	Map(def ...map[string]interface{}) map[string]interface{}
	Scan(val interface{}) error
	Bytes(def ...[]byte) []byte
}

type ConfigValues

type ConfigValues interface {
	Get(key string) ConfigValue
	Set(key string, val interface{}) error
	Del(key string) error
	Map() map[string]interface{}
	Scan(v interface{}) error
	Bytes() []byte
}

type ConfigWatchEvent

type ConfigWatchEvent interface {
	Type() WatchEventType
	Value() ConfigValue
}

type InstanceInfo

type InstanceInfo interface {
	// 命名空间
	Namespace() string
	// 服务名
	Name() string
	// 版本号
	Version() string
	// 地区
	Region() string
	// 地域
	Zone() string
	// 园区
	Campus() string
	// 元信息
	Metadata() map[string]string
	// 添加元信息(忽略已存在的KEY)
	AddMetadata(key, val string) bool
}

type Level

type Level int8
const (
	LvDebug Level = iota - 1
	LvInfo
	LvWarn
	LvError
	LvFault
)

func (Level) MarshalText added in v0.1.1

func (l Level) MarshalText() ([]byte, error)

MarshalText marshals the Level to text. Note that the text representation drops the -Level suffix (see example).

func (Level) String added in v0.1.1

func (l Level) String() string

String returns a lower-case ASCII representation of the log level.

func (*Level) UnmarshalText added in v0.1.1

func (l *Level) UnmarshalText(text []byte) error

UnmarshalText unmarshals text to a level. Like MarshalText, UnmarshalText expects the text representation of a Level to drop the -Level suffix (see example).

In particular, this makes it easy to configure logging levels using YAML, TOML, or JSON files.

type Logger

type Logger interface {
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Debug(args ...interface{})
	Fatal(args ...interface{})

	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})

	SetLevel(Level)
	GetLevel() Level
	Enable(Level) bool
}

type LoggerConstructor added in v0.1.1

type LoggerConstructor func() Logger

type Registry

type Registry interface {
	Register(context.Context, RegistryInstance) error
	Deregister(context.Context, RegistryInstance) error
	Name() string
}

type RegistryConstructor

type RegistryConstructor func() Registry

type RegistryInstance

type RegistryInstance interface {
	Region() string
	Zone() string
	Campus() string
	Namespace() string
	Name() string
	Version() string
	Metadata() map[string]string
	Endpoints() []ServerInfo
}

type Server

type Server interface {
	Serve() error
	Stop() error
	Info() ServerInfo
}

type ServerConstructor

type ServerConstructor func() Server

type ServerInfo

type ServerInfo interface {
	Scheme() string
	Kind() ServerKind
	Endpoint() string
	Metadata() map[string]string
}

type ServerKind

type ServerKind string
const (
	ServerKindRpc      ServerKind = "rpc"
	ServerKindJob      ServerKind = "job"
	ServerKindTask     ServerKind = "task"
	ServerKindGovernor ServerKind = "governor"
)

type ServerStream

type ServerStream interface {
	SetHeader(md.MD) error
	SendHeader(md.MD) error
	SetTrailer(md.MD)
	Context() context.Context
	SendMsg(m interface{}) error
	RecvMsg(m interface{}) error
}

type TracerProviderConstructor

type TracerProviderConstructor func(name string) trace.TracerProvider

type WatchEventType

type WatchEventType uint32
const (
	WatchEventUpd WatchEventType
	WatchEventAdd
	WatchEventDel
)

Jump to

Keyboard shortcuts

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