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

Clean eventstream rpc #704

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
38 changes: 12 additions & 26 deletions eventstream_rpc/include/aws/eventstreamrpc/EventStreamClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,32 +71,14 @@ namespace Aws
EventStreamHeader(
const struct aws_event_stream_header_value_pair &header,
Crt::Allocator *allocator = Crt::g_allocator);
EventStreamHeader(const Crt::String &name, bool value);
sfod marked this conversation as resolved.
Show resolved Hide resolved
EventStreamHeader(const Crt::String &name, int8_t value);
EventStreamHeader(const Crt::String &name, int16_t value);
EventStreamHeader(const Crt::String &name, int32_t value);
EventStreamHeader(const Crt::String &name, int64_t value);
EventStreamHeader(const Crt::String &name, Crt::DateTime &value);
EventStreamHeader(
const Crt::String &name,
const Crt::String &value,
Crt::Allocator *allocator = Crt::g_allocator) noexcept;
EventStreamHeader(const Crt::String &name, Crt::ByteBuf &value);
EventStreamHeader(const Crt::String &name, Crt::UUID value);

HeaderValueType GetHeaderValueType();
Crt::String GetHeaderName() const noexcept;
void SetHeaderName(const Crt::String &);

bool GetValueAsBoolean(bool &);
bool GetValueAsByte(int8_t &);
bool GetValueAsShort(int16_t &);
bool GetValueAsInt(int32_t &);
bool GetValueAsLong(int64_t &);
bool GetValueAsTimestamp(Crt::DateTime &);

bool GetValueAsString(Crt::String &) const noexcept;
bool GetValueAsBytes(Crt::ByteBuf &);
bool GetValueAsUUID(Crt::UUID &);

const struct aws_event_stream_header_value_pair *GetUnderlyingHandle() const;

Expand Down Expand Up @@ -229,6 +211,8 @@ namespace Aws
class AWS_EVENTSTREAMRPC_API ConnectionLifecycleHandler
{
public:
virtual ~ConnectionLifecycleHandler() noexcept = default;

/**
* This callback is only invoked upon receiving a CONNECT_ACK with the
* CONNECTION_ACCEPTED flag set by the server. Therefore, once this callback
Expand Down Expand Up @@ -300,7 +284,7 @@ namespace Aws
* the TERMINATE_STREAM flag, or when the connection shuts down.
*/
virtual void OnContinuationClosed() = 0;
virtual ~ClientContinuationHandler() noexcept;
virtual ~ClientContinuationHandler() noexcept = default;

private:
friend class ClientContinuation;
Expand Down Expand Up @@ -352,7 +336,6 @@ namespace Aws
* @return True if the continuation has been closed, false otherwise.
*/
bool IsClosed() noexcept;
void Release() noexcept;

/**
* Send message on the continuation.
Expand Down Expand Up @@ -394,7 +377,7 @@ namespace Aws
{
public:
AbstractShapeBase() noexcept;
virtual ~AbstractShapeBase() noexcept;
virtual ~AbstractShapeBase() noexcept = default;
static void s_customDeleter(AbstractShapeBase *shape) noexcept;
virtual void SerializeToJsonObject(Crt::JsonObject &payloadObject) const = 0;
virtual Crt::String GetModelName() const noexcept = 0;
Expand All @@ -409,7 +392,7 @@ namespace Aws
class AWS_EVENTSTREAMRPC_API OperationError : public AbstractShapeBase
{
public:
explicit OperationError() noexcept;
explicit OperationError() noexcept = default;
static void s_customDeleter(OperationError *shape) noexcept;
virtual void SerializeToJsonObject(Crt::JsonObject &payloadObject) const override;
virtual Crt::Optional<Crt::String> GetMessage() noexcept = 0;
Expand All @@ -423,6 +406,8 @@ namespace Aws
class AWS_EVENTSTREAMRPC_API StreamResponseHandler
{
public:
virtual ~StreamResponseHandler() noexcept = default;

/**
* Invoked when stream is closed, so no more messages will be received.
*/
Expand Down Expand Up @@ -523,6 +508,7 @@ namespace Aws
{
/* An interface shared by all operations for retrieving the response object given the model name. */
public:
virtual ~ResponseRetriever() noexcept = default;
virtual ExpectedResponseFactory GetInitialResponseFromModelName(
const Crt::String &modelName) const noexcept = 0;
virtual ExpectedResponseFactory GetStreamingResponseFromModelName(
Expand All @@ -534,6 +520,7 @@ namespace Aws
class AWS_EVENTSTREAMRPC_API ServiceModel
{
public:
virtual ~ServiceModel() noexcept = default;
virtual Crt::ScopedResource<OperationError> AllocateOperationErrorFromPayload(
const Crt::String &errorModelName,
Crt::StringView stringView,
Expand All @@ -548,6 +535,8 @@ namespace Aws
public:
OperationModelContext(const ServiceModel &serviceModel) noexcept;

virtual ~OperationModelContext() noexcept = default;

/**
* Parse the given string into an initial response object.
* @param stringView String to parse the response from.
Expand Down Expand Up @@ -662,9 +651,6 @@ namespace Aws
std::future<RpcError> Activate(
const AbstractShapeBase *shape,
OnMessageFlushCallback onMessageFlushCallback) noexcept;
std::future<RpcError> SendStreamEvent(
AbstractShapeBase *shape,
OnMessageFlushCallback onMessageFlushCallback) noexcept;

/**
* Returns the canonical model name associated with this operation across any client language.
Expand Down
6 changes: 0 additions & 6 deletions eventstream_rpc/source/EventStreamClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,8 +886,6 @@ namespace Aws
}
}

ClientContinuationHandler::~ClientContinuationHandler() noexcept {}

void ClientContinuation::s_onContinuationMessage(
struct aws_event_stream_rpc_client_continuation_token *continuationToken,
const struct aws_event_stream_rpc_message_args *messageArgs,
Expand Down Expand Up @@ -1101,14 +1099,10 @@ namespace Aws
{
}

OperationError::OperationError() noexcept {}

void OperationError::SerializeToJsonObject(Crt::JsonObject &payloadObject) const { (void)payloadObject; }

AbstractShapeBase::AbstractShapeBase() noexcept : m_allocator(nullptr) {}

AbstractShapeBase::~AbstractShapeBase() noexcept {}

ClientOperation::ClientOperation(
ClientConnection &connection,
std::shared_ptr<StreamResponseHandler> streamHandler,
Expand Down
Loading