Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Please find my first pull request to this project. It aims to enable the option to automatically try to reconnect to the LDAP server if the connection is closed. As I already mentionned in an issue, I am quite new to Elixir, so feel free to adapt this PR to what suits best.
In particular, if the new configuration
retry_on_connection_closed
is set totrue
, then each call toGenServer.call
is observed bydo_call_or_retry/2
. If it returns a{:error, :ldap_closed}
or a{:error, {:gen_tcp_error, term}}
, then it callsPaddle.reconnect
and resends the request.I have not been able to find an equivent of
:gen_tcp_error
for the:ssl
-module, but I think, based on eldap.erl'sdo_send/3
, that both (maybe erroneously) return:gen_tcp_error
.I sadly wasn't able to reproduce the configuration for the tests, but I don't expect any to fail. But that would be something to check for in the QA.
It is tricky to write tests for this PR, and I wasn't really able to do so. My approach to ensure a correct behaviour:
:ldap_closed
errors, that is, when:eldap
is able to close the connection properly, I just killed the socket using ss. It would be quite easy to implement, but I wasn't comfortable with adding this as a dependency, as it would be quite hard to setup for the users anyway.:gen_tcp_error
, it's quite tricky, and I just played with my LDAP server a little bit. What should really be done in order to properly insure that it behaves as expected would be using a tool that allows for connections drop, as for instance toxiproxy does. But that's a lot of work, that I'm not willing to put in right now, and again, there is the extra dependency issue.With my best regards !