Skip to content

Commit 9f78f83

Browse files
authored
Add Greengrass APIs for resource management (#303)
1 parent 3b4498e commit 9f78f83

File tree

8 files changed

+1073
-217
lines changed

8 files changed

+1073
-217
lines changed

eventstream_rpc/tests/include/awstest/EchoTestRpcClient.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ namespace Awstest
2626
Aws::Crt::Allocator *allocator = Aws::Crt::g_allocator) noexcept;
2727
/**
2828
* Connect the client to the server
29-
* @param lifecycleHandler An interface that is called upon when lifecycle events relating to the connection
30-
* occur.
31-
* @param connectionConfig The configuration parameters used for establishing the connection.
32-
* @return An `RpcError` that can be used to check whether the connection was established.
29+
* @param lifecycleHandler An interface that is called upon when lifecycle
30+
* events relating to the connection occur.
31+
* @param connectionConfig The configuration parameters used for establishing
32+
* the connection.
33+
* @return An `RpcError` that can be used to check whether the connection was
34+
* established.
3335
*/
3436
std::future<RpcError> Connect(
3537
ConnectionLifecycleHandler &lifecycleHandler,

eventstream_rpc/tests/include/awstest/EchoTestRpcModel.h

Lines changed: 70 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ namespace Awstest
6161
Aws::Crt::StringView,
6262
Aws::Crt::Allocator *) noexcept;
6363
static void s_customDeleter(Customer *) noexcept;
64-
/* This needs to be defined so that `Customer` can be used as a key in maps. */
64+
/* This needs to be defined so that `Customer` can be used as a key in maps.
65+
*/
6566
bool operator<(const Customer &) const noexcept;
6667
static const char *MODEL_NAME;
6768

@@ -156,7 +157,8 @@ namespace Awstest
156157
Aws::Crt::StringView,
157158
Aws::Crt::Allocator *) noexcept;
158159
static void s_customDeleter(MessageData *) noexcept;
159-
/* This needs to be defined so that `MessageData` can be used as a key in maps. */
160+
/* This needs to be defined so that `MessageData` can be used as a key in
161+
* maps. */
160162
bool operator<(const MessageData &) const noexcept;
161163
static const char *MODEL_NAME;
162164

@@ -219,7 +221,8 @@ namespace Awstest
219221
Aws::Crt::StringView,
220222
Aws::Crt::Allocator *) noexcept;
221223
static void s_customDeleter(EchoStreamingMessage *) noexcept;
222-
/* This needs to be defined so that `EchoStreamingMessage` can be used as a key in maps. */
224+
/* This needs to be defined so that `EchoStreamingMessage` can be used as a
225+
* key in maps. */
223226
bool operator<(const EchoStreamingMessage &) const noexcept;
224227
static const char *MODEL_NAME;
225228

@@ -249,7 +252,8 @@ namespace Awstest
249252
Aws::Crt::StringView,
250253
Aws::Crt::Allocator *) noexcept;
251254
static void s_customDeleter(GetAllProductsResponse *) noexcept;
252-
/* This needs to be defined so that `GetAllProductsResponse` can be used as a key in maps. */
255+
/* This needs to be defined so that `GetAllProductsResponse` can be used as a
256+
* key in maps. */
253257
bool operator<(const GetAllProductsResponse &) const noexcept;
254258
static const char *MODEL_NAME;
255259

@@ -271,7 +275,8 @@ namespace Awstest
271275
Aws::Crt::StringView,
272276
Aws::Crt::Allocator *) noexcept;
273277
static void s_customDeleter(GetAllProductsRequest *) noexcept;
274-
/* This needs to be defined so that `GetAllProductsRequest` can be used as a key in maps. */
278+
/* This needs to be defined so that `GetAllProductsRequest` can be used as a
279+
* key in maps. */
275280
bool operator<(const GetAllProductsRequest &) const noexcept;
276281
static const char *MODEL_NAME;
277282

@@ -294,7 +299,8 @@ namespace Awstest
294299
Aws::Crt::StringView,
295300
Aws::Crt::Allocator *) noexcept;
296301
static void s_customDeleter(GetAllCustomersResponse *) noexcept;
297-
/* This needs to be defined so that `GetAllCustomersResponse` can be used as a key in maps. */
302+
/* This needs to be defined so that `GetAllCustomersResponse` can be used as a
303+
* key in maps. */
298304
bool operator<(const GetAllCustomersResponse &) const noexcept;
299305
static const char *MODEL_NAME;
300306

@@ -316,7 +322,8 @@ namespace Awstest
316322
Aws::Crt::StringView,
317323
Aws::Crt::Allocator *) noexcept;
318324
static void s_customDeleter(GetAllCustomersRequest *) noexcept;
319-
/* This needs to be defined so that `GetAllCustomersRequest` can be used as a key in maps. */
325+
/* This needs to be defined so that `GetAllCustomersRequest` can be used as a
326+
* key in maps. */
320327
bool operator<(const GetAllCustomersRequest &) const noexcept;
321328
static const char *MODEL_NAME;
322329

@@ -339,7 +346,8 @@ namespace Awstest
339346
Aws::Crt::StringView,
340347
Aws::Crt::Allocator *) noexcept;
341348
static void s_customDeleter(EchoMessageResponse *) noexcept;
342-
/* This needs to be defined so that `EchoMessageResponse` can be used as a key in maps. */
349+
/* This needs to be defined so that `EchoMessageResponse` can be used as a key
350+
* in maps. */
343351
bool operator<(const EchoMessageResponse &) const noexcept;
344352
static const char *MODEL_NAME;
345353

@@ -363,7 +371,8 @@ namespace Awstest
363371
Aws::Crt::StringView,
364372
Aws::Crt::Allocator *) noexcept;
365373
static void s_customDeleter(EchoMessageRequest *) noexcept;
366-
/* This needs to be defined so that `EchoMessageRequest` can be used as a key in maps. */
374+
/* This needs to be defined so that `EchoMessageRequest` can be used as a key
375+
* in maps. */
367376
bool operator<(const EchoMessageRequest &) const noexcept;
368377
static const char *MODEL_NAME;
369378

@@ -385,7 +394,8 @@ namespace Awstest
385394
Aws::Crt::StringView,
386395
Aws::Crt::Allocator *) noexcept;
387396
static void s_customDeleter(EchoStreamingResponse *) noexcept;
388-
/* This needs to be defined so that `EchoStreamingResponse` can be used as a key in maps. */
397+
/* This needs to be defined so that `EchoStreamingResponse` can be used as a
398+
* key in maps. */
389399
bool operator<(const EchoStreamingResponse &) const noexcept;
390400
static const char *MODEL_NAME;
391401

@@ -406,7 +416,8 @@ namespace Awstest
406416
Aws::Crt::StringView,
407417
Aws::Crt::Allocator *) noexcept;
408418
static void s_customDeleter(EchoStreamingRequest *) noexcept;
409-
/* This needs to be defined so that `EchoStreamingRequest` can be used as a key in maps. */
419+
/* This needs to be defined so that `EchoStreamingRequest` can be used as a
420+
* key in maps. */
410421
bool operator<(const EchoStreamingRequest &) const noexcept;
411422
static const char *MODEL_NAME;
412423

@@ -431,7 +442,8 @@ namespace Awstest
431442
Aws::Crt::StringView,
432443
Aws::Crt::Allocator *) noexcept;
433444
static void s_customDeleter(ServiceError *) noexcept;
434-
/* This needs to be defined so that `ServiceError` can be used as a key in maps. */
445+
/* This needs to be defined so that `ServiceError` can be used as a key in
446+
* maps. */
435447
bool operator<(const ServiceError &) const noexcept;
436448
static const char *MODEL_NAME;
437449

@@ -454,7 +466,8 @@ namespace Awstest
454466
Aws::Crt::StringView,
455467
Aws::Crt::Allocator *) noexcept;
456468
static void s_customDeleter(CauseServiceErrorResponse *) noexcept;
457-
/* This needs to be defined so that `CauseServiceErrorResponse` can be used as a key in maps. */
469+
/* This needs to be defined so that `CauseServiceErrorResponse` can be used as
470+
* a key in maps. */
458471
bool operator<(const CauseServiceErrorResponse &) const noexcept;
459472
static const char *MODEL_NAME;
460473

@@ -475,7 +488,8 @@ namespace Awstest
475488
Aws::Crt::StringView,
476489
Aws::Crt::Allocator *) noexcept;
477490
static void s_customDeleter(CauseServiceErrorRequest *) noexcept;
478-
/* This needs to be defined so that `CauseServiceErrorRequest` can be used as a key in maps. */
491+
/* This needs to be defined so that `CauseServiceErrorRequest` can be used as
492+
* a key in maps. */
479493
bool operator<(const CauseServiceErrorRequest &) const noexcept;
480494
static const char *MODEL_NAME;
481495

@@ -533,8 +547,10 @@ namespace Awstest
533547
/**
534548
* Used to activate a stream for the `GetAllProductsOperation`
535549
* @param request The request used for the `GetAllProductsOperation`
536-
* @param onMessageFlushCallback An optional callback that is invoked when the request is flushed.
537-
* @return An `RpcError` that can be used to check whether the stream was activated.
550+
* @param onMessageFlushCallback An optional callback that is invoked when the
551+
* request is flushed.
552+
* @return An `RpcError` that can be used to check whether the stream was
553+
* activated.
538554
*/
539555
std::future<RpcError> Activate(
540556
const GetAllProductsRequest &request,
@@ -596,8 +612,10 @@ namespace Awstest
596612
/**
597613
* Used to activate a stream for the `CauseServiceErrorOperation`
598614
* @param request The request used for the `CauseServiceErrorOperation`
599-
* @param onMessageFlushCallback An optional callback that is invoked when the request is flushed.
600-
* @return An `RpcError` that can be used to check whether the stream was activated.
615+
* @param onMessageFlushCallback An optional callback that is invoked when the
616+
* request is flushed.
617+
* @return An `RpcError` that can be used to check whether the stream was
618+
* activated.
601619
*/
602620
std::future<RpcError> Activate(
603621
const CauseServiceErrorRequest &request,
@@ -617,8 +635,10 @@ namespace Awstest
617635
virtual void OnStreamEvent(EchoStreamingMessage *response) { (void)response; }
618636

619637
/**
620-
* A callback that is invoked when an error occurs while parsing a message from the stream.
621-
* @param rpcError The RPC error containing the status and possibly a CRT error.
638+
* A callback that is invoked when an error occurs while parsing a message
639+
* from the stream.
640+
* @param rpcError The RPC error containing the status and possibly a CRT
641+
* error.
622642
*/
623643
virtual bool OnStreamError(RpcError rpcError)
624644
{
@@ -637,7 +657,8 @@ namespace Awstest
637657
}
638658

639659
/**
640-
* A callback that is invoked upon receiving ANY error response from the server.
660+
* A callback that is invoked upon receiving ANY error response from the
661+
* server.
641662
* @param operationError The error message being received.
642663
*/
643664
virtual bool OnStreamError(OperationError *operationError)
@@ -652,7 +673,8 @@ namespace Awstest
652673
*/
653674
void OnStreamEvent(Aws::Crt::ScopedResource<AbstractShapeBase> response) override;
654675
/**
655-
* Invoked when a message is received on this continuation but results in an error.
676+
* Invoked when a message is received on this continuation but results in an
677+
* error.
656678
*
657679
* This callback can return true so that the stream is closed afterwards.
658680
*/
@@ -708,9 +730,12 @@ namespace Awstest
708730
Aws::Crt::Allocator *allocator = Aws::Crt::g_allocator) noexcept;
709731
/**
710732
* Used to activate a stream for the `CauseStreamServiceToErrorOperation`
711-
* @param request The request used for the `CauseStreamServiceToErrorOperation`
712-
* @param onMessageFlushCallback An optional callback that is invoked when the request is flushed.
713-
* @return An `RpcError` that can be used to check whether the stream was activated.
733+
* @param request The request used for the
734+
* `CauseStreamServiceToErrorOperation`
735+
* @param onMessageFlushCallback An optional callback that is invoked when the
736+
* request is flushed.
737+
* @return An `RpcError` that can be used to check whether the stream was
738+
* activated.
714739
*/
715740
std::future<RpcError> Activate(
716741
const EchoStreamingRequest &request,
@@ -730,8 +755,10 @@ namespace Awstest
730755
virtual void OnStreamEvent(EchoStreamingMessage *response) { (void)response; }
731756

732757
/**
733-
* A callback that is invoked when an error occurs while parsing a message from the stream.
734-
* @param rpcError The RPC error containing the status and possibly a CRT error.
758+
* A callback that is invoked when an error occurs while parsing a message
759+
* from the stream.
760+
* @param rpcError The RPC error containing the status and possibly a CRT
761+
* error.
735762
*/
736763
virtual bool OnStreamError(RpcError rpcError)
737764
{
@@ -740,7 +767,8 @@ namespace Awstest
740767
}
741768

742769
/**
743-
* A callback that is invoked upon receiving ANY error response from the server.
770+
* A callback that is invoked upon receiving ANY error response from the
771+
* server.
744772
* @param operationError The error message being received.
745773
*/
746774
virtual bool OnStreamError(OperationError *operationError)
@@ -755,7 +783,8 @@ namespace Awstest
755783
*/
756784
void OnStreamEvent(Aws::Crt::ScopedResource<AbstractShapeBase> response) override;
757785
/**
758-
* Invoked when a message is received on this continuation but results in an error.
786+
* Invoked when a message is received on this continuation but results in an
787+
* error.
759788
*
760789
* This callback can return true so that the stream is closed afterwards.
761790
*/
@@ -810,8 +839,10 @@ namespace Awstest
810839
/**
811840
* Used to activate a stream for the `EchoStreamMessagesOperation`
812841
* @param request The request used for the `EchoStreamMessagesOperation`
813-
* @param onMessageFlushCallback An optional callback that is invoked when the request is flushed.
814-
* @return An `RpcError` that can be used to check whether the stream was activated.
842+
* @param onMessageFlushCallback An optional callback that is invoked when the
843+
* request is flushed.
844+
* @return An `RpcError` that can be used to check whether the stream was
845+
* activated.
815846
*/
816847
std::future<RpcError> Activate(
817848
const EchoStreamingRequest &request,
@@ -873,8 +904,10 @@ namespace Awstest
873904
/**
874905
* Used to activate a stream for the `EchoMessageOperation`
875906
* @param request The request used for the `EchoMessageOperation`
876-
* @param onMessageFlushCallback An optional callback that is invoked when the request is flushed.
877-
* @return An `RpcError` that can be used to check whether the stream was activated.
907+
* @param onMessageFlushCallback An optional callback that is invoked when the
908+
* request is flushed.
909+
* @return An `RpcError` that can be used to check whether the stream was
910+
* activated.
878911
*/
879912
std::future<RpcError> Activate(
880913
const EchoMessageRequest &request,
@@ -936,8 +969,10 @@ namespace Awstest
936969
/**
937970
* Used to activate a stream for the `GetAllCustomersOperation`
938971
* @param request The request used for the `GetAllCustomersOperation`
939-
* @param onMessageFlushCallback An optional callback that is invoked when the request is flushed.
940-
* @return An `RpcError` that can be used to check whether the stream was activated.
972+
* @param onMessageFlushCallback An optional callback that is invoked when the
973+
* request is flushed.
974+
* @return An `RpcError` that can be used to check whether the stream was
975+
* activated.
941976
*/
942977
std::future<RpcError> Activate(
943978
const GetAllCustomersRequest &request,

format-check.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if NOT type $CLANG_FORMAT 2> /dev/null ; then
1010
fi
1111

1212
FAIL=0
13-
SOURCE_FILES=`find devicedefender discovery iotdevicecommon jobs shadow samples -type f \( -name '*.h' -o -name '*.cpp' \)`
13+
SOURCE_FILES=`find devicedefender discovery eventstream_rpc greengrass_ipc identity iotdevicecommon jobs shadow samples -type f \( -name '*.h' -o -name '*.cpp' \)`
1414
for i in $SOURCE_FILES
1515
do
1616
$CLANG_FORMAT -output-replacements-xml $i | grep -c "<replacement " > /dev/null

greengrass_ipc/include/aws/greengrass/GreengrassCoreIpcClient.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,20 @@ namespace Aws
2828
Aws::Crt::Allocator *allocator = Aws::Crt::g_allocator) noexcept;
2929
/**
3030
* Connect the client to the server
31-
* @param lifecycleHandler An interface that is called upon when lifecycle events relating to the connection
32-
* occur.
33-
* @param connectionConfig The configuration parameters used for establishing the connection.
34-
* @return An `RpcError` that can be used to check whether the connection was established.
31+
* @param lifecycleHandler An interface that is called upon when lifecycle
32+
* events relating to the connection occur.
33+
* @param connectionConfig The configuration parameters used for establishing
34+
* the connection.
35+
* @return An `RpcError` that can be used to check whether the connection was
36+
* established.
3537
*/
3638
std::future<RpcError> Connect(
3739
ConnectionLifecycleHandler &lifecycleHandler,
3840
const ConnectionConfig &connectionConfig = DefaultConnectionConfig()) noexcept;
3941
bool IsConnected() const noexcept { return m_connection.IsOpen(); }
4042
void Close() noexcept;
4143
SubscribeToIoTCoreOperation NewSubscribeToIoTCore(SubscribeToIoTCoreStreamHandler &) noexcept;
44+
ResumeComponentOperation NewResumeComponent() noexcept;
4245
PublishToIoTCoreOperation NewPublishToIoTCore() noexcept;
4346
SubscribeToConfigurationUpdateOperation NewSubscribeToConfigurationUpdate(
4447
SubscribeToConfigurationUpdateStreamHandler &) noexcept;
@@ -66,6 +69,7 @@ namespace Aws
6669
SubscribeToComponentUpdatesStreamHandler &) noexcept;
6770
ListLocalDeploymentsOperation NewListLocalDeployments() noexcept;
6871
StopComponentOperation NewStopComponent() noexcept;
72+
PauseComponentOperation NewPauseComponent() noexcept;
6973
CreateLocalDeploymentOperation NewCreateLocalDeployment() noexcept;
7074
~GreengrassCoreIpcClient() noexcept;
7175

0 commit comments

Comments
 (0)