Esempio n. 1
0
func (p *MsgResponseItem) WriteResponse(buf *bufio.Writer) error {

	v := 5
	if p.msg.UnlockTs > 0 {
		v = 6
	}

	err := enc.WriteDictSize(buf, v)
	_, err = buf.WriteString(" ID ")
	err = enc.WriteString(buf, p.msg.StrId)

	_, err = buf.WriteString(" PL ")
	err = enc.WriteBytes(buf, p.payload)

	_, err = buf.WriteString(" ETS ")
	err = enc.WriteInt64(buf, p.msg.ExpireTs)

	_, err = buf.WriteString(" POPCNT ")
	err = enc.WriteInt64(buf, p.msg.PopCount)

	_, err = buf.WriteString(" UTS ")
	err = enc.WriteInt64(buf, p.msg.UnlockTs)

	if p.msg.UnlockTs > 0 {
		_, err = buf.WriteString(" RCPT ")
		_, err = buf.WriteString(enc.EncodeTo36Base(p.msg.SerialNumber))
		err = buf.WriteByte('-')
		_, err = buf.WriteString(enc.EncodeTo36Base(uint64(p.msg.PopCount)))
	}
	return err
}
Esempio n. 2
0
func (r *StrArrayResponse) WriteResponse(buf *bufio.Writer) error {
	_, err := buf.WriteString(r.header)
	_, err = buf.WriteString(" *")
	_, err = buf.WriteString(strconv.Itoa(len(r.val)))
	for _, v := range r.val {
		err = buf.WriteByte(' ')
		enc.WriteString(buf, v)
	}
	return err
}