Beispiel #1
0
func (self *RequestBson) MarshalBson(buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodePrefix(buf, bson.Binary, "ServiceMethod")
	bson.EncodeString(buf, self.ServiceMethod)

	bson.EncodePrefix(buf, bson.Long, "Seq")
	bson.EncodeUint64(buf, uint64(self.Seq))

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Beispiel #2
0
func MarshalFieldBson(self mysql.Field, buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodePrefix(buf, bson.Binary, "Name")
	bson.EncodeString(buf, self.Name)

	bson.EncodePrefix(buf, bson.Long, "Type")
	bson.EncodeUint64(buf, uint64(self.Type))

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Beispiel #3
0
func (self *QueryResult) encodeRowBson(row []interface{}, buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)
	for i, v := range row {
		if v == nil {
			bson.EncodePrefix(buf, bson.Null, bson.Itoa(i))
		} else {
			bson.EncodePrefix(buf, bson.Binary, bson.Itoa(i))
			bson.EncodeString(buf, v.(string))
		}
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Beispiel #4
0
func (self *Session) MarshalBson(buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodePrefix(buf, bson.Long, "TransactionId")
	bson.EncodeUint64(buf, uint64(self.TransactionId))

	bson.EncodePrefix(buf, bson.Long, "ConnectionId")
	bson.EncodeUint64(buf, uint64(self.ConnectionId))

	bson.EncodePrefix(buf, bson.Long, "SessionId")
	bson.EncodeUint64(buf, uint64(self.SessionId))

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Beispiel #5
0
func (self *QueryResult) encodeFieldsBson(buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)
	for i, v := range self.Fields {
		bson.EncodePrefix(buf, bson.Object, bson.Itoa(i))
		MarshalFieldBson(v, buf)
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Beispiel #6
0
func (self *QueryResult) MarshalBson(buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodePrefix(buf, bson.Array, "Fields")
	self.encodeFieldsBson(buf)

	bson.EncodePrefix(buf, bson.Long, "RowsAffected")
	bson.EncodeUint64(buf, uint64(self.RowsAffected))

	bson.EncodePrefix(buf, bson.Long, "InsertId")
	bson.EncodeUint64(buf, uint64(self.InsertId))

	bson.EncodePrefix(buf, bson.Array, "Rows")
	self.encodeRowsBson(buf)

	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Beispiel #7
0
func (self *QueryResult) encodeRowsBson(buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)
	for i, v := range self.Rows {
		bson.EncodePrefix(buf, bson.Array, bson.Itoa(i))
		self.encodeRowBson(v, buf)
	}
	buf.WriteByte(0)
	lenWriter.RecordLen()
}
Beispiel #8
0
func (self *Query) MarshalBson(buf *bytes.Buffer) {
	lenWriter := bson.NewLenWriter(buf)

	bson.EncodePrefix(buf, bson.Binary, "Sql")
	bson.EncodeString(buf, self.Sql)

	bson.EncodePrefix(buf, bson.Object, "BindVariables")
	self.encodeBindVariablesBson(buf)

	bson.EncodePrefix(buf, bson.Long, "TransactionId")
	bson.EncodeUint64(buf, uint64(self.TransactionId))

	bson.EncodePrefix(buf, bson.Long, "ConnectionId")
	bson.EncodeUint64(buf, uint64(self.ConnectionId))

	bson.EncodePrefix(buf, bson.Long, "SessionId")
	bson.EncodeUint64(buf, uint64(self.SessionId))

	buf.WriteByte(0)
	lenWriter.RecordLen()
}