Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: support IPROTO_WATCH_ONCE request type #340

Merged
merged 2 commits into from
Oct 30, 2023

Conversation

DerekBum
Copy link

@DerekBum DerekBum commented Oct 25, 2023

Added support of IPROTO_WATCH_ONCE request type.
It works only for Tarantool version >= 3.0.0-alpha1.

Replaced the local ProtocolFeature type with the iproto.Feature.
Replaced local Feature constants with their iproto.IPROTO_FEATURE_ analogues.

I didn't forget about (remove if it is not applicable):

Closes #337

@DerekBum DerekBum requested a review from oleg-jukovec October 25, 2023 13:07
@DerekBum DerekBum force-pushed the DerekBum/gh-337-support-iproto-watch-once branch from e6775db to 7320b05 Compare October 25, 2023 13:20
request.go Outdated Show resolved Hide resolved
request_test.go Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
tarantool_test.go Outdated Show resolved Hide resolved
@oleg-jukovec
Copy link
Collaborator

oleg-jukovec commented Oct 25, 2023

You also forgot to update client features list:

go-tarantool/protocol.go

Lines 76 to 98 in b6e8aba

var clientProtocolInfo ProtocolInfo = ProtocolInfo{
// Protocol version supported by connector. Version 3
// was introduced in Tarantool 2.10.0, version 4 was
// introduced in master 948e5cd (possible 2.10.5 or 2.11.0).
// Support of protocol version on connector side was introduced in
// 1.10.0.
Version: ProtocolVersion(4),
// Streams and transactions were introduced in protocol version 1
// (Tarantool 2.10.0), in connector since 1.7.0.
// Error extension type was introduced in protocol
// version 2 (Tarantool 2.10.0), in connector since 1.10.0.
// Watchers were introduced in protocol version 3 (Tarantool 2.10.0), in
// connector since 1.10.0.
// Pagination were introduced in protocol version 4 (Tarantool 2.11.0), in
// connector since 1.11.0.
Features: []ProtocolFeature{
StreamsFeature,
TransactionsFeature,
ErrorExtensionFeature,
WatchersFeature,
PaginationFeature,
},
}

I also suggest to replace ProtocolFeature constants type:

go-tarantool/protocol.go

Lines 14 to 74 in b6e8aba

// ProtocolVersion type stores a Tarantool protocol feature.
type ProtocolFeature uint64
// ProtocolInfo type aggregates Tarantool protocol version and features info.
type ProtocolInfo struct {
// Auth is an authentication method.
Auth Auth
// Version is the supported protocol version.
Version ProtocolVersion
// Features are supported protocol features.
Features []ProtocolFeature
}
// Clone returns an exact copy of the ProtocolInfo object.
// Any changes in copy will not affect the original values.
func (info ProtocolInfo) Clone() ProtocolInfo {
infoCopy := info
if info.Features != nil {
infoCopy.Features = make([]ProtocolFeature, len(info.Features))
copy(infoCopy.Features, info.Features)
}
return infoCopy
}
const (
// StreamsFeature represents streams support (supported by connector).
StreamsFeature ProtocolFeature = 0
// TransactionsFeature represents interactive transactions support.
// (supported by connector).
TransactionsFeature ProtocolFeature = 1
// ErrorExtensionFeature represents support of MP_ERROR objects over MessagePack
// (supported by connector).
ErrorExtensionFeature ProtocolFeature = 2
// WatchersFeature represents support of watchers
// (supported by connector).
WatchersFeature ProtocolFeature = 3
// PaginationFeature represents support of pagination
// (supported by connector).
PaginationFeature ProtocolFeature = 4
)
// String returns the name of a Tarantool feature.
// If value X is not a known feature, returns "Unknown feature (code X)" string.
func (ftr ProtocolFeature) String() string {
switch ftr {
case StreamsFeature:
return "StreamsFeature"
case TransactionsFeature:
return "TransactionsFeature"
case ErrorExtensionFeature:
return "ErrorExtensionFeature"
case WatchersFeature:
return "WatchersFeature"
case PaginationFeature:
return "PaginationFeature"
default:
return fmt.Sprintf("Unknown feature (code %d)", ftr)
}
}

By the type Feature from go-iproto package:
https://github.com/tarantool/go-iproto/blob/cb78944739315ca92d64bddf64689e82df4b3cc5/feature.go#L5-L9

@DerekBum DerekBum force-pushed the DerekBum/gh-337-support-iproto-watch-once branch 2 times, most recently from b978024 to 2a378a6 Compare October 25, 2023 16:36
@DerekBum
Copy link
Author

DerekBum commented Oct 25, 2023

Updated protocol.go and protocol_test.go. SpaceAndIndexNamesFeature (5) and WatchOnceFeature (6) added.

@DerekBum DerekBum force-pushed the DerekBum/gh-337-support-iproto-watch-once branch from 2a378a6 to 3009903 Compare October 25, 2023 16:47
example_test.go Outdated Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
protocol.go Outdated Show resolved Hide resolved
@DerekBum DerekBum force-pushed the DerekBum/gh-337-support-iproto-watch-once branch 4 times, most recently from b6b3ca7 to fd987e5 Compare October 26, 2023 10:30
CHANGELOG.md Show resolved Hide resolved
example_test.go Outdated Show resolved Hide resolved
pool/example_test.go Show resolved Hide resolved
protocol.go Outdated Show resolved Hide resolved
@DerekBum DerekBum force-pushed the DerekBum/gh-337-support-iproto-watch-once branch 2 times, most recently from 31b1426 to b9febd3 Compare October 26, 2023 17:28
protocol_test.go Outdated Show resolved Hide resolved
test_helpers/utils.go Outdated Show resolved Hide resolved
Copy link
Collaborator

@oleg-jukovec oleg-jukovec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the patch!

@DerekBum DerekBum force-pushed the DerekBum/gh-337-support-iproto-watch-once branch from b9febd3 to 428e050 Compare October 26, 2023 21:48
Copy link
Member

@DifferentialOrange DifferentialOrange left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine, see a couple of nits regarding the description below

CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@DerekBum DerekBum force-pushed the DerekBum/gh-337-support-iproto-watch-once branch from 428e050 to 43ff73d Compare October 30, 2023 12:02
@oleg-jukovec
Copy link
Collaborator

oleg-jukovec commented Oct 30, 2023

Please check what is wrong with ExampleSelectRequest_pagination.

@oleg-jukovec
Copy link
Collaborator

oleg-jukovec commented Oct 30, 2023

Please check what is wrong with ExampleSelectRequest_pagination.

Oh, please just rebase to the master branch:
#339

Add support of `IPROTO_WATCH_ONCE` request type.
It works only for Tarantool version >= 3.0.0-alpha1.

Part of #337
Replaced the local `ProtocolFeature` type with the
`iproto.Feature`.
Replaced local `Feature` constants with their
`iproto.IPROTO_FEATURE_` analogues.

Closes #337
@DerekBum DerekBum force-pushed the DerekBum/gh-337-support-iproto-watch-once branch from 43ff73d to a916922 Compare October 30, 2023 12:34
@oleg-jukovec oleg-jukovec merged commit a664c6b into master Oct 30, 2023
22 checks passed
@oleg-jukovec oleg-jukovec deleted the DerekBum/gh-337-support-iproto-watch-once branch October 30, 2023 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support IPROTO_WATCH_ONCE
3 participants