humors

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2021 License: MIT Imports: 12 Imported by: 1

README

humors

Documentation

Index

Constants

View Source
const (
	ERROR string = "[HUMORS][ERROR] "
	WARN  string = "[HUMORS][WARN] "
	INFO  string = "[HUMORS][INFO] "
	DEBUG string = "[HUMORS][DEBUG] "

	ADAPTOR string = "[ADAPTOR] "
	SERVANT string = "[SERVANT] "

	HUMORS_ERR string = "HUMORS_ERR: %d"
)

Variables

View Source
var (
	ErrorCode_name = map[int32]string{
		0: "SUCCESS",
		1: "DECODEERR",
		2: "ENCODEERR",
		3: "NOFUNCERR",
		4: "NOSERVANTERR",
		5: "CONNECTERR",
		6: "TIMEOUT",
	}
	ErrorCode_value = map[string]int32{
		"SUCCESS":      0,
		"DECODEERR":    1,
		"ENCODEERR":    2,
		"NOFUNCERR":    3,
		"NOSERVANTERR": 4,
		"CONNECTERR":   5,
		"TIMEOUT":      6,
	}
)

Enum value maps for ErrorCode.

View Source
var File_humors_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type ErrorCode

type ErrorCode int32
const (
	ErrorCode_SUCCESS      ErrorCode = 0
	ErrorCode_DECODEERR    ErrorCode = 1
	ErrorCode_ENCODEERR    ErrorCode = 2
	ErrorCode_NOFUNCERR    ErrorCode = 3
	ErrorCode_NOSERVANTERR ErrorCode = 4
	ErrorCode_CONNECTERR   ErrorCode = 5
	ErrorCode_TIMEOUT      ErrorCode = 6
)

func (ErrorCode) Descriptor

func (ErrorCode) Descriptor() protoreflect.EnumDescriptor

func (ErrorCode) Enum

func (x ErrorCode) Enum() *ErrorCode

func (ErrorCode) EnumDescriptor deprecated

func (ErrorCode) EnumDescriptor() ([]byte, []int)

Deprecated: Use ErrorCode.Descriptor instead.

func (ErrorCode) Number

func (x ErrorCode) Number() protoreflect.EnumNumber

func (ErrorCode) String

func (x ErrorCode) String() string

func (ErrorCode) Type

type HumorAdaptor

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

func (*HumorAdaptor) Call

func (a *HumorAdaptor) Call(clientID string, action int32,
	req proto.Message, res proto.Message) error

func (*HumorAdaptor) CallTopic

func (a *HumorAdaptor) CallTopic(topic string, action int32,
	req proto.Message, res proto.Message) error

func (*HumorAdaptor) MessageHandler

func (a *HumorAdaptor) MessageHandler(_ MQTT.Client, message MQTT.Message)

type HumorServant

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

func (*HumorServant) MessageHandler

func (s *HumorServant) MessageHandler(_ MQTT.Client, message MQTT.Message)

func (*HumorServant) RegisterFun

func (s *HumorServant) RegisterFun(action int32, req interface{}, res interface{},
	fun func(ctx context.Context, req interface{}, res interface{}))

type Humors

type Humors struct {
	Adaptor *HumorAdaptor
	Servant *HumorServant
	// contains filtered or unexported fields
}

func NewHumors

func NewHumors(opts *MQTT.ClientOptions) (*Humors, error)

func (*Humors) InitAdaptor

func (h *Humors) InitAdaptor(timeout int32)

func (*Humors) InitServant

func (h *Humors) InitServant(topic string)

type RequestPacket

type RequestPacket struct {
	ReqID    int32  `protobuf:"varint,1,opt,name=reqID,proto3" json:"reqID,omitempty"`
	Action   int32  `protobuf:"varint,2,opt,name=action,proto3" json:"action,omitempty"`
	Timeout  int32  `protobuf:"varint,3,opt,name=timeout,proto3" json:"timeout,omitempty"`
	Payload  []byte `protobuf:"bytes,4,opt,name=payload,proto3" json:"payload,omitempty"`
	ResTopic string `protobuf:"bytes,5,opt,name=resTopic,proto3" json:"resTopic,omitempty"`
	// contains filtered or unexported fields
}

func (*RequestPacket) Descriptor deprecated

func (*RequestPacket) Descriptor() ([]byte, []int)

Deprecated: Use RequestPacket.ProtoReflect.Descriptor instead.

func (*RequestPacket) GetAction

func (x *RequestPacket) GetAction() int32

func (*RequestPacket) GetPayload

func (x *RequestPacket) GetPayload() []byte

func (*RequestPacket) GetReqID

func (x *RequestPacket) GetReqID() int32

func (*RequestPacket) GetResTopic

func (x *RequestPacket) GetResTopic() string

func (*RequestPacket) GetTimeout

func (x *RequestPacket) GetTimeout() int32

func (*RequestPacket) ProtoMessage

func (*RequestPacket) ProtoMessage()

func (*RequestPacket) ProtoReflect

func (x *RequestPacket) ProtoReflect() protoreflect.Message

func (*RequestPacket) Reset

func (x *RequestPacket) Reset()

func (*RequestPacket) String

func (x *RequestPacket) String() string

type ResponsePacket

type ResponsePacket struct {
	ReqID   int32     `protobuf:"varint,1,opt,name=reqID,proto3" json:"reqID,omitempty"`
	Code    ErrorCode `protobuf:"varint,2,opt,name=code,proto3,enum=humors.ErrorCode" json:"code,omitempty"`
	Payload []byte    `protobuf:"bytes,3,opt,name=payload,proto3" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

func (*ResponsePacket) Descriptor deprecated

func (*ResponsePacket) Descriptor() ([]byte, []int)

Deprecated: Use ResponsePacket.ProtoReflect.Descriptor instead.

func (*ResponsePacket) GetCode

func (x *ResponsePacket) GetCode() ErrorCode

func (*ResponsePacket) GetPayload

func (x *ResponsePacket) GetPayload() []byte

func (*ResponsePacket) GetReqID

func (x *ResponsePacket) GetReqID() int32

func (*ResponsePacket) ProtoMessage

func (*ResponsePacket) ProtoMessage()

func (*ResponsePacket) ProtoReflect

func (x *ResponsePacket) ProtoReflect() protoreflect.Message

func (*ResponsePacket) Reset

func (x *ResponsePacket) Reset()

func (*ResponsePacket) String

func (x *ResponsePacket) String() string

Directories

Path Synopsis
example
api

Jump to

Keyboard shortcuts

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