// MarshalBson bson-encodes ZkNode. func (zkNode *ZkNode) MarshalBson(buf *bytes2.ChunkedWriter, key string) { bson.EncodeOptionalPrefix(buf, bson.Object, key) lenWriter := bson.NewLenWriter(buf) bson.EncodeString(buf, "Path", zkNode.Path) bson.EncodeString(buf, "Data", zkNode.Data) zkNode.Stat.MarshalBson(buf, "Stat") // []string { bson.EncodePrefix(buf, bson.Array, "Children") lenWriter := bson.NewLenWriter(buf) for _i, _v1 := range zkNode.Children { bson.EncodeString(buf, bson.Itoa(_i), _v1) } lenWriter.Close() } bson.EncodeBool(buf, "Cached", zkNode.Cached) bson.EncodeBool(buf, "Stale", zkNode.Stale) lenWriter.Close() }
// MarshalBson bson-encodes MyType. func (myType *MyType) MarshalBson(buf *bytes2.ChunkedWriter, key string) { bson.EncodeOptionalPrefix(buf, bson.Object, key) lenWriter := bson.NewLenWriter(buf) bson.EncodeFloat64(buf, "Float64", myType.Float64) bson.EncodeString(buf, "String", myType.String) bson.EncodeBool(buf, "Bool", myType.Bool) bson.EncodeInt64(buf, "Int64", myType.Int64) bson.EncodeInt32(buf, "Int32", myType.Int32) bson.EncodeInt(buf, "Int", myType.Int) bson.EncodeUint64(buf, "Uint64", myType.Uint64) bson.EncodeUint32(buf, "Uint32", myType.Uint32) bson.EncodeUint(buf, "Uint", myType.Uint) bson.EncodeBinary(buf, "Bytes", myType.Bytes) bson.EncodeTime(buf, "Time", myType.Time) bson.EncodeInterface(buf, "Interface", myType.Interface) lenWriter.Close() }
// MarshalBson bson-encodes Session. func (session *Session) MarshalBson(buf *bytes2.ChunkedWriter, key string) { bson.EncodeOptionalPrefix(buf, bson.Object, key) lenWriter := bson.NewLenWriter(buf) bson.EncodeBool(buf, "InTransaction", session.InTransaction) // []*ShardSession { bson.EncodePrefix(buf, bson.Array, "ShardSessions") lenWriter := bson.NewLenWriter(buf) for _i, _v1 := range session.ShardSessions { // *ShardSession if _v1 == nil { bson.EncodePrefix(buf, bson.Null, bson.Itoa(_i)) } else { (*_v1).MarshalBson(buf, bson.Itoa(_i)) } } lenWriter.Close() } lenWriter.Close() }