einsteinx2 / WaveBox

A free, open source personal media server written in C# and available on all platforms thanks to the Mono framework. GPL3 Licensed.
waveboxapp.com
GNU General Public License v3.0
32 stars 12 forks source link

Proposal: move all WaveBox sub-services to an "init"-style service interface #109

Closed mdlayher closed 11 years ago

mdlayher commented 11 years ago

I've been thinking about this for a little while now, and talked it over with Justin tonight. As the WaveBox code base continues to grow, and as we add more features, I feel as though we should look into creating a unified "init"-style interface, through which all WaveBox sub-services are managed.

For example, we are currently running the following sub-services in WaveBox: NAT, Dynamic DNS, HTTP, Device Sync, ZeroConf, Crash Reporter, Auto Updater, and some "cronjob"-like delayed operations (Podcast Download, Session Scrubber).

As we continue to add future services (MPD, DLNA, Last.fm Parser, Musicbrainz Parser, etc.), it will become more and more cumbersome to maintain each of these services, as they all have different method signatures and configuration.

In order to mitigate these difficulties, I propose that we create a sort of Init manager and interface for WaveBox, which will spin off and manage each of these sub-services, without further cluttering the main and configuration files. In addition, we can add a new Cron service to replace the delayed operation queues, so that all timed services run under a unified timer, rather than maintaining their own.

In order to simplify configuration and remove all of the boolean service toggles currently present, we could use an Arch Linux-style array of services which will be launched at startup. For example:

// Define which services WaveBox will launch on startup
"services": ["dynamicdns", "nat", "devicesync", "zeroconf", "mpd", "lastfm", "musicbrainz"]

I did not include HTTP, File Manager, User Manager, or Cron, as I feel these are integral to WaveBox, and should run regardless of configuration.

I think the project could seriously benefit from a more abstracted and unified sub-service interface, and would like to begin working on an initial concept in the next couple of days. Let me know if you guys have any thoughts on the matter!

einsteinx2 commented 11 years ago

I love this idea, let's do it.

mdlayher commented 11 years ago

Way ahead of you! So far, I've got AutoUpdate, (basic) Cron, DynamicDns, Http, Nat, and ZeroConf all ported.

einsteinx2 commented 11 years ago

Sweet, can you push some of it to your repo so I can take a look?

mdlayher commented 11 years ago

As we are (currently) discussing on Hangouts, the Services layer is pretty much ready to go. I've ported the following to use services:

autoupdate, cron, devicesync, dynamicdns, filemanager, http, jukebox, nat, transcode, and zeroconf

Adding a new service is akin to adding an API handler: you add a class which implements the IService interface, and add a line to the switch in ServiceFactory, and you're good to go!

mdlayher commented 11 years ago

Merged as of #111 .