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

Handle encoding/coercing/validation in the encoder #167

Merged
merged 2 commits into from
Feb 14, 2014
Merged

Conversation

liveh2o
Copy link
Contributor

@liveh2o liveh2o commented Feb 14, 2014

Rather than having the dispatcher coerce and validate responses or handle that in a separate middleware, move it all into the encoder.

This should make it easier for other middlewares to hook in before or after the coercion and validation.

// @localshred @abrandoned

@@ -135,7 +135,7 @@ def callable_rpc_method(method_name)
# Register a failure callback for use when rpc_failed is invoked.
#
def on_rpc_failed(callable)
@_rpc_failed_callback ||= callable
@_rpc_failed_callback = callable
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 why this would be useful, but I left it in while setting up a default. It allowed me to cleanup the dispatcher.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was going to mention it, it's a kind of wonky pattern (I created) with the method handle. Rather than the send, I'd just have that method return a lambda, or just set the lambda in the initializer directly. Chalk it up as another "feature" that never materialized.

Copy link
Contributor

Choose a reason for hiding this comment

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

In other words, KILL IT!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider it done.

Rather than having the dispatcher coerce and validate responses or
handle that in a separate middleware, move it all into the encoder.
Instead of providing a callback hook that is fired when rpc_failed is
called, just take the given message and raise an RPC failed error.
@localshred
Copy link
Contributor

Count me a fan! 👍

liveh2o added a commit that referenced this pull request Feb 14, 2014
Handle encoding/coercing/validation in the encoder
@liveh2o liveh2o merged commit c28632c into master Feb 14, 2014
@liveh2o liveh2o deleted the encode_everything branch February 14, 2014 20:33
@liveh2o
Copy link
Contributor Author

liveh2o commented Feb 14, 2014

Closes #154

liveh2o added a commit that referenced this pull request Feb 16, 2014
Handle encoding/coercing/validation in the encoder
@localshred localshred added this to the v3.x milestone Feb 19, 2014
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.

2 participants