phuedx / pinc

A network connection conditioner for a handful of low-end devices in my home office
MIT License
16 stars 3 forks source link

Remove exec abstraction #12

Open phuedx opened 6 years ago

phuedx commented 6 years ago

Currently, src/server/exec.js is relied upon to abstract away whether or not to shell out the tc commands from the profiles service. When in dev mode, require('/path/to/exec').exec( '...' ) is a NOP.

If we were to separate out the caching part of the profiles service from the tc part, define an interface and its null implementation, then we can safely remove the abstraction by composing these new services:

const profilesService = require('...')
const cachingProfilesService = require('...')
const nullProfilesService = require('...')

const profileService = cachingProfilesService( IS_PROD ? profilesService : nullProfilesService )