ami

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeAction   MessageType = "Action"
	MessageTypeEvent                = "Event"
	MessageTypeResponse             = "Response"
)
View Source
const (
	EOL = "\r\n"
	EOM = "\r\n\r\n"
	EOB = '\n'
	SEP = ":"
	SPC = " "
	EMP = ""
)

Variables

This section is empty.

Functions

func ReadMessage

func ReadMessage(m *Message, rd io.Reader) (err error)

func WriteMessage

func WriteMessage(m *Message, w io.Writer) (err error)

Types

type Conn

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

func Connect

func Connect(addr string, opts ...ConnectOption) (conn *Conn, err error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Request

func (c *Conn) Request(r interface{}, opts ...RequestOption) (resp *Message, err error)

func (*Conn) Subscribe

func (c *Conn) Subscribe(cb SubscribeFunc, opts ...SubscribeOption) (func(), error)

type ConnErrHandler

type ConnErrHandler func(*Conn, error)

type ConnHandler

type ConnHandler func(*Conn)

type ConnectOption

type ConnectOption func(c *ConnectOptions) error

func WithAllowReconnect

func WithAllowReconnect() ConnectOption

func WithAuth

func WithAuth(username string, secret string) ConnectOption

func WithContext

func WithContext(ctx context.Context) ConnectOption

func WithCustomDialer

func WithCustomDialer(dialer CustomDialer) ConnectOption

func WithOnConnectError

func WithOnConnectError(handler ConnErrHandler) ConnectOption

func WithOnConnected

func WithOnConnected(handler ConnHandler) ConnectOption

func WithSubscribe

func WithSubscribe(cb SubscribeFunc, opts ...SubscribeOption) ConnectOption

func WithTimeout

func WithTimeout(timeout time.Duration) ConnectOption

type ConnectOptions

type ConnectOptions struct {
	Context        context.Context
	Timeout        time.Duration
	AllowReconnect bool
	Username       string // login username
	Secret         string // login secret
	Logger         *zap.Logger
	Dialer         CustomDialer
	OnConnectErr   ConnErrHandler
	OnConnected    ConnHandler
	// contains filtered or unexported fields
}

type CustomDialer

type CustomDialer interface {
	Dial(network, address string) (net.Conn, error)
}

type Message

type Message struct {
	Type       MessageType
	Name       string
	Attributes map[string]interface{}
}

func ConvertToMessage

func ConvertToMessage(in interface{}) (msg *Message, err error)

func (*Message) AttrString

func (m *Message) AttrString(name string) string

func (*Message) Error

func (m *Message) Error() error

func (*Message) Format

func (m *Message) Format() string

func (*Message) Message

func (m *Message) Message() string

func (*Message) Read

func (m *Message) Read(r *bufio.Reader) (err error)

func (*Message) SetAttr

func (m *Message) SetAttr(name string, val interface{})

func (*Message) Success

func (m *Message) Success() bool

func (*Message) Write

func (m *Message) Write(w io.Writer) (err error)

type MessageType

type MessageType string

type RequestOption

type RequestOption func(o *requestOptions) error

func RequestResponseCallback

func RequestResponseCallback(cb func(ctx context.Context, msg *Message, err error)) RequestOption

func RequestTimeout

func RequestTimeout(d time.Duration) RequestOption

type SubscribeFunc

type SubscribeFunc func(ctx context.Context, message *Message) bool

func SubscribeChan

func SubscribeChan(c chan *Message, names ...string) SubscribeFunc

func SubscribeFullyBootedChanOnce

func SubscribeFullyBootedChanOnce(c chan *Message) SubscribeFunc

type SubscribeOption

type SubscribeOption func(o *subscribe) error

func SubscribeSend

func SubscribeSend() SubscribeOption

func SubscribeSetContext

func SubscribeSetContext(ctx context.Context) SubscribeOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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