-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { CostParameters } from '../cost-queue/CostQueue'; | ||
export interface AggregatorService { | ||
get description(): string; | ||
initialize: () => Promise<void>; | ||
test: (operation: Operation) => Promise<OperationTestResult>; | ||
run: (operation: Operation) => Promise<OperationResult | undefined>; | ||
} | ||
export interface OperationTestResult { | ||
aggregatorService: AggregatorService; | ||
operation: Operation; | ||
runnable: boolean; | ||
operationResult?: OperationResult; | ||
costParameters?: CostParameters; | ||
} | ||
export interface OperationResult { | ||
aggregatorService: AggregatorService; | ||
operation: Operation; | ||
resultLocation: string; | ||
} | ||
export interface Operation { | ||
id: string; | ||
operation: string; | ||
sources: string[]; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { CostParameters } from '../cost-queue/CostQueue'; | ||
|
||
export interface AggregatorService { | ||
get description(): string; | ||
initialize: () => Promise<void>; | ||
test: (operation: Operation) => Promise<OperationTestResult>; | ||
run: (operation: Operation) => Promise<OperationResult | undefined>; | ||
} | ||
|
||
export interface OperationTestResult { | ||
aggregatorService: AggregatorService; | ||
operation: Operation; | ||
runnable: boolean; | ||
operationResult?: OperationResult; | ||
costParameters?: CostParameters; | ||
} | ||
|
||
export interface OperationResult { | ||
aggregatorService: AggregatorService; | ||
operation: Operation; | ||
resultLocation: string; | ||
} | ||
|
||
export interface Operation { | ||
id: string; | ||
operation: string; | ||
sources: string[]; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { AggregatorService, Operation, OperationResult, OperationTestResult } from './aggregatorService'; | ||
export declare class AggregatorServiceSPARQL implements AggregatorService { | ||
initialize(): Promise<void>; | ||
test(operation: Operation): Promise<OperationTestResult>; | ||
run(operation: Operation): Promise<OperationResult>; | ||
get description(): string; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { AggregatorService, Operation, OperationResult, OperationTestResult } from './aggregatorService'; | ||
|
||
export class AggregatorServiceSPARQL implements AggregatorService { | ||
public async initialize(): Promise<void> { | ||
return undefined; | ||
} | ||
|
||
public async test(operation: Operation): Promise<OperationTestResult> { | ||
return { | ||
aggregatorService: this, | ||
operation, | ||
runnable: false, | ||
}; | ||
} | ||
|
||
public async run(operation: Operation): Promise<OperationResult> { | ||
return { | ||
aggregatorService: this, | ||
operation, | ||
resultLocation: '', | ||
}; | ||
} | ||
|
||
public get description(): string { | ||
return 'SPARQL'; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { OperationTestResult } from '../aggregator-services/aggregatorService'; | ||
export interface CostQueueFactory { | ||
create: () => CostQueue; | ||
} | ||
export interface CostQueue { | ||
length: number; | ||
push: (aggregatorService: OperationTestResult) => void; | ||
pop: () => OperationTestResult | undefined; | ||
} | ||
export type CostParameters = { | ||
timeSeconds: number; | ||
}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import type { OperationTestResult } from '../aggregator-services/aggregatorService'; | ||
|
||
export interface CostQueueFactory { | ||
create: () => CostQueue; | ||
} | ||
|
||
export interface CostQueue { | ||
length: number; | ||
push: (aggregatorService: OperationTestResult) => void; | ||
pop: () => OperationTestResult | undefined; | ||
} | ||
|
||
export type CostParameters = { | ||
timeSeconds: number; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import type { CostQueue, CostQueueFactory } from './CostQueue'; | ||
export declare class CostQueueTimeFactory implements CostQueueFactory { | ||
create(): CostQueue; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import TinyQueue from 'tinyqueue'; | ||
import type { OperationTestResult } from '../aggregator-services/aggregatorService'; | ||
import type { CostQueue, CostQueueFactory } from './CostQueue'; | ||
|
||
export class CostQueueTimeFactory implements CostQueueFactory { | ||
public create(): CostQueue { | ||
return new CostQueueTime(); | ||
} | ||
} | ||
|
||
class CostQueueTime implements CostQueue { | ||
private readonly priorityQueue: TinyQueue<OperationTestResult>; | ||
|
||
public get length(): number { | ||
return this.priorityQueue.length; | ||
} | ||
|
||
public constructor() { | ||
this.priorityQueue = new TinyQueue([], compare); | ||
} | ||
|
||
public push(aggregatorService: OperationTestResult): void { | ||
this.priorityQueue.push(aggregatorService); | ||
} | ||
|
||
public pop(): OperationTestResult | undefined { | ||
return this.priorityQueue.pop(); | ||
} | ||
} | ||
|
||
function compare(a: OperationTestResult, b: OperationTestResult): number { | ||
if (a.costParameters === undefined) { | ||
if (b.costParameters === undefined) { | ||
return 0; | ||
} | ||
return -1; | ||
} | ||
if (b.costParameters === undefined) { | ||
return 1; | ||
} | ||
return a.costParameters.timeSeconds - b.costParameters.timeSeconds; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export declare class Endpoint { | ||
private readonly httpServer; | ||
constructor(); | ||
run(): void; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { Server } from 'node:http'; | ||
import { createServer } from 'node:http'; | ||
|
||
export class Endpoint { | ||
private readonly httpServer: Server; | ||
public constructor() { | ||
this.httpServer = createServer(); | ||
} | ||
|
||
public run(): void { | ||
this.httpServer.listen(8080); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from './endpoint/endpoint'; | ||
export * from './aggregator-services/aggregatorService'; | ||
export * from './aggregator-services/aggregatorServiceSparql'; | ||
export * from './cost-queue/CostQueue'; | ||
export * from './cost-queue/CostQueueTime'; | ||
export * from './operation-registry/aggregatorServiceRegistry'; | ||
export * from './operation-registry/aggregatorServiceRegistryHardcodedTestOnly'; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export * from './endpoint/endpoint'; | ||
|
||
export * from './aggregator-services/aggregatorService'; | ||
export * from './aggregator-services/aggregatorServiceSparql'; | ||
|
||
export * from './cost-queue/CostQueue'; | ||
export * from './cost-queue/CostQueueTime'; | ||
|
||
export * from './operation-registry/aggregatorServiceRegistry'; | ||
export * from './operation-registry/aggregatorServiceRegistryHardcodedTestOnly'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import type { Operation, OperationResult } from '../aggregator-services/aggregatorService'; | ||
export interface AggregatorServiceRegistry { | ||
initializeServices: () => Promise<void>; | ||
run: (operation: Operation) => Promise<OperationResult | undefined>; | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import type { Operation, OperationResult } from '../aggregator-services/aggregatorService'; | ||
|
||
export interface AggregatorServiceRegistry { | ||
initializeServices: () => Promise<void>; | ||
run: (operation: Operation) => Promise<OperationResult | undefined>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import type { AggregatorService, Operation, OperationResult } from '../aggregator-services/aggregatorService'; | ||
import type { CostQueueFactory } from '../cost-queue/CostQueue'; | ||
import type { AggregatorServiceRegistry } from './aggregatorServiceRegistry'; | ||
export declare class AggregatorServiceRegistryHardcodedTestOnly implements AggregatorServiceRegistry { | ||
readonly costQueueFactory: CostQueueFactory; | ||
readonly aggregatorServices: AggregatorService[]; | ||
constructor(aggregatorServices: AggregatorService[], costQueueFactory: CostQueueFactory); | ||
initializeServices(): Promise<void>; | ||
run(operation: Operation): Promise<OperationResult | undefined>; | ||
} |