connector

package module
v0.0.0-...-c00318b Latest Latest
Warning

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

Go to latest
Published: May 24, 2025 License: Apache-2.0 Imports: 0 Imported by: 1

README

interface

Common standard interface for go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LevelString

func LevelString(lv Level) string

Types

type IBroker

type IBroker interface {
	Connect(url string) error
	Close() error
	Publish(topic string, v any) error
	Subscribe(topic string, handler MessageHandler) error
	OpenChannel(name string) (IChannel, error)
}

type IChannel

type IChannel interface {
	Close() error
	Publish(topic string, v any) error
	Subscribe(topic string, handler MessageHandler) error
}

type ICodec

type ICodec interface {
	MIMEType() string
	Marshal(v any) (data []byte, err error)
	Unmarshal(data []byte, v any) error
}

type ILogger

type ILogger interface {
	Debug(args ...any)
	Info(args ...any)
	Warn(args ...any)
	Error(args ...any)
	Fatal(args ...any)

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

type IMessage

type IMessage interface {
	//Acknowledge consumed message	/ 确认消费该消息
	Ack() error
	//Requeued to be consumed again / 重新排队并再次消费
	Requeue() error
	//Reject to consume again / 拒绝再次消费
	Reject() error
	//Unmarshal To target
	Unmarshal(v any) error
	//MIME content type
	ContentType() string
	// Body raw data
	Body() []byte
	//Message ID
	ID() string
}

type Level

type Level int8
const (
	DebugLevel Level = iota - 1
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
)

type MIMEType

type MIMEType string

MIME type的缩写为(Multipurpose Internet Mail Extensions)代表互联网媒体类型(Internet media type) *type有下面的形式。 Text:用于标准化地表示的文本信息,文本消息可以是多种字符集和或者多种格式的; Multipart:用于连接消息体的多个部分构成一个消息,这些部分可以是不同类型的数据; Application:用于传输应用程序数据或者二进制数据; Message:用于包装一个E-mail消息; Image:用于传输静态图片数据; Audio:用于传输音频或者音声数据; Video:用于传输动态影像数据,可以是与音频编辑在一起的视频数据格式。

const (
	MIMETypeBinary   MIMEType = "application/binary"
	MIMETypeXml      MIMEType = "application/xml"
	MIMETypeJson     MIMEType = "application/json"
	MIMETypeProtobuf MIMEType = "application/x-protobuf"
)

type MessageHandler

type MessageHandler func(IMessage)

Jump to

Keyboard shortcuts

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