[bind10-dev] #2376 and more lightweight approach

Michal 'vorner' Vaner michal.vaner at nic.cz
Tue Nov 13 11:40:49 UTC 2012


Hello

I'm bit worried about useless layers of glue classes that do nothing in our
code. I can find them from time to time and I believe they are hard to read whet
someone who does not know the code finds them.

A concrete example of this is ticket #2376, the LoaderContext class. Effectively
it holds 3 callbacks (one for adding RRsets, two for reporting errors).
The only current implementation will:
 • Log the errors.
 • Call the addRRset method of ZoneUpdater. Verbatim, unmodified.

That seems a little bit overkill to have an abstract base class, concrete
implementation and yet another helper class for this to me. So the proposal is
to simply pass the callbacks to constructor of the MasterLoader, like this:

  MasterLoader(const boost::function<void (const RRsetPtr&)>& addRRset,
               const boost::function<void (string, size_t, string)>& warning,
               const boost::function<void (string, size_t, string)>& error);

We could as well unify the warning and error handlers to one, as they are
expected to be very similar, something like:

  void issue(bool severe, const string& filename, size_t line, const string& reason);

This will allow it to be passed conveniently around to the RR factories.

And possibly put both callbacks together into a std::pair. So we could have:

typedef boost::function<void (const std::string&, size_t, const std::string&)>
    IssueCallback;
typedef boost::function<void (const RRsetPtr&)> AddRRsetCallback;
typedef std::pair<AddRRsetCallback, IssueCallback> LoaderCallbacks;

This has one disadvantage. It is harder to extend with some kind of state or
more callbacks. But, I don't really see a place where more callbacks or state
would fit in.

What is your opinions?

Thank you

-- 
Never underestimate the bandwidth of a station wagon full of HDDs.

Michal 'vorner' Vaner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <https://lists.isc.org/pipermail/bind10-dev/attachments/20121113/9518251d/attachment.bin>


More information about the bind10-dev mailing list