-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add retry in templates to wait realtime notifications #161
Merged
Merged
Changes from 11 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
a677a3d
[realtime tests] add sleep to wait notifications
Aschen 0b0a6cf
[realtime tests] extract sleep from the code snippets
Aschen 21bf4a7
[realtime tests] remove sleep in cpp snippet
Aschen e32e360
[realtime tests] increase sleep for js
Aschen 91857f3
[realtime tests] use retry in cpp template
Aschen 4cdc08a
[realtime tests] use retry in java template
Aschen 24a87c5
[realtime tests] use retry in go template
Aschen 46b7010
[realtime tests] use retry in js template
Aschen 720997d
[realtime tests] nitpicking
Aschen 706ea6c
[realtime tests] prevent infinite loops
Aschen cb9253a
[realtime tests] exit with non-zero code when timeout in go
Aschen 9639cd2
[realtime tests] add sleep to wait notifications
Aschen 35b338d
[realtime tests] extract sleep from the code snippets
Aschen 1199b28
[realtime tests] remove sleep in cpp snippet
Aschen 6ca00a9
[realtime tests] increase sleep for js
Aschen a555b16
[realtime tests] use retry in cpp template
Aschen 89700bf
[realtime tests] use retry in java template
Aschen 948490f
[realtime tests] use retry in go template
Aschen 37efd20
[realtime tests] use retry in js template
Aschen 007bed9
[realtime tests] nitpicking
Aschen 41d634c
[realtime tests] prevent infinite loops
Aschen 7cd127d
[realtime tests] exit with non-zero code when timeout in go
Aschen 8ea341f
Merge branch 'fix-realtime-tests' of github.com:kuzzleio/documentatio…
Aschen 4b5e07e
[realtime tests] fix js realtime
Aschen c9ebf6d
[realtime tests] fix js realtime
Aschen 851e07f
[c++] update templates to the latest SDK version
scottinet c875266
[templates] C++: kuzzle->connect now throws
scottinet 0d19c20
[cleanup] revert type change
scottinet e944bba
[c++] upgrade SDK install to the latest changes
scottinet 2a8dcf9
Merge remote-tracking branch 'origin/upgrade-cpp-templates' into fix-…
scottinet c181328
Merge remote-tracking branch 'origin/master' into fix-realtime-tests
scottinet f6489d2
[c++] upgrade code snippets
scottinet 154cce2
[java] upgrade templates to the new kuzzle constructor
scottinet 6559596
Merge remote-tracking branch 'origin/upgrade-cpp-templates' into fix-…
scottinet 94bbb9c
[realtime] upgrade templates to the latest kuzzle constructor
scottinet 5a67369
[realtime] wait for 30s before throwing a timeout
scottinet 9e64df3
[templates] realtime: timeout after 30s
scottinet de6e9d3
[realtime] JS template: exit even if the event loop is not empty
scottinet ea3e090
[realtime] JS: stricter tests + fix explanation
scottinet f20db37
[snippets] multi-snippets wrongly check column precedence
scottinet 7645862
[realtime] stricter tests + snippet fixes
scottinet f8f8e20
[realtime] stabilize realtime tests
scottinet ee3b481
[templates] C++: getPort() is now only accessible through the Protoco…
scottinet 3b3306c
Merge remote-tracking branch 'origin/master' into fix-realtime-tests
scottinet ee6d075
[java] fix user notifications snippet
scottinet File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include <unistd.h> | ||
|
||
#include <sstream> | ||
#include <iostream> | ||
#include <string> | ||
#include <ctime> | ||
#include <vector> | ||
|
||
#include "auth.hpp" | ||
#include "collection.hpp" | ||
#include "document.hpp" | ||
#include "server.hpp" | ||
#include "index.hpp" | ||
#include "realtime.hpp" | ||
#include "kuzzle.hpp" | ||
|
||
bool is_empty(std::ostringstream *stream) { | ||
bool empty; | ||
std::streampos position = stream->tellp(); | ||
|
||
stream->seekp(0, std::ios_base::end); | ||
empty = stream->tellp() == 0; | ||
stream->seekp(position); | ||
|
||
return empty; | ||
} | ||
|
||
int main() { | ||
std::string hostname = "kuzzle"; | ||
|
||
kuzzleio::Kuzzle* kuzzle = new kuzzleio::Kuzzle(hostname); | ||
|
||
char* error = kuzzle->connect(); | ||
if (error != nullptr) { | ||
std::cerr << "Unable to connect to " << hostname << ":7512\n" << error << std::endl; | ||
return 1; | ||
} | ||
|
||
std::streambuf *cout_original = std::cout.rdbuf(); | ||
std::ostringstream cout_copy; | ||
|
||
std::cout.rdbuf(cout_copy.rdbuf()); | ||
|
||
[snippet-code] | ||
|
||
for (size_t i = 20; i > 0 && is_empty(&cout_copy); --i) { | ||
usleep(200); | ||
} | ||
|
||
std::cout.rdbuf(cout_original); | ||
std::cout << cout_copy.str(); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You should make sure that the buffer has been completely emptied and printed before stopping the snippet: 4k may not be large enough
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.
I pick this value that should be enough because in the snippets we always print a string with a fixed length