Closed m0rcq closed 3 years ago
Suggestions are welcome to fix the spec below trying to capture two different argument patterns.
@aeden:
map_rrset_type/1 has been moved to erldnsimple_zone_parser.erl and I am trying to find a clean way to inject the function into erldns_zoneclient on startup, but looking into the current flow:
https://github.com/dnsimple/erldnsimple/blob/master/src/erldnsimple.erl#L12 [...] application:ensure_all_started(erldnsimple).
the erldns_zoneclient:start() is not called explicitly, but relies on the application specification defined in https://github.com/dnsimple/erldnsimple/blob/master/src/erldnsimple.app.src#L16.
as per specification: http://erlang.org/doc/man/app.html
The mod accepts StartArgs but only for modules in the current application i.e erldnsimple, where erldns_zoneclient application fails out of this scope.
the start_phases can be used as it will call the primary application, plus all the dependent applications, but they will need to have Module:start_phases/3 defined which is not the right path for such a simple feat as providing higher-order fun to another application.
The erldns_zoneclient_app creates the supervisor in start/2 https://github.com/dnsimple/erldns-zoneclient/blob/master/src/erldns_zoneclient_app.erl#L25
and the supervisor creates the erldns_zoneclient_server_monitor child process here: https://github.com/dnsimple/erldns-zoneclient/blob/master/src/erldns_zoneclient_sup.erl#L47
On top of this we have the actual function which handles websocket ingress defined as higher-order fun for the websocket_client library.
As we have multiple logic points mixing application + supervisors behaviour, what do you think will be cleanest approach to inject a function from the parent process (erldnsimple)?
Should I try to:
have explicit erldns_zoneclient:start(Args) in erldnsimple:start() instead of relying on the application spec
explicit init(Args) in erldnsimple_sup Supervisor: https://github.com/dnsimple/erldnsimple/blob/master/src/erldnsimple_sup.erl#L19
Or some other approach?
I think you'll likely need an approach similar to how handlers are injected into erldns: https://github.com/dnsimple/erldns/blob/master/src/erldns_handler.erl
I think you'll likely need an approach similar to how handlers are injected into erldns: https://github.com/dnsimple/erldns/blob/master/src/erldns_handler.erl
Roger that - will implement using similar approach @ gen_server's erldns_zoneclient_zoneserver_monitor
operations for RRSets over the wire without full zone unload/load.