Example #1
0
// EncodeMsg implements msgp.Encodable
func (z Attribute) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 3
	// write "Id"
	err = en.Append(0x83, 0xa2, 0x49, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Id)
	if err != nil {
		return
	}
	// write "Name"
	err = en.Append(0xa4, 0x4e, 0x61, 0x6d, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Name)
	if err != nil {
		return
	}
	// write "Value"
	err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Value)
	if err != nil {
		return
	}
	return
}
Example #2
0
// EncodeMsg implements msgp.Encodable
func (z EventHeader) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 3
	// write "message_id"
	err = en.Append(0x83, 0xaa, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Id)
	if err != nil {
		return
	}
	// write "v"
	err = en.Append(0xa1, 0x76)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Version)
	if err != nil {
		return
	}
	// write "response_to"
	err = en.Append(0xab, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x74, 0x6f)
	if err != nil {
		return err
	}
	err = en.WriteString(z.ResponseTo)
	if err != nil {
		return
	}
	return
}
// EncodeMsg implements msgp.Encodable
func (z *bitmapContainer) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 2
	// write "cardinality"
	err = en.Append(0x82, 0xab, 0x63, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.cardinality)
	if err != nil {
		return
	}
	// write "bitmap"
	err = en.Append(0xa6, 0x62, 0x69, 0x74, 0x6d, 0x61, 0x70)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.bitmap)))
	if err != nil {
		return
	}
	for zxvk := range z.bitmap {
		err = en.WriteUint64(z.bitmap[zxvk])
		if err != nil {
			return
		}
	}
	return
}
Example #4
0
// EncodeMsg implements msgp.Encodable
func (z *ServerResponse) EncodeMsg(en *msgp.Writer) (err error) {
	// array header, size 3
	err = en.Append(0x93)
	if err != nil {
		return err
	}
	if z.Header == nil {
		err = en.WriteNil()
		if err != nil {
			return
		}
	} else {
		// map header, size 3
		// write "message_id"
		err = en.Append(0x83, 0xaa, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Header.Id)
		if err != nil {
			return
		}
		// write "v"
		err = en.Append(0xa1, 0x76)
		if err != nil {
			return err
		}
		err = en.WriteInt(z.Header.Version)
		if err != nil {
			return
		}
		// write "response_to"
		err = en.Append(0xab, 0x72, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x5f, 0x74, 0x6f)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Header.ResponseTo)
		if err != nil {
			return
		}
	}
	err = en.WriteString(z.Name)
	if err != nil {
		return
	}
	err = en.WriteArrayHeader(uint32(len(z.Params)))
	if err != nil {
		return
	}
	for bzg := range z.Params {
		err = en.WriteIntf(z.Params[bzg])
		if err != nil {
			return
		}
	}
	return
}
Example #5
0
// EncodeMsg implements msgp.Encodable
func (z *Event) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 4
	// write "id"
	err = en.Append(0x84, 0xa2, 0x69, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Id)
	if err != nil {
		return
	}
	// write "user"
	// map header, size 2
	// write "first"
	err = en.Append(0xa4, 0x75, 0x73, 0x65, 0x72, 0x82, 0xa5, 0x66, 0x69, 0x72, 0x73, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.User.First)
	if err != nil {
		return
	}
	// write "last"
	err = en.Append(0xa4, 0x6c, 0x61, 0x73, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.User.Last)
	if err != nil {
		return
	}
	// write "flight"
	err = en.Append(0xa6, 0x66, 0x6c, 0x69, 0x67, 0x68, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Flight)
	if err != nil {
		return
	}
	// write "pilot"
	err = en.Append(0xa5, 0x70, 0x69, 0x6c, 0x6f, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Pilot)))
	if err != nil {
		return
	}
	for xvk := range z.Pilot {
		err = en.WriteString(z.Pilot[xvk])
		if err != nil {
			return
		}
	}
	return
}
// EncodeMsg implements msgp.Encodable
func (z *bitmapContainerShortIterator) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 2
	// write "ptr"
	err = en.Append(0x82, 0xa3, 0x70, 0x74, 0x72)
	if err != nil {
		return err
	}
	if z.ptr == nil {
		err = en.WriteNil()
		if err != nil {
			return
		}
	} else {
		// map header, size 2
		// write "cardinality"
		err = en.Append(0x82, 0xab, 0x63, 0x61, 0x72, 0x64, 0x69, 0x6e, 0x61, 0x6c, 0x69, 0x74, 0x79)
		if err != nil {
			return err
		}
		err = en.WriteInt(z.ptr.cardinality)
		if err != nil {
			return
		}
		// write "bitmap"
		err = en.Append(0xa6, 0x62, 0x69, 0x74, 0x6d, 0x61, 0x70)
		if err != nil {
			return err
		}
		err = en.WriteArrayHeader(uint32(len(z.ptr.bitmap)))
		if err != nil {
			return
		}
		for zwht := range z.ptr.bitmap {
			err = en.WriteUint64(z.ptr.bitmap[zwht])
			if err != nil {
				return
			}
		}
	}
	// write "i"
	err = en.Append(0xa1, 0x69)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.i)
	if err != nil {
		return
	}
	return
}
Example #7
0
func (r *Response) EncodeMsg(w *msgp.Writer) error {
	var bm msgp.Encodable

	if r.Body != nil {
		var ok bool
		bm, ok = r.Body.(msgp.Encodable)
		if !ok {
			return ErrNotEncodable
		}
	}

	var err error

	if err = w.WriteArrayHeader(ResponsePackSize); err != nil {
		return err
	}

	if err = w.WriteInt(ResponseType); err != nil {
		return err
	}

	if err = w.WriteUint32(r.ID); err != nil {
		return err
	}

	// No error.
	if r.Error == "" {
		if err = w.WriteNil(); err != nil {
			return err
		}

		if bm != nil {
			return msgp.Encode(w, bm)
		}
	} else {
		if err = w.WriteString(r.Error); err != nil {
			return err
		}
	}

	// Write nil body.
	return w.WriteNil()
}
Example #8
0
// EncodeMsg encodes the request to writer. The body is expected to
// be an encodable type.
func (r *Request) EncodeMsg(w *msgp.Writer) error {
	var bm msgp.Encodable

	if r.Body != nil {
		var ok bool
		bm, ok = r.Body.(msgp.Encodable)
		if !ok {
			return ErrNotEncodable
		}
	}

	var err error

	if err = w.WriteArrayHeader(RequestPackSize); err != nil {
		return err
	}

	if err = w.WriteInt(RequestType); err != nil {
		return err
	}

	if err = w.WriteUint32(r.ID); err != nil {
		return err
	}

	if err = w.WriteString(r.Method); err != nil {
		return err
	}

	// No body to encode. Write a zero-length params array.
	if bm == nil {
		return w.WriteArrayHeader(0)
	}

	// 1-item array containing the body.
	if err = w.WriteArrayHeader(1); err != nil {
		return err
	}

	return msgp.Encode(w, bm)
}
Example #9
0
// EncodeMsg implements msgp.Encodable
func (z *Packet) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 4
	// write "type"
	err = en.Append(0x84, 0xa4, 0x74, 0x79, 0x70, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteByte(z.pType)
	if err != nil {
		return
	}
	// write "id"
	err = en.Append(0xa2, 0x69, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.id)
	if err != nil {
		return
	}
	// write "event"
	err = en.Append(0xa5, 0x65, 0x76, 0x65, 0x6e, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.eventName)
	if err != nil {
		return
	}
	// write "payload"
	err = en.Append(0xa7, 0x70, 0x61, 0x79, 0x6c, 0x6f, 0x61, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteBytes(z.payload)
	if err != nil {
		return
	}
	return
}
Example #10
0
// EncodeMsg implements msgp.Encodable
func (z Date) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 3
	// write "Year"
	err = en.Append(0x83, 0xa4, 0x59, 0x65, 0x61, 0x72)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Year)
	if err != nil {
		return
	}
	// write "Month"
	err = en.Append(0xa5, 0x4d, 0x6f, 0x6e, 0x74, 0x68)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Month)
	if err != nil {
		return
	}
	// write "Day"
	err = en.Append(0xa3, 0x44, 0x61, 0x79)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Day)
	if err != nil {
		return
	}
	return
}
Example #11
0
// EncodeMsg encodes the notification to writer. The body is expected to
// be an encodable type.
func (n *Notification) EncodeMsg(w *msgp.Writer) error {
	var bm msgp.Encodable

	if n.Body != nil {
		var ok bool
		bm, ok = n.Body.(msgp.Encodable)
		if !ok {
			return ErrNotEncodable
		}
	}

	var err error

	if err = w.WriteArrayHeader(NotificationPackSize); err != nil {
		return err
	}

	if err = w.WriteInt(NotificationType); err != nil {
		return err
	}

	if err = w.WriteString(n.Method); err != nil {
		return err
	}

	// No body to encode. Write a zero-length params array.
	if bm == nil {
		return w.WriteArrayHeader(0)
	}

	// 1-item array containing the body.
	if err = w.WriteArrayHeader(1); err != nil {
		return err
	}

	return msgp.Encode(w, bm)
}
Example #12
0
// EncodeMsg implements msgp.Encodable
func (z *MetricData) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 9
	// write "OrgId"
	err = en.Append(0x89, 0xa5, 0x4f, 0x72, 0x67, 0x49, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.OrgId)
	if err != nil {
		return
	}
	// write "Name"
	err = en.Append(0xa4, 0x4e, 0x61, 0x6d, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Name)
	if err != nil {
		return
	}
	// write "Metric"
	err = en.Append(0xa6, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Metric)
	if err != nil {
		return
	}
	// write "Interval"
	err = en.Append(0xa8, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Interval)
	if err != nil {
		return
	}
	// write "Value"
	err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteFloat64(z.Value)
	if err != nil {
		return
	}
	// write "Unit"
	err = en.Append(0xa4, 0x55, 0x6e, 0x69, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Unit)
	if err != nil {
		return
	}
	// write "Time"
	err = en.Append(0xa4, 0x54, 0x69, 0x6d, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteInt64(z.Time)
	if err != nil {
		return
	}
	// write "TargetType"
	err = en.Append(0xaa, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.TargetType)
	if err != nil {
		return
	}
	// write "Tags"
	err = en.Append(0xa4, 0x54, 0x61, 0x67, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Tags)))
	if err != nil {
		return
	}
	for xvk := range z.Tags {
		err = en.WriteString(z.Tags[xvk])
		if err != nil {
			return
		}
	}
	return
}
Example #13
0
// EncodeMsg implements msgp.Encodable
func (z *MetricDefinition) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 11
	// write "Id"
	err = en.Append(0x8b, 0xa2, 0x49, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Id)
	if err != nil {
		return
	}
	// write "OrgId"
	err = en.Append(0xa5, 0x4f, 0x72, 0x67, 0x49, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.OrgId)
	if err != nil {
		return
	}
	// write "Name"
	err = en.Append(0xa4, 0x4e, 0x61, 0x6d, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Name)
	if err != nil {
		return
	}
	// write "Metric"
	err = en.Append(0xa6, 0x4d, 0x65, 0x74, 0x72, 0x69, 0x63)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Metric)
	if err != nil {
		return
	}
	// write "Interval"
	err = en.Append(0xa8, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x76, 0x61, 0x6c)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Interval)
	if err != nil {
		return
	}
	// write "Unit"
	err = en.Append(0xa4, 0x55, 0x6e, 0x69, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteString(z.Unit)
	if err != nil {
		return
	}
	// write "TargetType"
	err = en.Append(0xaa, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x54, 0x79, 0x70, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.TargetType)
	if err != nil {
		return
	}
	// write "Tags"
	err = en.Append(0xa4, 0x54, 0x61, 0x67, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Tags)))
	if err != nil {
		return
	}
	for hct := range z.Tags {
		err = en.WriteString(z.Tags[hct])
		if err != nil {
			return
		}
	}
	// write "LastUpdate"
	err = en.Append(0xaa, 0x4c, 0x61, 0x73, 0x74, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteInt64(z.LastUpdate)
	if err != nil {
		return
	}
	// write "Nodes"
	err = en.Append(0xa5, 0x4e, 0x6f, 0x64, 0x65, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteMapHeader(uint32(len(z.Nodes)))
	if err != nil {
		return
	}
	for cua, xhx := range z.Nodes {
		err = en.WriteString(cua)
		if err != nil {
			return
		}
		err = en.WriteString(xhx)
		if err != nil {
			return
		}
	}
	// write "NodeCount"
	err = en.Append(0xa9, 0x4e, 0x6f, 0x64, 0x65, 0x43, 0x6f, 0x75, 0x6e, 0x74)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.NodeCount)
	if err != nil {
		return
	}
	return
}
Example #14
0
// EncodeMsg implements msgp.Encodable
func (z *Car) EncodeMsg(en *msgp.Writer) (err error) {
	// map header, size 5
	// write "CarId"
	err = en.Append(0x85, 0xa5, 0x43, 0x61, 0x72, 0x49, 0x64)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.CarId)
	if err != nil {
		return
	}
	// write "CarName"
	err = en.Append(0xa7, 0x43, 0x61, 0x72, 0x4e, 0x61, 0x6d, 0x65)
	if err != nil {
		return err
	}
	err = en.WriteString(z.CarName)
	if err != nil {
		return
	}
	// write "Attributes"
	err = en.Append(0xaa, 0x41, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73)
	if err != nil {
		return err
	}
	err = en.WriteArrayHeader(uint32(len(z.Attributes)))
	if err != nil {
		return
	}
	for bai := range z.Attributes {
		// map header, size 3
		// write "Id"
		err = en.Append(0x83, 0xa2, 0x49, 0x64)
		if err != nil {
			return err
		}
		err = en.WriteInt(z.Attributes[bai].Id)
		if err != nil {
			return
		}
		// write "Name"
		err = en.Append(0xa4, 0x4e, 0x61, 0x6d, 0x65)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Attributes[bai].Name)
		if err != nil {
			return
		}
		// write "Value"
		err = en.Append(0xa5, 0x56, 0x61, 0x6c, 0x75, 0x65)
		if err != nil {
			return err
		}
		err = en.WriteString(z.Attributes[bai].Value)
		if err != nil {
			return
		}
	}
	// write "FlagMap"
	err = en.Append(0xa7, 0x46, 0x6c, 0x61, 0x67, 0x4d, 0x61, 0x70)
	if err != nil {
		return err
	}
	err = en.WriteMapHeader(uint32(len(z.FlagMap)))
	if err != nil {
		return
	}
	for cmr, ajw := range z.FlagMap {
		err = en.WriteString(cmr)
		if err != nil {
			return
		}
		err = en.WriteString(ajw)
		if err != nil {
			return
		}
	}
	// write "Ttl"
	err = en.Append(0xa3, 0x54, 0x74, 0x6c)
	if err != nil {
		return err
	}
	err = en.WriteInt(z.Ttl)
	if err != nil {
		return
	}
	return
}
Example #15
0
// EncodeMsg implements msgp.Encodable
func (z *Incident) EncodeMsg(en *msgp.Writer) (err error) {
	err = en.WriteMapHeader(9)
	if err != nil {
		return
	}
	err = en.WriteString("event_name")
	if err != nil {
		return
	}
	err = en.WriteBytes(z.EventName)
	if err != nil {
		return
	}
	err = en.WriteString("time")
	if err != nil {
		return
	}
	err = en.WriteInt64(z.Time)
	if err != nil {
		return
	}
	err = en.WriteString("id")
	if err != nil {
		return
	}
	err = en.WriteInt64(z.Id)
	if err != nil {
		return
	}
	err = en.WriteString("active")
	if err != nil {
		return
	}
	err = en.WriteBool(z.Active)
	if err != nil {
		return
	}
	err = en.WriteString("escalation")
	if err != nil {
		return
	}
	err = en.WriteString(z.Escalation)
	if err != nil {
		return
	}
	err = en.WriteString("description")
	if err != nil {
		return
	}
	err = en.WriteString(z.Description)
	if err != nil {
		return
	}
	err = en.WriteString("policy")
	if err != nil {
		return
	}
	err = en.WriteString(z.Policy)
	if err != nil {
		return
	}
	err = en.WriteString("Status")
	if err != nil {
		return
	}
	err = en.WriteInt(z.Status)
	if err != nil {
		return
	}
	err = en.WriteString("Event")
	if err != nil {
		return
	}
	err = z.Event.EncodeMsg(en)
	if err != nil {
		return
	}
	return
}