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

Add golioth_rpc_deinit() API #478

Merged
merged 5 commits into from
May 21, 2024
Merged

Add golioth_rpc_deinit() API #478

merged 5 commits into from
May 21, 2024

Conversation

szczys
Copy link
Contributor

@szczys szczys commented May 2, 2024

  • Add internal ability to cancel observations by path prefix
  • Add API to cancel RPC observations and deinitialize the context struct

resolves https://github.com/golioth/firmware-issue-tracker/issues/520

Copy link

github-actions bot commented May 2, 2024

Visit the preview URL for this PR (updated for commit 6fa46b1):

https://golioth-firmware-sdk-doxygen-dev--pr478-szczys-add-rpc-z2qrnhn3.web.app

(expires Tue, 28 May 2024 16:12:18 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: a9993e61697a3983f3479e468bcb0b616f9a0578

Copy link

github-actions bot commented May 2, 2024

Code Coverage

Type Coverage
lines 58.8% (1258 of 2140 lines)
functions 65.8% (125 of 190 functions)

@szczys szczys changed the base branch from main to szczys/cancel_observations May 3, 2024 13:27
@szczys szczys force-pushed the szczys/add_rpc_cancel branch 3 times, most recently from 83c528d to 4336422 Compare May 3, 2024 14:45
include/golioth/rpc.h Outdated Show resolved Hide resolved
include/golioth/rpc.h Outdated Show resolved Hide resolved
@szczys szczys force-pushed the szczys/cancel_observations branch from 161664d to 26ecaa6 Compare May 7, 2024 20:59
@szczys szczys force-pushed the szczys/add_rpc_cancel branch 3 times, most recently from 7adb16d to 56a80b0 Compare May 8, 2024 02:07
Copy link
Collaborator

@mniestroj mniestroj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@szczys szczys force-pushed the szczys/cancel_observations branch 2 times, most recently from 5752223 to 19334fc Compare May 10, 2024 16:56
@@ -23,5 +23,5 @@ DECLARE_FAKE_VALUE_FUNC(enum golioth_status,
bool,
int32_t);
DECLARE_FAKE_VOID_FUNC(golioth_coap_client_cancel_observations_by_prefix,
struct golioth_client *,
const char *);
struct golioth_client *,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT: would be cleaner to fix this in the previous commit.

src/rpc.c Outdated
@@ -234,6 +234,20 @@ struct golioth_rpc *golioth_rpc_init(struct golioth_client *client)
return grpc;
}

enum golioth_status golioth_rpc_deinit(struct golioth_client *client, struct golioth_rpc *grpc)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can extract client from grpc so this function only needs one argument.

@szczys szczys force-pushed the szczys/cancel_observations branch from 19334fc to 724cfae Compare May 20, 2024 19:06
@szczys szczys force-pushed the szczys/add_rpc_cancel branch 2 times, most recently from 65aae50 to 89d18f7 Compare May 20, 2024 19:49
Base automatically changed from szczys/cancel_observations to main May 20, 2024 21:51
@szczys szczys requested a review from sam-golioth May 21, 2024 04:26
The prefix indicates the type of observation and will be be used by the
service APIs to cancel by service.

Signed-off-by: Mike Szczys <[email protected]>
The prefix indicates the type of observation and will be be used by the
service APIs to cancel by service.

Signed-off-by: Mike Szczys <[email protected]>
Implement golioth_coap_client_cancel_observations_by_prefix() to wrap the
functions provided by the ports.

Signed-off-by: Mike Szczys <[email protected]>
Add golioth_rpc_deinit() function that cancels RPC observations and frees
the RPC context struct (used to store the registered RPC paths/methods).

Signed-off-by: Mike Szczys <[email protected]>
Update the test to use the RPC deinit API instead of the internal cancel
observations function.

Signed-off-by: Mike Szczys <[email protected]>
@szczys szczys merged commit e79073e into main May 21, 2024
39 of 42 checks passed
@szczys szczys deleted the szczys/add_rpc_cancel branch May 21, 2024 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants