summaryrefslogtreecommitdiff
path: root/lib/nickserver/dispatcher.rb
AgeCommit message (Collapse)Author
2018-02-05feature: enamble wkd lookupfeature/web-key-directoryAzul
fixes #1
2017-09-23style: rubocop mostly auto-correctAzul
2017-07-21fix: filedescriptor leak from http_adaptersAzul
Now we reuse a single adapter for all requests triggered by an incoming request. Then we .terminate the adapter. Includes a regression test.
2016-09-30logging: use proper loggerAzul
This way the logs do not interfere with test output
2016-09-29use stderr for errorsAzul
2016-09-29skip tests with ConnectionErrorsAzul
We handle these errors nicely in the dispatcher and have tests for that. Tests should fail or err out when running into exceptions we are not handling yet. But for these it's better to just skip.
2016-09-24log HTTP::ConnectionErrors, respond with json bodyAzul
2016-09-22feature: 502 on ConnectionErrorsAzul
If one source raises a 502 and no other handler has any result we'll respond with a 502 - bad gateway.
2016-09-21feature: activate nicknym lookupAzul
2016-09-19refactor: separate handler chain from dispatcherAzul
Handler Chain is of handlers that respond to call. Invoking handle(*args) on the chain will call the handlers with the given args until one of them returns a result that is truethy (i.e. not false or nil). Extracted from the dispatcher so we can also handle exceptions there in the future. (So that if one of the network connections to the request_handlers fails we can continue while still tracking the failed exception.)
2016-09-12[wip] nicknym source query implementedAzul
Also changed Nickserver::Response to not include the status code. This may be okay for error responses but in most cases we want to have a parsable message and not some status code prepended to it.
2016-08-30refactor: make the RequestHandler classes callableAzul
Whenever a RequestHandler class is called we instantiate it with the request. Then we call handle on the instance. This way we can access the request and its content via accessors rather than only in the handle method.
2016-08-30refactor: rename EmailHandler to HkpEmailHandlerAzul
2016-08-29refactor: split EmailHandler in 3Azul
InvalidEmailHandler - handle emails with an invalid format LocalEmailHandler - handle emails on the local domain EmailHandler - handle all other emails by using hkp This is a preparation to add leap provider email lookup and remove hkp eventually. But for now we keep the behaviour the same and only refactor.
2016-08-29refactor: let handlers check if they are applicableAzul
Instead of testing the preconditions for each handler in the dispatcher the dispatcher hands a request to one handler after the other until one of them responds. This is similar to the Chain of Responsibility patter but we iterate over the 'handler_chain' array instead of a linked list. To change the order of handlers or add other handlers change the array in the handler_chain function.
2016-08-29refactor: split up ResponseHandlerAzul
Now we have a Dispatcher and two ResponseHandlers that have the same interface. Moving towards a Chain of Responsibility pattern.