add aws and region

This commit is contained in:
Partouf
2024-07-14 17:59:37 +02:00
parent 7864222333
commit 0bfbbdcda4
6 changed files with 21 additions and 13 deletions
+7 -2
View File
@@ -524,7 +524,12 @@ async function main() {
const clientOptionsHandler = new ClientOptionsHandler(sources, compilerProps, defArgs);
const compilationQueue = CompilationQueue.fromProps(compilerProps.ceProps);
const compilationEnvironment = new CompilationEnvironment(compilerProps, compilationQueue, defArgs.doCache);
const compilationEnvironment = new CompilationEnvironment(
compilerProps,
awsProps,
compilationQueue,
defArgs.doCache,
);
const compileHandler = new CompileHandler(compilationEnvironment, awsProps);
const storageType = getStorageTypeByKey(storageSolution);
const storageHandler = new storageType(httpRoot, compilerProps, awsProps);
@@ -887,7 +892,7 @@ async function main() {
setupEventLoopLagLogging();
if (isExecutionWorker) {
const queue = new SqsWorkerMode(ceProps);
const queue = new SqsWorkerMode(ceProps, awsProps);
const doExecutionWork = async () => {
const msg = await queue.pop();
if (msg && msg.guid) {
+3 -1
View File
@@ -45,6 +45,7 @@ type PropFunc = (string, any?) => any;
export class CompilationEnvironment {
ceProps: PropertyGetter;
awsProps: PropertyGetter;
compilationQueue: CompilationQueue;
compilerProps: CompilerProps;
okOptions: RegExp;
@@ -60,8 +61,9 @@ export class CompilationEnvironment {
statsNoter: IStatsNoter;
private logCompilerCacheAccesses: boolean;
constructor(compilerProps, compilationQueue, doCache) {
constructor(compilerProps, awsProps, compilationQueue, doCache) {
this.ceProps = compilerProps.ceProps;
this.awsProps = awsProps;
this.compilationQueue = compilationQueue;
this.compilerProps = compilerProps.get.bind(compilerProps);
// So people running local instances don't break suddenly when updating
+1 -1
View File
@@ -22,7 +22,7 @@ export class RemoteExecutionEnvironment implements IExecutionEnvironment {
this.triple = triple;
this.guid = crypto.randomUUID();
this.packageHash = executablePackageHash;
this.execQueue = new SqsExecuteRequester(environment.ceProps);
this.execQueue = new SqsExecuteRequester(environment.ceProps, environment.awsProps);
logger.info(
`RemoteExecutionEnvironment with ${triple.toString()} and ${executablePackageHash} - guid ${this.guid}`,
+5 -4
View File
@@ -17,8 +17,9 @@ export class SqsExecuteQueueBase {
protected sqs: SQS;
protected queue_url: string;
constructor(props: PropertyGetter) {
this.sqs = new SQS();
constructor(props: PropertyGetter, awsProps: PropertyGetter) {
const region = awsProps<string>('region', '');
this.sqs = new SQS({region: region});
this.queue_url = props<string>('execqueue.queue_url', '');
if (this.queue_url === '') throw new Error('execqueue.queue_url property required');
}
@@ -43,8 +44,8 @@ export class SqsExecuteRequester extends SqsExecuteQueueBase {
export class SqsWorkerMode extends SqsExecuteQueueBase {
protected triple: ExecutionTriple;
constructor(props: PropertyGetter) {
super(props);
constructor(props: PropertyGetter, awsProps: PropertyGetter) {
super(props, awsProps);
this.triple = new ExecutionTriple();
// this.triple.setInstructionSet('aarch64'); // test
// todo: determine and set specialty somehow
+4 -4
View File
@@ -43,28 +43,28 @@ describe('Compilation environment', () => {
it('Should cache by default', async () => {
// TODO: Work will need to be done here when CompilationEnvironment's constructor is typed better
const ce = new CompilationEnvironment(compilerProps, undefined, undefined);
const ce = new CompilationEnvironment(compilerProps, fakeProps, undefined, undefined);
await expect(ce.cacheGet('foo')).resolves.toBeNull();
await ce.cachePut('foo', {res: 'bar'}, undefined);
await expect(ce.cacheGet('foo')).resolves.toEqual({res: 'bar'});
await expect(ce.cacheGet('baz')).resolves.toBeNull();
});
it('Should cache when asked', async () => {
const ce = new CompilationEnvironment(compilerProps, undefined, true);
const ce = new CompilationEnvironment(compilerProps, fakeProps, undefined, true);
await expect(ce.cacheGet('foo')).resolves.toBeNull();
await ce.cachePut('foo', {res: 'bar'}, undefined);
await expect(ce.cacheGet('foo')).resolves.toEqual({res: 'bar'});
});
it("Shouldn't cache when asked", async () => {
// TODO: Work will need to be done here when CompilationEnvironment's constructor is typed better
const ce = new CompilationEnvironment(compilerProps, undefined, false);
const ce = new CompilationEnvironment(compilerProps, fakeProps, undefined, false);
await expect(ce.cacheGet('foo')).resolves.toBeNull();
await ce.cachePut('foo', {res: 'bar'}, undefined);
await expect(ce.cacheGet('foo')).resolves.toBeNull();
});
it('Should filter bad options', () => {
// TODO: Work will need to be done here when CompilationEnvironment's constructor is typed better
const ce = new CompilationEnvironment(compilerProps, undefined, undefined);
const ce = new CompilationEnvironment(compilerProps, fakeProps, undefined, undefined);
expect(ce.findBadOptions(['-O3', '-flto'])).toEqual([]);
expect(ce.findBadOptions(['-O3', '-plugin'])).toEqual(['-plugin']);
});
+1 -1
View File
@@ -41,7 +41,7 @@ import {Language} from '../types/languages.interfaces.js';
export function makeCompilationEnvironment(options: Record<string, any>): CompilationEnvironment {
const compilerProps = new CompilerProps(options.languages, fakeProps(options.props || {}));
const compilationQueue = options.queue || new CompilationQueue(options.concurrency || 1, options.timeout, 100_000);
return new CompilationEnvironment(compilerProps, compilationQueue, options.doCache);
return new CompilationEnvironment(compilerProps, fakeProps, compilationQueue, options.doCache);
}
export function makeFakeCompilerInfo(props: Partial<CompilerInfo>): CompilerInfo {