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

Ensure delivery of bind success response before further messages sent #249

Open
github-actions bot opened this issue Mar 5, 2022 · 0 comments
Open
Labels
priority: low todo type: bug something isn't working type: enhancement new feature or request

Comments

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

  • Keep a flag in @bindings hash, set the flag as success message has been sent
  • Notify update gets subscription, checks @bindings for flag and waits on channel if not ready

# Bind a websocket to a module subscription
#
def bind(
request_id : Int64,
system_id : String,
module_name : String,
index : Int32,
name : String
)
Log.debug { "binding to module" }
begin
# Check if module previously bound
unless has_binding?(system_id, module_name, index, name)
return unless create_binding(request_id, system_id, module_name, index, name)
end
rescue error
Log.warn(exception: error) { "websocket binding could not find system" }
respond(error_response(request_id, :module_not_found, "could not find module: sys=#{system_id} mod=#{module_name}"))
return
end
# Notify success
# TODO: Ensure delivery of success before messages
# - keep a flag in @bindings hash, set flag once success sent and send message on channel
# - notify update gets subscription, checks binding hash for flag, otherwise wait on channel
# Could use a promise
response = Response.new(
id: request_id,
type: :success,
metadata: {
sys: system_id,
mod: module_name,
index: index,
name: name,
},
)
respond(response)
rescue e
Log.error(exception: e) { {
message: "failed to bind",
error: e.message,
} }
respond(error_response(request_id, :unexpected_failure, "failed to bind"))
end

@github-actions github-actions bot added the todo label Mar 5, 2022
@caspiano caspiano changed the title Ensure delivery of success before messages Ensure delivery of bind success response before further messages sent Mar 5, 2022
@caspiano caspiano added the type: enhancement new feature or request label Mar 5, 2022
@caspiano caspiano removed their assignment Mar 5, 2022
@caspiano caspiano added priority: low type: bug something isn't working labels May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: low todo type: bug something isn't working type: enhancement new feature or request
Projects
None yet
Development

No branches or pull requests

1 participant