Last active
July 21, 2022 00:28
-
-
Save mamund/d488f73efebcd48ae0580ec670adcfe7 to your computer and use it in GitHub Desktop.
prototype for a composable service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jobInterface(args) { | |
function init(args) {} | |
function stateRead(args) {} | |
function stateWrite(args) {} | |
function JobStart(args) {} | |
function JobCancel(args) {} | |
function JobRestart(args) {} | |
function JobRevert(args) {} | |
} | |
var taskInterface(args) { | |
function init(args) {} | |
function stateRead(args) {} | |
function stateWrite(args) {} | |
function taskExecute(args) {} | |
function taskCancel(args) {} | |
function taskRepeat(args) {} | |
function taskRevert(args) {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var composableService(args) { | |
// internals | |
var globals = {}; | |
globals.stateData = args.stateData||{}; | |
globals.jobId = args.jobId||null; | |
globals.taskId = args.taskId||null; | |
globals.maxTTLSeconds = args.maxTTLSeconds||60; | |
globals.maxRetries = args.maxRetries||3; | |
// actions | |
function init(args) {...} | |
function stateRead(args) {...} | |
function stateWrite(args) {...} | |
function execute(args) {...} | |
function repeat(args) {...} | |
function revert(args) {...} | |
function restart(args) {...} | |
function cancel(args) {...} | |
// externals | |
var that = {}; | |
that.stateData = globals.stateData; | |
that.jobId = globals.jobId; | |
that.taskId = globals.taskId; | |
that.stateRead = stateRead | |
that.stateWrite = stateWrite; | |
that.execute = execute; | |
that.repeat = repeat; | |
that.revert = revert; | |
that.restart = restart; | |
that.cancel = cancel; | |
return that; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment