Skip to content

Commit e3ed24c

Browse files
committed
feat(arrow, datetime, decimal, uuid): add support for go-option
Add support for `go-option` to the `arrow`, `datetime`, `decimal`, and `uuid` packages. This allows for handling optional values of the `Arrow`, `Datetime`, `Interval`, `Decimal`, and `UUID` types. The following changes have been made: - Added `go:generate` directives to the `Arrow`, `Datetime`, `Interval`, `Decimal`, and `UUID` types to generate optional types using `github.com/tarantool/go-option/cmd/gentypes`. - Implemented `MarshalMsgpack` and `UnmarshalMsgpack` methods for the `Arrow`, `Datetime`, `Interval`, and `Decimal` types. - Added `marshalUUID` and `unmarshalUUID` functions for the `UUID` type. - The generated `_gen.go` files contain the `Optional*` types that wrap the original types and provide methods to handle optional values, including `EncodeMsgpack` and `DecodeMsgpack` for `msgpack` serialization. - Refactored the `datetime` and `decimal` decoders to use the new `UnmarshalMsgpack` methods.
1 parent 12cb834 commit e3ed24c

File tree

12 files changed

+1482
-183
lines changed

12 files changed

+1482
-183
lines changed

arrow/arrow.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"github.com/vmihailenco/msgpack/v5"
88
)
99

10+
//go:generate go run github.com/tarantool/go-option/cmd/gentypes -ext-code 8 Arrow
11+
1012
// Arrow MessagePack extension type.
1113
const arrowExtId = 8
1214

@@ -26,6 +28,15 @@ func (a Arrow) Raw() []byte {
2628
return a.data
2729
}
2830

31+
func (a Arrow) MarshalMsgpack() ([]byte, error) {
32+
return a.data, nil
33+
}
34+
35+
func (a *Arrow) UnmarshalMsgpack(data []byte) error {
36+
a.data = data
37+
return nil
38+
}
39+
2940
func arrowDecoder(d *msgpack.Decoder, v reflect.Value, extLen int) error {
3041
arrow := Arrow{
3142
data: make([]byte, extLen),

arrow/arrow_gen.go

Lines changed: 241 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)