Skip to content

Commit

Permalink
chore(vm): move some magic strings to constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasvdam committed Jun 18, 2024
1 parent 3e0c023 commit 93d87ad
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libs/vm/src/data-request-vm-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { HttpFetchAction } from './types/vm-actions.js';
import { HttpFetchResponse } from './types/vm-actions.js';
import type { VmAdapter } from './types/vm-adapter.js';
import { VM_MODE_ENV_KEY, VM_MODE_DR } from "./types/vm-modes.js";
import fetch from 'node-fetch';
import { PromiseStatus } from './types/vm-promise.js';
import { VmCallData } from './vm.js';
Expand All @@ -13,7 +14,7 @@ export default class DataRequestVmAdapter implements VmAdapter {
...input,
envs: {
...input.envs,
VM_MODE: 'dr',
[VM_MODE_ENV_KEY]: VM_MODE_DR,
},
};
}
Expand Down
1 change: 1 addition & 0 deletions libs/vm/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { parse, format } from "node:path";
import { HostToWorker } from "./worker-host-communication.js";
import { createProcessId } from "./services/create-process-id.js";

export * from "./types/vm-modes.js";
export { default as TallyVmAdapter } from './tally-vm-adapter.js';
export { default as DataRequestVmAdapter } from './data-request-vm-adapter.js';

Expand Down
3 changes: 2 additions & 1 deletion libs/vm/src/tally-vm-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { HttpFetchAction } from './types/vm-actions';
import { HttpFetchResponse } from './types/vm-actions.js';
import type { VmAdapter } from './types/vm-adapter';
import { PromiseStatus } from './types/vm-promise.js';
import { VM_MODE_ENV_KEY, VM_MODE_TALLY } from "./types/vm-modes.js";
import type { VmCallData } from './vm';

export default class TallyVmAdapter implements VmAdapter {
Expand All @@ -12,7 +13,7 @@ export default class TallyVmAdapter implements VmAdapter {
...input,
envs: {
...input.envs,
VM_MODE: 'tally'
[VM_MODE_ENV_KEY]: VM_MODE_TALLY,
}
};
}
Expand Down
3 changes: 3 additions & 0 deletions libs/vm/src/types/vm-modes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const VM_MODE_ENV_KEY = "VM_MODE";
export const VM_MODE_TALLY = "tally";
export const VM_MODE_DR = "dr";

0 comments on commit 93d87ad

Please sign in to comment.