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

Updates behavior when new session name is in use in different resource repository. #687

Merged
merged 5 commits into from
Jul 29, 2022

Conversation

reckenro
Copy link
Collaborator

@reckenro reckenro commented Jul 27, 2022

What does this Pull Request accomplish?

  • Created a new SessionException struct in the shared library
  • Throw a SessionException from the session resource repository when trying to add a session that's already in a different resource repository instead of returning a warning status of 1.
  • Update codegen so all "Init" service handlers catch the new SessionException and return a gRPC Status of INVALID_ARGUMENT with the exception's message attached.
  • Update the session resource repository unit test to now expect the SessionException to be thrown when trying to add a session where the session name is already in use in a different resource repository.

Why should this Pull Request be merged?

Addresses #685

If a proposed session name is already used by a different driver, grpc-device was returning a warning status 1 on the return message's status field. This both allows programs making the call to keep running since it's treated as a warning and if the client does check the status code it can be ambiguous depending on the driver.

This change addresses this by instead immediately returning a gRPC Status of INVALID_ARGUMENT with a message explaining that the session name is already in use.

What testing has been done?

Updated a unit test testing the old behavior to now ensure the new SessionException is thrown if the session name is used in a different resource repository.

Ran the examples like they were specified in the Issue.

Now, running the daqmx example while dcpower is running using "my task" as the session name produces:

PS ~\grpc-device\examples\nidaqmx> python .\analog-input.py
The session name "my task" is being used by a different driver.

And similarly, running the dcpower example while the daqmx example is running (with time.wait(60.0)) stops the program with the same message:

PS ~\grpc-device\examples\nidcpower> python .\measure-record.py
The session name "my task" is being used by a different driver.

@reckenro reckenro requested a review from astarche as a code owner July 27, 2022 20:06
@reckenro reckenro changed the title Updates behavior when session creation name conflicts between two drivers. Updates behavior when new session name is in use in different resource repository. Jul 27, 2022
@astarche astarche added the binary-breaking Change to proto file that requires client updates label Jul 29, 2022
Copy link
Collaborator

@astarche astarche left a comment

Choose a reason for hiding this comment

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

Nice fix!

@astarche
Copy link
Collaborator

@reckenro I added the breaking change tag here. The old behavior was pretty wrong and a bit of an edge/probably-a-mistake case anyway. But (I think) it's possible that someone could have worked around the old behavior in a way that would now break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
binary-breaking Change to proto file that requires client updates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants