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

Refactor Thrift.Transport.SSL.configuration/1 #517

Merged
merged 2 commits into from
Nov 9, 2020

Conversation

pguillory
Copy link
Collaborator

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.

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.
@pguillory
Copy link
Collaborator Author

I must have closed #511 accidentally.

{:ok, opts} ->
handle_optional(opts)

{:error, %_exception{}} = error ->
Copy link
Member

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.

Copy link
Collaborator Author

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 ->
Copy link
Member

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.

Copy link
Collaborator Author

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.

@pguillory pguillory merged commit 5a62391 into pinterest:master Nov 9, 2020
@pguillory pguillory deleted the refactor_ssl_config branch November 9, 2020 19:11
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