fanux / lhttp

go websocket, a better way to buid your IM server
MIT License
691 stars 141 forks source link

后端消息队列可以改成接口吗 #27

Open lchjczw opened 5 years ago

lchjczw commented 5 years ago

后端消息队列可以改成接口吗,后面有些情况下,可以用其他消息队列

fanux commented 5 years ago
func (mq *Mq) Publish(key string, v MqHandler) error {
    return mq.conn.Publish(key, v)
}

func (mq *Mq) Subscribe(key string, v MqHandler) (*nats.Subscription, error) {
    return mq.conn.Subscribe(key, v)
}

/*
func (mq *Mq) Unsubscribe(sub *nats.Subscription) error {
    return sub.Unsubscribe()
}
*/

func (mq *Mq) Unsubscribe(handle interface{}) error {
    c :=handle.(*nats.Subscription)
    return c.Unsubscribe()
}

确实可以抽象成接口,有兴趣可参与这个项目进行改造