-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Copy bi-directional event stream request #3311
Conversation
cad86c2
to
f6975df
Compare
@@ -305,7 +305,8 @@ HttpResponseOutcome AWSClient::AttemptExhaustively(const Aws::Http::URI& uri, | |||
coreMetrics.httpClientMetrics = httpRequest->GetRequestMetrics(); | |||
TracingUtils::EmitCoreHttpMetrics(httpRequest->GetRequestMetrics(), | |||
*m_telemetryProvider->getMeter(this->GetServiceClientName(), {}), | |||
{{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()},{TracingUtils::SMITHY_SERVICE_DIMENSION, this->GetServiceClientName()}}); | |||
{{TracingUtils::SMITHY_METHOD_DIMENSION, request.GetServiceRequestName()}, |
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.
if it crashes again we will know if service client or request is in UB.
@@ -53,6 +53,7 @@ namespace Aws | |||
|
|||
void EventStreamDecoder::ResetEventStreamHandler(EventStreamHandler* handler) | |||
{ | |||
m_eventStreamHandler = handler; |
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.
it was a big one.
@@ -137,7 +137,7 @@ namespace Model | |||
/** | |||
* Underlying Event Stream Handler which is used to define callback functions. | |||
*/ | |||
inline const ${operation.name}Handler& GetEventStreamHandler() const { return m_handler; } | |||
inline ${operation.name}Handler& GetEventStreamHandler() { return m_handler; } |
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.
returning object with only non-const methods by const reference is quite meaningless otherwise.
607e0fe
to
602782b
Compare
@@ -9,6 +9,7 @@ | |||
#include <aws/core/utils/logging/ErrorMacros.h> | |||
#include <aws/core/utils/component-registry/ComponentRegistry.h> | |||
|
|||
|
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.
nit: not changes in file
AWS_LOGSTREAM_FATAL(ClientT::GetAllocationTag(), | ||
"Unexpected nullptr bi-directional streaming request on response streaming factory call!"); | ||
assert(false); | ||
return nullptr; |
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.
instead of nullptr should we return a empty string stream? even though we have entered a invalid state, a empty stream might help someone more gracefully exit than a null ptr
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.
ResponseStream is already handling nullptr condition in the c-tor.
ResponseStream::ResponseStream(Aws::IOStream* underlyingStreamToManage) : | |
m_underlyingStream(underlyingStreamToManage) | |
{ | |
RegisterStream(); | |
} |
if (!request) { | ||
AWS_LOGSTREAM_FATAL(ClientT::GetAllocationTag(), "Unexpected nullptr bi-directional streaming request on initial response!"); | ||
assert(false); | ||
return; |
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.
nit i prefer no returns on a void function and to rely on if - else behavior i.e.
if (!request) {
....
} else if (!response) {
....
} else {
.....
}
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.
Replaced with ptr check macros.
m_stream(stream), | ||
m_method(method), | ||
m_signerName(signerName), | ||
m_sem(Aws::MakeShared<Aws::Utils::Threading::Semaphore>("BidirectionalEventStreamingTask", 0, 1)) { |
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.
why do we want to use a semaphore and not a mutex if max value of semaphore is 1?
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.
That's the original generated design code.
We could switch to a singal, but it will take 2 more member variables (mutex and a conditional_variable) to pass around instead of this single one.
}; | ||
for (size_t i = 0; i < 2; ++i) { | ||
client->StartStreamTranscriptionAsync(request, OnStreamReady, OnResponseCallback, nullptr /*context*/); | ||
semaphore.WaitOne(); |
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.
please add a reasonable "drop dead" timeout so that we can avoid locking unit tests if something goes wrong
9755fd5
to
54ca419
Compare
0ee6fc5
to
2b6fdfb
Compare
2b6fdfb
to
aaaef77
Compare
Issue #, if available:
Undefined behavior:
Description of changes:
Create a request copy for async execution.
Avoid capturing objects by raw pointers into lambdas factories to avoid dangling pointers/reference.
Check all that applies:
Check which platforms you have built SDK on to verify the correctness of this PR.
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.