Prepend broker files with Memory

Co-authored-by: Fredrik Adelöw <freben@gmail.com>
Co-authored-by: blam<ben@blam.sh>
Co-authored-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Johan Haals
2021-01-22 11:58:59 +01:00
parent fcbfc56be8
commit 06da4425e0
3 changed files with 7 additions and 7 deletions
@@ -25,7 +25,7 @@ export interface Database {
setStatus(taskId: string, status: Status): Promise<void>;
}
export class InMemoryDatabase implements Database {
export class MemoryDatabase implements Database {
private readonly store = new Map<string, DbTaskRow>();
async heartBeat(runId: string): Promise<void> {
@@ -14,11 +14,11 @@
* limitations under the License.
*/
import { InMemoryDatabase } from './Database';
import { MemoryTaskBroker, TaskAgent } from './TaskBroker';
import { MemoryDatabase } from './MemoryDatabase';
import { MemoryTaskBroker, TaskAgent } from './MemoryTaskBroker';
describe('MemoryTaskBroker', () => {
const storage = new InMemoryDatabase();
const storage = new MemoryDatabase();
const broker = new MemoryTaskBroker(storage);
it('should claim a dispatched work item', async () => {
@@ -21,12 +21,12 @@ import {
TaskBroker,
DispatchResult,
} from './types';
import { InMemoryDatabase } from './Database';
import { MemoryDatabase } from './MemoryDatabase';
export class TaskAgent implements Task {
private heartbeartInterval?: ReturnType<typeof setInterval>;
static create(state: TaskState, storage: InMemoryDatabase) {
static create(state: TaskState, storage: MemoryDatabase) {
const agent = new TaskAgent(state, storage);
agent.start();
return agent;
@@ -35,7 +35,7 @@ export class TaskAgent implements Task {
// Runs heartbeat internally
private constructor(
private readonly state: TaskState,
private readonly storage: InMemoryDatabase,
private readonly storage: MemoryDatabase,
) {}
get spec() {