service

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 21, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DelRdValue

func DelRdValue(key string) (int64, error)

func EmqxApiPublish

func EmqxApiPublish(emqxCfg *config.EmqxConf, params *EmqxParamsConf)

EmqxApiPublish 使用emqx自带api服务,便于业务管理后台操作

func GetClient

func GetClient(addr, username, password, database, precision string) client.Client

func GetMqttClient

func GetMqttClient(broker_, username_, password_ string, defaultHandler mqtt.MessageHandler) mqtt.Client

func GetRdValue

func GetRdValue(key string) (string, error)

func GetRedisClient

func GetRedisClient(addr, password string, db int) *redis.Client

func MqttSend

func MqttSend(topic string, payload interface{}, qos_ byte) error

func MqttSubscribe

func MqttSubscribe(broker_, username_, password_, topic_ string, qos_ byte, defaultHandler mqtt.MessageHandler) error

func SelectInflux

func SelectInflux(sn, sql string, database, prefix string) (res []client.Result, err1 error)

SelectInflux sql是赛选条件,例:`LIMIT 10`

func SetRdValue

func SetRdValue(key string, value interface{}) error

func SetRdValueTimeout

func SetRdValueTimeout(key string, value interface{}, expiration time.Duration) error

func SubscribeKeyExpired

func SubscribeKeyExpired(fc RedisKeyExpiredFunc) error

func WirteInflux

func WirteInflux(sn string, productKey string, status int64, fields map[string]interface{}, database, prefix, precision string) (string, error)

Types

type EmqxParamsConf

type EmqxParamsConf struct {
	model.Eq2MqLog
	App     string // 暂时未使用,默认 runThings
	User    int64  // 用户id
	Project int64  // 项目id
}

type RabbitMQ

type RabbitMQ struct {

	//队列名称
	QueueName string
	//交换机
	Exchange string
	//key Simple模式 几乎用不到
	Key string
	//连接信息
	Mqurl string
	// contains filtered or unexported fields
}

func NewRabbitMQ

func NewRabbitMQ(queuename string, exchange string, key string, mqurl string) *RabbitMQ

NewRabbitMQ 创建RabbitMQ结构体实例

func NewRabbitMQPubSub

func NewRabbitMQPubSub(exchangeName string, mqurl string) *RabbitMQ

NewRabbitMQPubSub 订阅模式创建rabbitmq实例

func NewRabbitMQRouting

func NewRabbitMQRouting(exchagne string, routingKey string, mqurl string) *RabbitMQ

NewRabbitMQRouting 路由模式 创建RabbitMQ实例

func NewRabbitMQSimple

func NewRabbitMQSimple(queueName string, mqurl string) *RabbitMQ

NewRabbitMQSimple 简单模式step:1。创建简单模式下RabbitMQ实例

func NewRabbitMQTopic

func NewRabbitMQTopic(exchagne string, routingKey string, mqurl string) *RabbitMQ

NewRabbitMQTopic 话题模式 创建RabbitMQ实例

func (*RabbitMQ) ConsumeSimple

func (r *RabbitMQ) ConsumeSimple(fc recieveMsgFunc)

ConsumeSimple 修改简单模式,其实支持外部函数调用

func (*RabbitMQ) Destory

func (r *RabbitMQ) Destory()

Destory 断开channel和connection

func (*RabbitMQ) PublishPub

func (r *RabbitMQ) PublishPub(message string)

PublishPub 订阅模式生成

func (*RabbitMQ) PublishRouting

func (r *RabbitMQ) PublishRouting(message string)

PublishRouting 路由模式发送信息

func (*RabbitMQ) PublishSimple

func (r *RabbitMQ) PublishSimple(message string)

PublishSimple 简单模式Step:2、简单模式下生产代码

func (*RabbitMQ) PublishTopic

func (r *RabbitMQ) PublishTopic(message string)

PublishTopic 话题模式发送信息

func (*RabbitMQ) RecieveRouting

func (r *RabbitMQ) RecieveRouting()

RecieveRouting 路由模式接收信息

func (*RabbitMQ) RecieveSub

func (r *RabbitMQ) RecieveSub(fc recieveMsgFunc)

RecieveSub 订阅模式消费端代码

func (*RabbitMQ) RecieveTopic

func (r *RabbitMQ) RecieveTopic()

RecieveTopic 话题模式接收信息 要注意key 其中* 用于匹配一个单词,#用于匹配多个单词(可以是零个) 匹配 表示匹配imooc.* 表示匹配imooc.hello,但是imooc.hello.one需要用imooc.#才能匹配到

type RedisKeyExpiredFunc

type RedisKeyExpiredFunc func(string)

Jump to

Keyboard shortcuts

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