@practicaloptimism/uniplexer
Version:
A multiplexer for 3rd party service providers and application protocols
78 lines (59 loc) • 1.89 kB
text/typescript
class ProcessRunner {
runnerId: string = ''
schedulerTable: { [schedulerId: string]: ProcessScheduler } = {}
processQueue: Process[] = []
processTable: { [processId: string]: Process } = {}
}
class ProcessScheduler {
schedulerId: string = ''
millisecondDelayFrequency: number = 10
processIdQueue: string[] = []
processTable: { [processId: string]: Process } = {}
}
/*
How Scheduling works:
- add a process
- the process has a date to be processed
- use the date to determine whether to store the process
in memory or in a database for later processing
- use the date to determine which scheduler will check
the process to see if it should be checked by another
scheduler. The highest frequency scheduler will run the
process. So eventually all the processes will be run
by the high frequency scheduler which has a much smaller
delay than any other process (theoretically 0 but tactically
it will be above 0.. on second thought maybe it will
also be 0 for high speed processes.. still need to think
about this..)
*/
class Process {
processId: string = ''
creatorIdList: string[] = []
dateToProcess?: Date
dateProcessed?: Date
// howManyTimesToProcess: number = 1
cancelOperation: boolean = false
processorId: string = ''
dateCancelled?: Date
// the process to be run
processOperation?: ProcessOperation
errorData: any = ''
}
class ProcessOperation {
functionName: string = ''
inputList: any[] = []
}
interface ProcessRunnerProvider {
getProcess (processId: string, extract?: any): any
saveProcess (processId: string, process: Process, extract?: any): any
updateProcess (processId: string, extract?: any): any
deleteProcess (processId: string, extract?: any): any
}
interface ComputerServiceMultiplexer {
something (): void
}
export {
ComputerServiceMultiplexer,
ProcessRunner,
ProcessRunnerProvider
}