Skip to content

Commit

Permalink
Checkpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Bret Ambrose committed Mar 6, 2024
1 parent 590f947 commit 545aba0
Show file tree
Hide file tree
Showing 4 changed files with 371 additions and 23 deletions.
33 changes: 33 additions & 0 deletions include/aws/mqtt/private/request-response/request_response.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef AWS_MQTT_PRIVATE_REQUEST_RESPONSE_REQUEST_RESPONSE_H
#define AWS_MQTT_PRIVATE_REQUEST_RESPONSE_REQUEST_RESPONSE_H

/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/

#include <aws/mqtt/mqtt.h>

/*
* Describes a change to the state of a request-response client subscription
*/
enum aws_rr_subscription_event_type {

/*
* A subscribe succeeded
*/
ARRSET_SUBSCRIPTION_SUBSCRIBE_SUCCESS,

/*
* A subscribe failed
*/
ARRSET_SUBSCRIPTION_SUBSCRIBE_FAILURE,

/*
* A previously successful subscription has ended (generally due to a failure to resume a session)
*/
ARRSET_SUBSCRIPTION_ENDED
};

#endif /* AWS_MQTT_PRIVATE_REQUEST_RESPONSE_REQUEST_RESPONSE_H */

22 changes: 1 addition & 21 deletions include/aws/mqtt/private/request-response/subscription_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,12 @@
#include <aws/mqtt/mqtt.h>

#include <aws/common/hash_table.h>
#include <aws/mqtt/private/request-response/request_response.h>

struct aws_mqtt_protocol_adapter;
struct aws_protocol_adapter_connection_event;
struct aws_protocol_adapter_subscription_event;

/*
* The kind of subscription event being emitted.
*/
enum aws_rr_subscription_event_type {

/*
* A subscribe succeeded
*/
ARRSET_SUBSCRIPTION_SUBSCRIBE_SUCCESS,

/*
* A subscribe failed
*/
ARRSET_SUBSCRIPTION_SUBSCRIBE_FAILURE,

/*
* A previously successful subscription has ended (generally due to a failure to resume a session)
*/
ARRSET_SUBSCRIPTION_ENDED
};

struct aws_rr_subscription_status_event {
enum aws_rr_subscription_event_type type;
struct aws_byte_cursor topic_filter;
Expand Down
71 changes: 69 additions & 2 deletions include/aws/mqtt/request-response/request_response_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,66 @@
* SPDX-License-Identifier: Apache-2.0.
*/

#include "aws/mqtt/mqtt.h"
#include <aws/mqtt/mqtt.h>

#include <aws/mqtt/private/request-response/request_response.h>

struct aws_mqtt_request_response_client;
struct aws_mqtt_client_connection;
struct aws_mqtt5_client;
struct aws_mqtt_streaming_operation;

struct aws_mqtt_request_operation_message_path {
struct aws_byte_cursor topic;

/* potential point of expansion into an abstract "extractor" if we ever need to support non-JSON payloads */
struct aws_byte_cursor correlation_token_json_path;
};

typedef void(aws_mqtt_request_operation_completion_fn)(int error_code, struct aws_byte_cursor payload, void *user_data);

struct aws_mqtt_request_operation_options {
struct aws_byte_cursor subscription_topic_filter;

struct aws_mqtt_request_operation_message_path *message_paths;
size_t message_path_count;

struct aws_byte_cursor publish_topic;
struct aws_byte_cursor serialized_request;
struct aws_byte_cursor correlation_token;

aws_mqtt_request_operation_completion_fn *completion_callback;
void *user_data;
};

struct aws_mqtt_request_operation_storage {
struct aws_mqtt_request_operation_options options;

struct aws_array_list operation_message_paths;

struct aws_byte_buf operation_data;
};

typedef void(aws_mqtt_streaming_operation_subscription_status_fn)(enum aws_rr_subscription_event_type status, int error_code, void *user_data);
typedef void(aws_mqtt_streaming_operation_incoming_publish_fn)(struct aws_byte_cursor payload, void *user_data);
typedef void(aws_mqtt_streaming_operation_terminated_fn)(void *user_data);

struct aws_mqtt_streaming_operation_options {
struct aws_byte_cursor topic_filter;

aws_mqtt_streaming_operation_subscription_status_fn *subscription_status_callback;
aws_mqtt_streaming_operation_incoming_publish_fn *incoming_publish_callback;
aws_mqtt_streaming_operation_terminated_fn *terminated_callback;

void *user_data;
};

struct aws_mqtt_streaming_operation_storage {
struct aws_mqtt_streaming_operation_options options;

struct aws_byte_buf operation_data;
};


typedef void(aws_mqtt_request_response_client_initialized_callback_fn)(void *user_data);
typedef void(aws_mqtt_request_response_client_terminated_callback_fn)(void *user_data);
Expand All @@ -21,8 +76,8 @@ struct aws_mqtt_request_response_client_options {

/* Do not bind the initialized callback; it exists mostly for tests and should not be exposed */
aws_mqtt_request_response_client_initialized_callback_fn *initialized_callback;

aws_mqtt_request_response_client_terminated_callback_fn *terminated_callback;

void *user_data;
};

Expand Down Expand Up @@ -56,6 +111,18 @@ AWS_MQTT_API struct aws_mqtt_request_response_client *aws_mqtt_request_response_
AWS_MQTT_API struct aws_mqtt_request_response_client *aws_mqtt_request_response_client_release(
struct aws_mqtt_request_response_client *client);

AWS_MQTT_API int aws_mqtt_request_response_client_submit_request(
struct aws_mqtt_request_response_client *client,
struct aws_mqtt_request_operation_options *request_options);

AWS_MQTT_API struct aws_mqtt_streaming_operation *aws_mqtt_request_response_client_create_streaming_operation(
struct aws_mqtt_request_response_client *client,
struct aws_mqtt_streaming_operation_options *streaming_options);

AWS_MQTT_API struct aws_mqtt_streaming_operation *aws_mqtt_streaming_operation_acquire(struct aws_mqtt_streaming_operation *operation);

AWS_MQTT_API struct aws_mqtt_streaming_operation *aws_mqtt_streaming_operation_release(struct aws_mqtt_streaming_operation *operation);

AWS_EXTERN_C_END

#endif /* AWS_MQTT_REQUEST_RESPONSE_REQUEST_RESPONSE_CLIENT_H */
Loading

0 comments on commit 545aba0

Please sign in to comment.