sociomantic-tsunami / swarm

Asynchronous client/node framework library
Boost Software License 1.0
14 stars 26 forks source link

Dismantle core node framework #57

Open gavin-norman-sociomantic opened 7 years ago

gavin-norman-sociomantic commented 7 years ago

The node framework in swarm.core provides many useful components for building nodes. Currently, they are all glued together in a very rigid way. There is essentially one class (ChannelsNodeBase) which all nodes must derive from, in order to be able to access the full range of features. As the different types of nodes diverge in their needs, however, this approach is becoming less useful. A nicer approach would be to separate out each of the components so that they can be assembled as required.

Components:

It's interesting that the majority of the really interconnected stuff is for stats tracking / logging. Probably a better approach would be to have separate stats instances for different things (per-request, global I/O, etc), each with a log() method.

gavin-norman-sociomantic commented 7 years ago

A note on the node information interfaces: it seems that they are unnecessary. For the swarm clients they totally make sense -- you have internal classes that do magic stuff which should absolutely not be exposed to the user, but you want to present the user an interface to the classes with purely non-destructive methods. In the case of the swarm nodes, however, there is no "user" to protect from scary internals.

It seems like these interfaces should just be removed; they serve no purpose and just make things more complicated.

gavin-norman-sociomantic commented 7 years ago

A note on the node information interfaces: it seems that they are unnecessary.

Actually, they do serve a purpose: the actual node base classes are templated, so accessing the node via one of these information interfaces saves having to store templated references all over the place.