-
Notifications
You must be signed in to change notification settings - Fork 60
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: queue works with connection_pool #212
Conversation
d774023
to
cde62df
Compare
This pull request is ready for review in general, but I'll wait for #210 to spend less time on rebase. Also there is a bug in the queue that needs to be fixed to make tests successful. |
e1bf9cf
to
679ab77
Compare
There is a problem with download from tarantool.io, so we have 2.x-latest tests failed:
I think we can ignore this problem for a couple of days. |
679ab77
to
70ad414
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patch!
I have lest several questions. Most of them are not of a great importance, except for the lack of test for the main feature. (Maybe I had missed something.)
70ad414
to
d0314fe
Compare
d0314fe
to
5bc9814
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, it doesn't seems nice to remove the approval (especially since nothing had changed since last revision), but I've tried to manually run the examples and it wasn't an immediate success.
ac49d45
to
ef7fbd3
Compare
The patch adds missed Execute, ExecuteTyped and ExecuteAsync methods to the ConnectionPool type. Part of #176
ConnectorAdapter allows to use ConnectionPool as Connector. All requests to a pool will be executed in a specified mode. Part of #176
It fixes queue.cfg({in_replicaset = true}) for Tarantool 1.10 [1]. 1. tarantool/queue#185 Part of #176
1c6c78a
to
3ddf87d
Compare
I have updated the example connection_pool + queue. Let's have another round of review. |
3ddf87d
to
e2b7a1c
Compare
Sorry, I don't get how force-pulling the branch had resulted in its deleting on the remote. |
917b6ad
to
0132b18
Compare
The example demonstrates how to use the queue package with the connection_pool package. Closes #176
0132b18
to
842866f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, seems awesome.
I've also tried to ack the taken task after one more master switch, it was a success. If you want, you may add it too, see git diff
below.
diff --git a/queue/example_connection_pool_test.go b/queue/example_connection_pool_test.go
index bf1d53d..7b4deae 100644
--- a/queue/example_connection_pool_test.go
+++ b/queue/example_connection_pool_test.go
@@ -185,17 +185,50 @@ func Example_connectionPool() {
}
// Take a data from the new master instance.
- if task, err := q.Take(); err == nil || task.Data() == nil {
- task.Ack()
+ var task *queue.Task
+ task, err = q.Take()
+ if err == nil || task.Data() == nil {
fmt.Println("Got data:", task.Data())
} else {
fmt.Println("Unable to got data:", err)
}
+ // Switch a master instance in the pool.
+ roles = []bool{false, true}
+ err = test_helpers.SetClusterRO(servers, connOpts, roles)
+ if err != nil {
+ fmt.Printf("Unable to set cluster roles: %s", err)
+ return
+ }
+
+ // Wait for a new master instance re-identification.
+ <-h.masterUpdated
+ if h.err != nil {
+ fmt.Printf("Unable to re-identify in the pool: %s", h.err)
+ return
+ }
+
+ err = task.Ack()
+
+ if err != nil {
+ fmt.Printf("Unable to ack the task: %s", err)
+ return
+ }
+
+ var stats interface{}
+ stats, err = q.Statistic()
+ if err != nil {
+ fmt.Printf("Unable to get stats: %s", err)
+ return
+ }
+ fmt.Println(stats)
+
// Output:
// Master 127.0.0.1:3014 is ready to work!
// A Queue object is ready to work.
// Send data: test_data
// Master 127.0.0.1:3014 is ready to work!
// A Queue object is ready to work.
// Send data: test_data
// Master 127.0.0.1:3015 is ready to work!
// Got data: test_data
+ // Master 127.0.0.1:3014 is ready to work!
+ // map[calls:map[ack:1 bury:0 delay:0 delete:0 kick:0 put:1 release:0 take:0 touch:0 ttl:0 ttr:0] tasks:map[buried:0 delayed:0 done:1 ready:0 taken:0 total:0]]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The patchet allows to use the queue subpackage with the connection_pool subpackage:
Execute*
methods to ConnectionPool.Finally, it adds an example how-to use a Queue with ConnectionPool.
I didn't forget about (remove if it is not applicable):
Related issues:
Closes #176