@@ -2,6 +2,7 @@ package crud
22
33import (
44 "github.com/vmihailenco/msgpack/v5"
5+ "github.com/tarantool/go-option"
56)
67
78const (
@@ -27,25 +28,25 @@ const (
2728)
2829
2930// OptUint is an optional uint. Old local optional type.
30- type OptUint struct {
31+ /* type OptUint struct {
3132 value uint
3233 exist bool
33- }
34+ } */
3435
3536// MakeOptUint creates an optional uint from value.
36- func MakeOptUint (value uint ) OptUint {
37+ /* func MakeOptUint(value uint) OptUint {
3738 return OptUint{
3839 value: value,
3940 exist: true,
4041 }
41- }
42+ } */
4243
43- // Get returns the integer value or an error if not present.
44+ /* / / Get returns the integer value or an error if not present.
4445func (opt OptUint) Get() (uint, bool) {
45- return opt .value , opt .exist
46+ return opt.value, opt.exist // Method Get() from go-options is same.
4647}
47-
48- // OptInt is an optional int.
48+ */
49+ /* / / OptInt is an optional int.
4950type OptInt struct {
5051 value int
5152 exist bool
@@ -119,10 +120,10 @@ func MakeOptBool(value bool) OptBool {
119120// Get returns the boolean value or an error if not present.
120121func (opt OptBool) Get() (bool, bool) {
121122 return opt.value, opt.exist
122- }
123+ } */
123124
124125// OptTuple is an optional tuple.
125- type OptTuple struct {
126+ /* type OptTuple struct {
126127 tuple interface{}
127128}
128129
@@ -135,15 +136,18 @@ func MakeOptTuple(tuple interface{}) OptTuple {
135136func (o *OptTuple) Get() (interface{}, bool) {
136137 return o.tuple, o.tuple != nil
137138}
139+ */
138140
141+ // Defining an alias for Generic[interface{}] to replace OptTuple
142+ type OptAny = option.Generic [interface {}]
139143// BaseOpts describes base options for CRUD operations.
140144type BaseOpts struct {
141145 // Timeout is a `vshard.call` timeout and vshard
142146 // master discovery timeout (in seconds).
143- Timeout OptFloat64
147+ Timeout option. Float64
144148 // VshardRouter is cartridge vshard group name or
145149 // vshard router instance.
146- VshardRouter OptString
150+ VshardRouter option. String
147151}
148152
149153// EncodeMsgpack provides custom msgpack encoder.
@@ -164,22 +168,22 @@ func (opts BaseOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
164168type SimpleOperationOpts struct {
165169 // Timeout is a `vshard.call` timeout and vshard
166170 // master discovery timeout (in seconds).
167- Timeout OptFloat64
171+ Timeout option. Float64
168172 // VshardRouter is cartridge vshard group name or
169173 // vshard router instance.
170- VshardRouter OptString
174+ VshardRouter option. String
171175 // Fields is field names for getting only a subset of fields.
172- Fields OptTuple
176+ Fields OptAny
173177 // BucketId is a bucket ID.
174- BucketId OptUint
178+ BucketId option. Uint64
175179 // FetchLatestMetadata guarantees the up-to-date metadata (space format)
176180 // in first return value, otherwise it may not take into account
177181 // the latest migration of the data format. Performance overhead is up to 15%.
178182 // Disabled by default.
179- FetchLatestMetadata OptBool
183+ FetchLatestMetadata option. Bool
180184 // Noreturn suppresses successfully processed data (first return value is `nil`).
181185 // Disabled by default.
182- Noreturn OptBool
186+ Noreturn option. Bool
183187}
184188
185189// EncodeMsgpack provides custom msgpack encoder.
@@ -191,7 +195,7 @@ func (opts SimpleOperationOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
191195 noreturnOptName }
192196 values := [optsCnt ]interface {}{}
193197 exists := [optsCnt ]bool {}
194- values [0 ], exists [0 ] = opts .Timeout .Get ()
198+ values [0 ], exists [0 ] = opts .Timeout .Get () // Method Get() from go-options is same.
195199 values [1 ], exists [1 ] = opts .VshardRouter .Get ()
196200 values [2 ], exists [2 ] = opts .Fields .Get ()
197201 values [3 ], exists [3 ] = opts .BucketId .Get ()
@@ -206,25 +210,25 @@ func (opts SimpleOperationOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
206210type SimpleOperationObjectOpts struct {
207211 // Timeout is a `vshard.call` timeout and vshard
208212 // master discovery timeout (in seconds).
209- Timeout OptFloat64
213+ Timeout option. Float64
210214 // VshardRouter is cartridge vshard group name or
211215 // vshard router instance.
212- VshardRouter OptString
216+ VshardRouter option. String
213217 // Fields is field names for getting only a subset of fields.
214- Fields OptTuple
218+ Fields OptAny
215219 // BucketId is a bucket ID.
216- BucketId OptUint
220+ BucketId option. Unit64
217221 // SkipNullabilityCheckOnFlatten is a parameter to allow
218222 // setting null values to non-nullable fields.
219- SkipNullabilityCheckOnFlatten OptBool
223+ SkipNullabilityCheckOnFlatten option. Bool
220224 // FetchLatestMetadata guarantees the up-to-date metadata (space format)
221225 // in first return value, otherwise it may not take into account
222226 // the latest migration of the data format. Performance overhead is up to 15%.
223227 // Disabled by default.
224- FetchLatestMetadata OptBool
228+ FetchLatestMetadata option. Bool
225229 // Noreturn suppresses successfully processed data (first return value is `nil`).
226230 // Disabled by default.
227- Noreturn OptBool
231+ Noreturn option. Bool
228232}
229233
230234// EncodeMsgpack provides custom msgpack encoder.
0 commit comments