-
Notifications
You must be signed in to change notification settings - Fork 12
NOISSUE: Return Response on Computation Termination. #211
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
NOISSUE: Return Response on Computation Termination. #211
Conversation
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
msg := &pkgmanager.ClientStreamMessage_StopComputationRes{StopComputationRes: &pkgmanager.StopComputationResponse{ | ||
ComputationId: mes.StopComputation.ComputationId, | ||
}} | ||
if err := client.svc.Stop(ctx, mes.StopComputation.ComputationId); err != nil { | ||
if errors.Contains(err, manager.ErrNotFound) { | ||
msg.StopComputationRes.Message = err.Error() | ||
msg.StopComputationRes.Stopped = false | ||
if err := client.stream.Send(&pkgmanager.ClientStreamMessage{Message: msg}); err != nil { | ||
return err | ||
} | ||
return nil | ||
} | ||
msg.StopComputationRes.Message = err.Error() | ||
msg.StopComputationRes.Stopped = false | ||
if err := client.stream.Send(&pkgmanager.ClientStreamMessage{Message: msg}); err != nil { | ||
return err | ||
} | ||
return err | ||
} | ||
msg.StopComputationRes.Stopped = true | ||
if err := client.stream.Send(&pkgmanager.ClientStreamMessage{Message: msg}); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactor and simplify definition of the stop message and sending it. ideally you should have only one stream send and one definition of the message.
manager/manager.proto
Outdated
bool stopped = 2; | ||
string message = 3; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you probably don't need stopped, message can be an empty string for nil error and some message in case of error
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
manager/service_test.go
Outdated
assert.Len(t, ms.vms, 0) | ||
} | ||
|
||
// Clear the events channel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Clear the events channel |
return ErrNotFound | ||
} | ||
if err := cvm.Stop(); err != nil { | ||
return err |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another event here
Signed-off-by: WashingtonKK <washingtonkigan@gmail.com>
What type of PR is this?
This is an enhancement since it enhances computation termination by sending back a response on the status of the activity.
What does this do?
This returns a response on computation termination to inform the user on the status of computation termination.
Which issue(s) does this PR fix/relate to?
No issue
Have you included tests for your changes?
Tested manually.
Did you document any new/modified feature?
Notes
Required for: https://github.com/ultravioletrs/prism/pull/407