The QosFailure will never return to client
The Subscribe function in memtopics.go message.QosFailure always whith some err.
https://github.com/influxdata/surgemq/blob/master/topics/memtopics.go#L61
func (this *memTopics) Subscribe(topic []byte, qos byte, sub interface{}) (byte, error) {
if !message.ValidQos(qos) {
return message.QosFailure, fmt.Errorf("Invalid QoS %d", qos)
}
if sub == nil {
return message.QosFailure, fmt.Errorf("Subscriber cannot be nil")
}
this.smu.Lock()
defer this.smu.Unlock()
if qos > MaxQosAllowed {
qos = MaxQosAllowed
}
if err := this.sroot.sinsert(topic, qos, sub); err != nil {
return message.QosFailure, err
}
return qos, nil
}
But the processSubscribe function in process.go ,when Subscribe return err QosFailure will not append into retcodes but function return
https://github.com/influxdata/surgemq/blob/master/service/process.go#L315
for i, t := range topics {
rqos, err := this.topicsMgr.Subscribe(t, qos[i], &this.onpub)
if err != nil {
return err
}
this.sess.AddTopic(string(t), qos[i])
retcodes = append(retcodes, rqos)
// yeah I am not checking errors here. If there's an error we don't want the
// subscription to stop, just let it go.
this.topicsMgr.Retained(t, &this.rmsgs)
glog.Debugf("(%s) topic = %s, retained count = %d", this.cid(), string(t), len(this.rmsgs))
}