本文整理汇总了Golang中github.com/absolute8511/nsq/nsqd.ClientV2.IncrSubError方法的典型用法代码示例。如果您正苦于以下问题:Golang ClientV2.IncrSubError方法的具体用法?Golang ClientV2.IncrSubError怎么用?Golang ClientV2.IncrSubError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/absolute8511/nsq/nsqd.ClientV2
的用法示例。
在下文中一共展示了ClientV2.IncrSubError方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: FIN
func (p *protocolV2) FIN(client *nsqd.ClientV2, params [][]byte) ([]byte, error) {
state := atomic.LoadInt32(&client.State)
if state != stateSubscribed && state != stateClosing {
nsqd.NsqLogger().LogWarningf("[%s] command in wrong state: %v", client, state)
return nil, protocol.NewFatalClientErr(nil, E_INVALID, "cannot FIN in current state")
}
if len(params) < 2 {
nsqd.NsqLogger().LogDebugf("FIN error params: %v", params)
return nil, protocol.NewFatalClientErr(nil, E_INVALID, "FIN insufficient number of params")
}
id, err := getFullMessageID(params[1])
if err != nil {
nsqd.NsqLogger().LogDebugf("FIN error: %v, %v", params[1], err)
return nil, protocol.NewFatalClientErr(nil, E_INVALID, err.Error())
}
msgID := nsqd.GetMessageIDFromFullMsgID(*id)
if int64(msgID) <= 0 {
return nil, protocol.NewFatalClientErr(nil, E_INVALID, "Invalid Message ID")
}
if client.Channel == nil {
nsqd.NsqLogger().LogDebugf("FIN error no channel: %v", msgID)
return nil, protocol.NewFatalClientErr(nil, E_INVALID, "No channel")
}
if !p.ctx.checkForMasterWrite(client.Channel.GetTopicName(), client.Channel.GetTopicPart()) {
nsqd.NsqLogger().Logf("topic %v fin message failed for not leader", client.Channel.GetTopicName())
return nil, protocol.NewFatalClientErr(nil, FailedOnNotLeader, "")
}
err = p.ctx.FinishMessage(client.Channel, client.ID, client.String(), msgID)
if err != nil {
client.IncrSubError(int64(1))
nsqd.NsqLogger().LogDebugf("FIN error : %v, err: %v, channel: %v, topic: %v", msgID,
err, client.Channel.GetName(), client.Channel.GetTopicName())
if clusterErr, ok := err.(*consistence.CommonCoordErr); ok {
if !clusterErr.IsLocalErr() {
return nil, protocol.NewFatalClientErr(err, FailedOnNotWritable, "")
}
}
return nil, protocol.NewClientErr(err, "E_FIN_FAILED",
fmt.Sprintf("FIN %v failed %s", *id, err.Error()))
}
client.FinishedMessage()
return nil, nil
}
示例2: REQ
func (p *protocolV2) REQ(client *nsqd.ClientV2, params [][]byte) ([]byte, error) {
state := atomic.LoadInt32(&client.State)
if state != stateSubscribed && state != stateClosing {
nsqd.NsqLogger().LogWarningf("[%s] command in wrong state: %v", client, state)
return nil, protocol.NewFatalClientErr(nil, E_INVALID, "cannot REQ in current state")
}
if len(params) < 3 {
return nil, protocol.NewFatalClientErr(nil, E_INVALID, "REQ insufficient number of params")
}
id, err := getFullMessageID(params[1])
if err != nil {
return nil, protocol.NewFatalClientErr(nil, E_INVALID, err.Error())
}
timeoutMs, err := protocol.ByteToBase10(params[2])
if err != nil {
return nil, protocol.NewFatalClientErr(err, E_INVALID,
fmt.Sprintf("REQ could not parse timeout %s", params[2]))
}
timeoutDuration := time.Duration(timeoutMs) * time.Millisecond
if timeoutDuration < 0 || timeoutDuration > p.ctx.getOpts().MaxReqTimeout {
return nil, protocol.NewFatalClientErr(nil, E_INVALID,
fmt.Sprintf("REQ timeout %v out of range 0-%v", timeoutDuration, p.ctx.getOpts().MaxReqTimeout))
}
if client.Channel == nil {
return nil, protocol.NewFatalClientErr(nil, E_INVALID, "No channel")
}
err = client.Channel.RequeueMessage(client.ID, client.String(), nsqd.GetMessageIDFromFullMsgID(*id), timeoutDuration, true)
if err != nil {
client.IncrSubError(int64(1))
return nil, protocol.NewClientErr(err, "E_REQ_FAILED",
fmt.Sprintf("REQ %v failed %s", *id, err.Error()))
}
client.RequeuedMessage(timeoutDuration > 0)
return nil, nil
}