Skip to content

Make parameter API synchronous#80

Merged
madelen-at-work merged 1 commit intomainfrom
non-stream-param
Aug 27, 2024
Merged

Make parameter API synchronous#80
madelen-at-work merged 1 commit intomainfrom
non-stream-param

Conversation

@madelen-at-work
Copy link
Contributor

@madelen-at-work madelen-at-work commented Aug 15, 2024

Describe your changes

To align with usage (i.e the Parameter API example, we change the implementation of the Parameter API to synchronous gRPC communication.

Checklist before requesting a review

  • I have performed a self-review of my own code
  • I have verified that the code builds perfectly fine on my local system
  • I have added tests that prove my fix is effective or that my feature works
  • I have commented my code, particularly in hard-to-understand areas
  • I have verified that my code follows the style already available in the repository
  • I have made corresponding changes to the documentation

@madelen-at-work madelen-at-work requested review from a team as code owners August 15, 2024 10:06
@madelen-at-work madelen-at-work changed the base branch from main to parameter-api August 15, 2024 10:07

char parhand_result[BUFSIZ];
// Initialize Parameter Service
bool Parameter::Init(const bool verbose)
Copy link
Contributor

Choose a reason for hiding this comment

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

If Parameter::Init was instead the class constructor, throwing runtime_error on failure, there wouldn't be a need to check ax_parameter == NULL before assignment and it wouldn't have to be checked at destruction. But maybe it's not worth the effort.

}
Status Parameter::GetValues(ServerContext *context, const Request *request, Response *response)
{
if (ax_parameter == NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it actually is worth the effort, because by initializing ax_parameter in the constructor, it is guaranteed to be always initialized.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure it is - this API has so far followed the same 'pattern' as the two other (i.e. using Init instead of a constructor). I don't see any real benefit in refactoring this API only.

{
ERRORLOG << "Error when getting axparameter: " << _error->message << endl;
parameter_value = g_strdup("");
g_clear_error(&_error);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why doesn't this lead to returning an error code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is inline with how the API works now - as long as the format of the key is correct it will return an empty value and gRPC Status::OK

struct tm *nTime = localtime(&now);
int nowTime = nTime->tm_hour;
if (nowTime != logTime)
namespace parameter_test
Copy link
Contributor

Choose a reason for hiding this comment

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

Starting with C++17, you can write this as namespace acap_runtime::parameter_test

Base automatically changed from parameter-api to main August 27, 2024 13:48
@madelen-at-work madelen-at-work merged commit 7babb34 into main Aug 27, 2024
@madelen-at-work madelen-at-work deleted the non-stream-param branch August 27, 2024 14:38
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.

3 participants