Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
crud: support fetch_latest_metadata option
`fetch_latest_metadata` option was introduced in crud 1.2.0 [1].

1. tarantool/crud@2675925
  • Loading branch information
DifferentialOrange committed Oct 6, 2023
commit c33f35102d143a8ac7a3991f227b8db513062a07
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Versioning](http://semver.org/spec/v2.0.0.html) except to the first release.
- Meaningful description for read/write socket errors (#129)
- Support password and password file to decrypt private SSL key file (#319)
- Support `operation_data` in `crud.Error` (#330)
- Support `fetch_latest_metadata` option for crud requests with metadata (#335)

### Changed

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ clean:
.PHONY: deps
deps: clean
( cd ./queue/testdata; $(TTCTL) rocks install queue 1.3.0 )
( cd ./crud/testdata; $(TTCTL) rocks install crud 1.1.1 )
( cd ./crud/testdata; $(TTCTL) rocks install crud 1.3.0 )

.PHONY: datetime-timezones
datetime-timezones:
Expand Down
10 changes: 8 additions & 2 deletions crud/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,20 @@ type GetOpts struct {
// Balance is a parameter to use replica according to vshard
// load balancing policy.
Balance OptBool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata OptBool
}

// EncodeMsgpack provides custom msgpack encoder.
func (opts GetOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
const optsCnt = 7
const optsCnt = 8

names := [optsCnt]string{timeoutOptName, vshardRouterOptName,
fieldsOptName, bucketIdOptName, modeOptName,
preferReplicaOptName, balanceOptName}
preferReplicaOptName, balanceOptName, fetchLatestMetadataOptName}
values := [optsCnt]interface{}{}
exists := [optsCnt]bool{}
values[0], exists[0] = opts.Timeout.Get()
Expand All @@ -47,6 +52,7 @@ func (opts GetOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
values[4], exists[4] = opts.Mode.Get()
values[5], exists[5] = opts.PreferReplica.Get()
values[6], exists[6] = opts.Balance.Get()
values[7], exists[7] = opts.FetchLatestMetadata.Get()

return encodeOptions(enc, names[:], values[:], exists[:])
}
Expand Down
54 changes: 44 additions & 10 deletions crud/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const (
firstOptName = "first"
afterOptName = "after"
batchSizeOptName = "batch_size"
fetchLatestMetadataOptName = "fetch_latest_metadata"
)

// OptUint is an optional uint.
Expand Down Expand Up @@ -150,20 +151,26 @@ type SimpleOperationOpts struct {
Fields OptTuple
// BucketId is a bucket ID.
BucketId OptUint
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata OptBool
}

// EncodeMsgpack provides custom msgpack encoder.
func (opts SimpleOperationOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
const optsCnt = 4
const optsCnt = 5

names := [optsCnt]string{timeoutOptName, vshardRouterOptName,
fieldsOptName, bucketIdOptName}
fieldsOptName, bucketIdOptName, fetchLatestMetadataOptName}
values := [optsCnt]interface{}{}
exists := [optsCnt]bool{}
values[0], exists[0] = opts.Timeout.Get()
values[1], exists[1] = opts.VshardRouter.Get()
values[2], exists[2] = opts.Fields.Get()
values[3], exists[3] = opts.BucketId.Get()
values[4], exists[4] = opts.FetchLatestMetadata.Get()

return encodeOptions(enc, names[:], values[:], exists[:])
}
Expand All @@ -184,21 +191,28 @@ type SimpleOperationObjectOpts struct {
// SkipNullabilityCheckOnFlatten is a parameter to allow
// setting null values to non-nullable fields.
SkipNullabilityCheckOnFlatten OptBool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata OptBool
}

// EncodeMsgpack provides custom msgpack encoder.
func (opts SimpleOperationObjectOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
const optsCnt = 5
const optsCnt = 6

names := [optsCnt]string{timeoutOptName, vshardRouterOptName,
fieldsOptName, bucketIdOptName, skipNullabilityCheckOnFlattenOptName}
fieldsOptName, bucketIdOptName, skipNullabilityCheckOnFlattenOptName,
fetchLatestMetadataOptName}
values := [optsCnt]interface{}{}
exists := [optsCnt]bool{}
values[0], exists[0] = opts.Timeout.Get()
values[1], exists[1] = opts.VshardRouter.Get()
values[2], exists[2] = opts.Fields.Get()
values[3], exists[3] = opts.BucketId.Get()
values[4], exists[4] = opts.SkipNullabilityCheckOnFlatten.Get()
values[5], exists[5] = opts.FetchLatestMetadata.Get()

return encodeOptions(enc, names[:], values[:], exists[:])
}
Expand All @@ -221,21 +235,28 @@ type OperationManyOpts struct {
// RollbackOnError is a parameter because of what any failed operation
// will lead to rollback on a storage, where the operation is failed.
RollbackOnError OptBool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata OptBool
}

// EncodeMsgpack provides custom msgpack encoder.
func (opts OperationManyOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
const optsCnt = 5
const optsCnt = 6

names := [optsCnt]string{timeoutOptName, vshardRouterOptName,
fieldsOptName, stopOnErrorOptName, rollbackOnErrorOptName}
fieldsOptName, stopOnErrorOptName, rollbackOnErrorOptName,
fetchLatestMetadataOptName}
values := [optsCnt]interface{}{}
exists := [optsCnt]bool{}
values[0], exists[0] = opts.Timeout.Get()
values[1], exists[1] = opts.VshardRouter.Get()
values[2], exists[2] = opts.Fields.Get()
values[3], exists[3] = opts.StopOnError.Get()
values[4], exists[4] = opts.RollbackOnError.Get()
values[5], exists[5] = opts.FetchLatestMetadata.Get()

return encodeOptions(enc, names[:], values[:], exists[:])
}
Expand All @@ -261,15 +282,20 @@ type OperationObjectManyOpts struct {
// SkipNullabilityCheckOnFlatten is a parameter to allow
// setting null values to non-nullable fields.
SkipNullabilityCheckOnFlatten OptBool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata OptBool
}

// EncodeMsgpack provides custom msgpack encoder.
func (opts OperationObjectManyOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
const optsCnt = 6
const optsCnt = 7

names := [optsCnt]string{timeoutOptName, vshardRouterOptName,
fieldsOptName, stopOnErrorOptName, rollbackOnErrorOptName,
skipNullabilityCheckOnFlattenOptName}
skipNullabilityCheckOnFlattenOptName, fetchLatestMetadataOptName}
values := [optsCnt]interface{}{}
exists := [optsCnt]bool{}
values[0], exists[0] = opts.Timeout.Get()
Expand All @@ -278,6 +304,7 @@ func (opts OperationObjectManyOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
values[3], exists[3] = opts.StopOnError.Get()
values[4], exists[4] = opts.RollbackOnError.Get()
values[5], exists[5] = opts.SkipNullabilityCheckOnFlatten.Get()
values[6], exists[6] = opts.FetchLatestMetadata.Get()

return encodeOptions(enc, names[:], values[:], exists[:])
}
Expand All @@ -292,18 +319,25 @@ type BorderOpts struct {
VshardRouter OptString
// Fields is field names for getting only a subset of fields.
Fields OptTuple
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata OptBool
}

// EncodeMsgpack provides custom msgpack encoder.
func (opts BorderOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
const optsCnt = 3
const optsCnt = 4

names := [optsCnt]string{timeoutOptName, vshardRouterOptName, fieldsOptName}
names := [optsCnt]string{timeoutOptName, vshardRouterOptName, fieldsOptName,
fetchLatestMetadataOptName}
values := [optsCnt]interface{}{}
exists := [optsCnt]bool{}
values[0], exists[0] = opts.Timeout.Get()
values[1], exists[1] = opts.VshardRouter.Get()
values[2], exists[2] = opts.Fields.Get()
values[3], exists[3] = opts.FetchLatestMetadata.Get()

return encodeOptions(enc, names[:], values[:], exists[:])
}
Expand Down
10 changes: 8 additions & 2 deletions crud/select.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,22 @@ type SelectOpts struct {
// Fullscan describes if a critical log entry will be skipped on
// potentially long select.
Fullscan OptBool
// FetchLatestMetadata guarantees the up-to-date metadata (space format)
// in first return value, otherwise it may not take into account
// the latest migration of the data format. Performance overhead is up to 15%.
// Disabled by default.
FetchLatestMetadata OptBool
}

// EncodeMsgpack provides custom msgpack encoder.
func (opts SelectOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
const optsCnt = 12
const optsCnt = 13

names := [optsCnt]string{timeoutOptName, vshardRouterOptName,
fieldsOptName, bucketIdOptName,
modeOptName, preferReplicaOptName, balanceOptName,
firstOptName, afterOptName, batchSizeOptName,
forceMapCallOptName, fullscanOptName}
forceMapCallOptName, fullscanOptName, fetchLatestMetadataOptName}
values := [optsCnt]interface{}{}
exists := [optsCnt]bool{}
values[0], exists[0] = opts.Timeout.Get()
Expand All @@ -66,6 +71,7 @@ func (opts SelectOpts) EncodeMsgpack(enc *msgpack.Encoder) error {
values[9], exists[9] = opts.BatchSize.Get()
values[10], exists[10] = opts.ForceMapCall.Get()
values[11], exists[11] = opts.Fullscan.Get()
values[12], exists[12] = opts.FetchLatestMetadata.Get()

return encodeOptions(enc, names[:], values[:], exists[:])
}
Expand Down
Loading