예제 #1
0
// DecodeMsg implements msgp.Decodable
func (z *Foo) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "bar":
			z.Bar, err = dc.ReadString()
			if err != nil {
				return
			}
		case "baz":
			z.Baz, err = dc.ReadFloat64()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #2
0
// DecodeMsg implements msgp.Decodable
func (z *Message) DecodeMsg(dc *msgp.Reader) (err error) {
	var ssz uint32
	ssz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if ssz != 4 {
		err = msgp.ArrayError{Wanted: 4, Got: ssz}
		return
	}
	z.Tag, err = dc.ReadString()
	if err != nil {
		return
	}
	z.Time, err = dc.ReadInt64()
	if err != nil {
		return
	}
	z.Record, err = dc.ReadIntf()
	if err != nil {
		return
	}
	z.Option, err = dc.ReadIntf()
	if err != nil {
		return
	}
	return
}
예제 #3
0
파일: main_gen.go 프로젝트: sztanpet/bimpc
// DecodeMsg implements msgp.Decodable
func (z *Incoming) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "from":
			z.From, err = dc.ReadString()
			if err != nil {
				return
			}
		case "message":
			z.Message, err = dc.ReadString()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #4
0
// DecodeMsg implements msgp.Decodable
func (z *Person) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "first":
			z.First, err = dc.ReadString()
			if err != nil {
				return
			}
		case "last":
			z.Last, err = dc.ReadString()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #5
0
// DecodeMsg implements msgp.Decodable
func (z *interval32) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zeff uint32
	zeff, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zeff > 0 {
		zeff--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "start":
			z.start, err = dc.ReadUint32()
			if err != nil {
				return
			}
		case "last":
			z.last, err = dc.ReadUint32()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #6
0
파일: rpc.go 프로젝트: micro/go-plugins
func (r *Request) DecodeMsg(mr *msgp.Reader) error {
	var bm msgp.Decodable

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

	if size, err := mr.ReadArrayHeader(); err != nil {
		return err
	} else if size != RequestPackSize {
		return ErrBadPackSize
	}

	if typ, err := mr.ReadInt(); err != nil {
		return err
	} else if typ != RequestType {
		return ErrBadMessageType
	}

	id, err := mr.ReadUint32()
	if err != nil {
		return err
	}

	r.ID = id

	method, err := mr.ReadString()
	if err != nil {
		return err
	}

	r.Method = method

	// The request body is packed in an array.
	l, err := mr.ReadArrayHeader()
	if err != nil {
		return err
	}

	if l > 1 {
		return ErrUnexpectedParams
	} else if l == 0 {
		return nil
	}

	r.hasBody = true

	// Skip decoding the body if no value is present to decode into.
	// The caller is expected to decode the body or skip it.
	if bm != nil {
		return decodeBody(mr, bm)
	}

	return nil
}
예제 #7
0
// DecodeMsg implements msgp.Decodable
func (z *Ztype) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var zgmo int32
		zgmo, err = dc.ReadInt32()
		(*z) = Ztype(zgmo)
	}
	if err != nil {
		return
	}
	return
}
예제 #8
0
// DecodeMsg implements msgp.Decodable
func (z *Binary) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var tmp []byte
		tmp, err = dc.ReadBytes([]byte((*z)))
		(*z) = Binary(tmp)
	}
	if err != nil {
		return
	}
	return
}
예제 #9
0
// DecodeMsg implements msgp.Decodable
func (z *contype) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var zajw uint8
		zajw, err = dc.ReadUint8()
		(*z) = contype(zajw)
	}
	if err != nil {
		return
	}
	return
}
// DecodeMsg implements msgp.Decodable
func (z *DocumentID) DecodeMsg(dc *msgp.Reader) (err error) {
	{
		var tmp uint
		tmp, err = dc.ReadUint()
		(*z) = DocumentID(tmp)
	}
	if err != nil {
		return
	}
	return
}
예제 #11
0
func (d *initialDispatch) Handle(id uint64, r *msgp.Reader) (Dispatcher, error) {
	var err error
	switch id {
	case spool:
		var opts = make(Profile)
		var name string

		if err = checkSize(_onSpoolArgsNum, r); err != nil {
			return nil, err
		}

		if err = r.ReadMapStrIntf(opts); err != nil {
			return nil, err
		}

		if name, err = r.ReadString(); err != nil {
			return nil, err
		}

		return d.onSpool(opts, name)
	case spawn:
		var (
			opts             = make(Profile)
			name, executable string
			args             = make(map[string]string)
			env              = make(map[string]string)
		)
		if err = checkSize(_onSpawnArgsNum, r); err != nil {
			return nil, err
		}

		if err = r.ReadMapStrIntf(opts); err != nil {
			return nil, err
		}
		if name, err = r.ReadString(); err != nil {
			return nil, err
		}
		if executable, err = r.ReadString(); err != nil {
			return nil, err
		}

		if err = readMapStrStr(r, args); err != nil {
			return nil, err
		}

		if err = readMapStrStr(r, env); err != nil {
			return nil, err
		}

		return d.onSpawn(opts, name, executable, args, env)
	default:
		return nil, fmt.Errorf("unknown transition id: %d", id)
	}
}
예제 #12
0
func (d *spawnDispatch) Handle(id int64, r *msgp.Reader) (Dispatcher, error) {
	switch id {
	case spawnKill:
		r.Skip()
		go d.asyncKill()
		// NOTE: do not return an err on purpose
		return nil, nil
	default:
		return nil, fmt.Errorf("unknown transition id: %d", id)
	}
}
예제 #13
0
func checkSize(num uint32, r *msgp.Reader) error {
	size, err := r.ReadArrayHeader()
	if err != nil {
		return err
	}

	if size != num {
		return ErrInvalidArgsNum
	}

	return nil
}
예제 #14
0
// DecodeMsg implements msgp.Decodable
func (z *StructInstance) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zqke uint32
	zqke, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zqke > 0 {
		zqke--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "StructId":
			z.StructId, err = dc.ReadInt64()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #15
0
func (s *spoolCancelationDispatch) Handle(id uint64, r *msgp.Reader) (Dispatcher, error) {
	switch id {
	case spoolCancel:
		// Skip empty array
		apexctx.GetLogger(s.ctx).Debug("Spool.Cancel()")
		r.Skip()
		// TODO: cancel only if I'm spooling
		s.cancel()
		// NOTE: do not return an err on purpose
		s.stream.Close(s.ctx, replySpoolOk)
		return nil, nil
	default:
		return nil, fmt.Errorf("unknown transition id: %d", id)
	}
}
예제 #16
0
// DecodeMsg implements msgp.Decodable
func (z *uint32Slice) DecodeMsg(dc *msgp.Reader) (err error) {
	var zjpj uint32
	zjpj, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if cap((*z)) >= int(zjpj) {
		(*z) = (*z)[:zjpj]
	} else {
		(*z) = make(uint32Slice, zjpj)
	}
	for zywj := range *z {
		(*z)[zywj], err = dc.ReadUint32()
		if err != nil {
			return
		}
	}
	return
}
예제 #17
0
// DecodeMsg implements msgp.Decodable
func (z *arrayContainer) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zbzg uint32
	zbzg, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zbzg > 0 {
		zbzg--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "content":
			var zbai uint32
			zbai, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.content) >= int(zbai) {
				z.content = (z.content)[:zbai]
			} else {
				z.content = make([]uint16, zbai)
			}
			for zxvk := range z.content {
				z.content[zxvk], err = dc.ReadUint16()
				if err != nil {
					return
				}
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #18
0
// DecodeMsg implements msgp.Decodable
func (z *MetricDataArray) DecodeMsg(dc *msgp.Reader) (err error) {
	var xsz uint32
	xsz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(MetricDataArray, xsz)
	}
	for bai := range *z {
		if dc.IsNil() {
			err = dc.ReadNil()
			if err != nil {
				return
			}
			(*z)[bai] = nil
		} else {
			if (*z)[bai] == nil {
				(*z)[bai] = new(MetricData)
			}
			err = (*z)[bai].DecodeMsg(dc)
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #19
0
// DecodeMsg implements msgp.Decodable
func (z *KVs) DecodeMsg(dc *msgp.Reader) (err error) {
	var xsz uint32
	xsz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(KVs, xsz)
	}
	for cmr := range *z {
		var asz uint32
		asz, err = dc.ReadArrayHeader()
		if err != nil {
			return
		}
		if asz != 2 {
			err = msgp.ArrayError{Wanted: 2, Got: asz}
			return
		}
		for ajw := range (*z)[cmr] {
			{
				var tmp []byte
				tmp, err = dc.ReadBytes([]byte((*z)[cmr][ajw]))
				(*z)[cmr][ajw] = Binary(tmp)
			}
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #20
0
// DecodeMsg implements msgp.Decodable
func (z *KV) DecodeMsg(dc *msgp.Reader) (err error) {
	var asz uint32
	asz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if asz != 2 {
		err = msgp.ArrayError{Wanted: 2, Got: asz}
		return
	}
	for xvk := range z {
		{
			var tmp []byte
			tmp, err = dc.ReadBytes([]byte(z[xvk]))
			z[xvk] = Binary(tmp)
		}
		if err != nil {
			return
		}
	}
	return
}
// DecodeMsg implements msgp.Decodable
func (z *DocumentList) DecodeMsg(dc *msgp.Reader) (err error) {
	var xsz uint32
	xsz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(DocumentList, xsz)
	}
	for bzg := range *z {
		{
			var tmp uint
			tmp, err = dc.ReadUint()
			(*z)[bzg] = DocumentID(tmp)
		}
		if err != nil {
			return
		}
	}
	return
}
예제 #22
0
// DecodeMsg implements msgp.Decodable
func (z *Ks) DecodeMsg(dc *msgp.Reader) (err error) {
	var xsz uint32
	xsz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if cap((*z)) >= int(xsz) {
		(*z) = (*z)[:xsz]
	} else {
		(*z) = make(Ks, xsz)
	}
	for jfb := range *z {
		{
			var tmp []byte
			tmp, err = dc.ReadBytes([]byte((*z)[jfb]))
			(*z)[jfb] = Binary(tmp)
		}
		if err != nil {
			return
		}
	}
	return
}
예제 #23
0
// DecodeMsg implements msgp.Decodable
func (z *containerSerz) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var zxvk uint32
	zxvk, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for zxvk > 0 {
		zxvk--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "t":
			{
				var zbzg uint8
				zbzg, err = dc.ReadUint8()
				z.t = contype(zbzg)
			}
			if err != nil {
				return
			}
		case "r":
			err = z.r.DecodeMsg(dc)
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #24
0
func (h *ConnectionHandler) next(r *msgp.Reader) (hasHeaders bool, channel uint64, c uint64, err error) {
	var sz uint32
	sz, err = r.ReadArrayHeader()
	if err != nil {
		return
	}
	hasHeaders = sz == 4

	channel, err = r.ReadUint64()
	if err != nil {
		return
	}

	c, err = r.ReadUint64()
	if err != nil {
		return
	}

	return
}
예제 #25
0
// DecodeMsg implements msgp.Decodable
func (z *Entry) DecodeMsg(dc *msgp.Reader) (err error) {
	var ssz uint32
	ssz, err = dc.ReadArrayHeader()
	if err != nil {
		return
	}
	if ssz != 2 {
		err = msgp.ArrayError{Wanted: 2, Got: ssz}
		return
	}
	z.Time, err = dc.ReadInt64()
	if err != nil {
		return
	}
	z.Record, err = dc.ReadIntf()
	if err != nil {
		return
	}
	return
}
예제 #26
0
func readMapStrStr(r *msgp.Reader, mp map[string]string) (err error) {
	var sz uint32
	sz, err = r.ReadMapHeader()
	if err != nil {
		return err
	}

	for i := uint32(0); i < sz; i++ {
		var key string
		var val string
		key, err = r.ReadString()
		if err != nil {
			return err
		}
		val, err = r.ReadString()
		if err != nil {
			return err
		}
		mp[key] = val
	}

	return
}
예제 #27
0
// DecodeMsg implements msgp.Decodable
func (z *ProbeEvent) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "Id":
			z.Id, err = dc.ReadString()
			if err != nil {
				return
			}
		case "EventType":
			z.EventType, err = dc.ReadString()
			if err != nil {
				return
			}
		case "OrgId":
			z.OrgId, err = dc.ReadInt64()
			if err != nil {
				return
			}
		case "Severity":
			z.Severity, err = dc.ReadString()
			if err != nil {
				return
			}
		case "Source":
			z.Source, err = dc.ReadString()
			if err != nil {
				return
			}
		case "Timestamp":
			z.Timestamp, err = dc.ReadInt64()
			if err != nil {
				return
			}
		case "Message":
			z.Message, err = dc.ReadString()
			if err != nil {
				return
			}
		case "Tags":
			var msz uint32
			msz, err = dc.ReadMapHeader()
			if err != nil {
				return
			}
			if z.Tags == nil && msz > 0 {
				z.Tags = make(map[string]string, msz)
			} else if len(z.Tags) > 0 {
				for key, _ := range z.Tags {
					delete(z.Tags, key)
				}
			}
			for msz > 0 {
				msz--
				var xvk string
				var bzg string
				xvk, err = dc.ReadString()
				if err != nil {
					return
				}
				bzg, err = dc.ReadString()
				if err != nil {
					return
				}
				z.Tags[xvk] = bzg
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #28
0
// DecodeMsg implements msgp.Decodable
func (z *Person) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "Name":
			z.Name, err = dc.ReadString()
			if err != nil {
				return
			}
		case "Age":
			z.Age, err = dc.ReadUint8()
			if err != nil {
				return
			}
		case "Height":
			z.Height, err = dc.ReadFloat64()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #29
0
// DecodeMsg implements msgp.Decodable
func (z *Group) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "Name":
			z.Name, err = dc.ReadString()
			if err != nil {
				return
			}
		case "Members":
			var xsz uint32
			xsz, err = dc.ReadArrayHeader()
			if err != nil {
				return
			}
			if cap(z.Members) >= int(xsz) {
				z.Members = z.Members[:xsz]
			} else {
				z.Members = make([]Person, xsz)
			}
			for xvk := range z.Members {
				var isz uint32
				isz, err = dc.ReadMapHeader()
				if err != nil {
					return
				}
				for isz > 0 {
					isz--
					field, err = dc.ReadMapKeyPtr()
					if err != nil {
						return
					}
					switch msgp.UnsafeString(field) {
					case "Name":
						z.Members[xvk].Name, err = dc.ReadString()
						if err != nil {
							return
						}
					case "Age":
						z.Members[xvk].Age, err = dc.ReadUint8()
						if err != nil {
							return
						}
					case "Height":
						z.Members[xvk].Height, err = dc.ReadFloat64()
						if err != nil {
							return
						}
					default:
						err = dc.Skip()
						if err != nil {
							return
						}
					}
				}
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}
예제 #30
0
// DecodeMsg implements msgp.Decodable
func (z *A) DecodeMsg(dc *msgp.Reader) (err error) {
	var field []byte
	_ = field
	var isz uint32
	isz, err = dc.ReadMapHeader()
	if err != nil {
		return
	}
	for isz > 0 {
		isz--
		field, err = dc.ReadMapKeyPtr()
		if err != nil {
			return
		}
		switch msgp.UnsafeString(field) {
		case "Name":
			z.Name, err = dc.ReadString()
			if err != nil {
				return
			}
		case "BirthDay":
			z.BirthDay, err = dc.ReadInt64()
			if err != nil {
				return
			}
		case "Phone":
			z.Phone, err = dc.ReadString()
			if err != nil {
				return
			}
		case "Siblings":
			z.Siblings, err = dc.ReadInt64()
			if err != nil {
				return
			}
		case "Spouse":
			z.Spouse, err = dc.ReadUint8()
			if err != nil {
				return
			}
		case "Money":
			z.Money, err = dc.ReadFloat64()
			if err != nil {
				return
			}
		default:
			err = dc.Skip()
			if err != nil {
				return
			}
		}
	}
	return
}