-
Notifications
You must be signed in to change notification settings - Fork 44
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
Refactor Thrift.Transport.SSL.configuration/1 #517
Conversation
The implementation did not respect its type signature, which specified that the error form of the return value should contain an exception as the second element. This expectation is relied upon by maybe_ssl_handshake. However the callback passed in the :configure option could return anything, and we return its response without fully verifying that it matches the configuration typespec. Also refactored the code for clarity.
I must have closed #511 accidentally. |
lib/thrift/transport/ssl.ex
Outdated
{:ok, opts} -> | ||
handle_optional(opts) | ||
|
||
{:error, %_exception{}} = error -> |
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.
This is a little defensive as elixir patterns go because the second tuple would always match given the rest of the code. Usually wed only be so defensive at the edge of an API this defensively, which youve done below from the callback result.
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.
Sure that's fine.
@@ -43,26 +49,23 @@ defmodule Thrift.Transport.SSL do | |||
{:ok, extra_opts} -> | |||
{:ok, extra_opts ++ opts} | |||
|
|||
{:error, _} = error -> | |||
{:error, %_exception{}} = error -> |
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.
Perhaps Exception.exception?
if we want to check this as an exception is more than struct
.
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.
For now I've just matched the same pattern as in protocol_handler.ex and client.ex.
The implementation did not respect its type signature, which specified that the
error form of the return value should contain an exception as the second
element. This expectation is relied upon by maybe_ssl_handshake. However the
callback passed in the :configure option could return anything, and we return
its response without fully verifying that it matches the configuration
typespec.
Also refactored the code for clarity.