dnsimple / erldns

DNS server, in Erlang.
MIT License
398 stars 98 forks source link

Merge RRset operations into master #100

Closed m0rcq closed 3 years ago

m0rcq commented 4 years ago

operations for RRSets over the wire without full zone unload/load.

m0rcq commented 4 years ago

Suggestions are welcome to fix the spec below trying to capture two different argument patterns.

https://github.com/dnsimple/erldns/pull/100/commits/3b0c4036e5cbc1c161fe5997df0d13c474e9f846#diff-8a8e060b9a8de98f1aa024db2afad89bR266

m0rcq commented 4 years ago

@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.

https://github.com/dnsimple/erldns-zoneclient/blob/master/src/erldns_zoneclient_zoneserver_monitor.erl#L137

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:

Or some other approach?

aeden commented 4 years ago

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

m0rcq commented 4 years ago

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