@eang/core
Version:
eang - model driven enterprise event processing
148 lines • 4.2 kB
JavaScript
import { Obj } from '../entity.js';
export class ProcessObj extends Obj {
typeOf = 'Process';
/** Function timeout in milliseconds */
timeout;
/** Memory limit in MB */
memoryLimit;
/** Environment variables specific to this function */
env;
/** Key-value pairs of secrets available to this object */
secrets;
constructor(opts) {
super({ ...opts, typeOf: 'Process' });
if (opts.timeout !== undefined) {
this.timeout = opts.timeout;
}
if (opts.memoryLimit !== undefined) {
this.memoryLimit = opts.memoryLimit;
}
if (opts.env !== undefined) {
this.env = opts.env;
}
if (opts.secrets !== undefined) {
this.secrets = opts.secrets;
}
}
}
export function isProcessObj(obj) {
return obj.typeOf === 'Process';
}
export class ProcessInstanceObj extends Obj {
typeOf = 'ProcessInstance';
startedAt;
stoppedAt;
constructor(opts) {
super({ ...opts, typeOf: 'ProcessInstance' });
if (opts.startedAt !== undefined) {
this.startedAt = opts.startedAt;
}
if (opts.stoppedAt !== undefined) {
this.stoppedAt = opts.stoppedAt;
}
}
get instanceOfId() {
if (this.instanceOf) {
return `Process/${this.instanceOf}`;
}
return undefined;
}
}
export function isProcessInstanceObj(obj) {
return obj.typeOf === 'ProcessInstance';
}
export class FunctionObj extends Obj {
typeOf = 'Function';
/** Function timeout in milliseconds */
timeout;
/** Memory limit in MB */
memoryLimit;
/** Environment variables specific to this function */
env;
/** Key-value pairs of secrets available to this object */
secrets;
constructor(opts) {
super({ ...opts, typeOf: 'Function' });
if (opts.timeout !== undefined) {
this.timeout = opts.timeout;
}
if (opts.memoryLimit !== undefined) {
this.memoryLimit = opts.memoryLimit;
}
if (opts.env !== undefined) {
this.env = opts.env;
}
if (opts.secrets !== undefined) {
this.secrets = opts.secrets;
}
}
}
export function isFunctionObj(obj) {
return obj.typeOf === 'Function';
}
export class FunctionInstanceObj extends Obj {
typeOf = 'FunctionInstance';
startedAt;
stoppedAt;
constructor(opts) {
super({ ...opts, typeOf: 'FunctionInstance' });
this.startedAt = opts.startedAt || Date.now();
if (opts.stoppedAt !== undefined) {
this.stoppedAt = opts.stoppedAt;
}
}
get instanceOfId() {
if (this.instanceOf) {
return `Function/${this.instanceOf}`;
}
return undefined;
}
}
export function isFunctionInstanceObj(obj) {
return obj.typeOf === 'FunctionInstance';
}
export class ServiceObj extends Obj {
typeOf = 'Service';
/** Service type (e.g., 'http', 'grpc', 'websocket') */
//type!: string
/** Service port */
//port?: number
/** Service host */
//host?: string
/** Service health check endpoint */
//healthCheckEndpoint?: string
/** Service version */
//version?: string
/** Environment variables specific to this service */
env;
/** Secrets available to this service */
secrets;
/** Service scaling configuration */
// scaling?: {
// minInstances?: number
// maxInstances?: number
// targetCPUUtilization?: number
// }
/** Service deployment configuration */
// deployment?: {
// strategy?: 'rolling' | 'recreate' | 'blue-green'
// replicas?: number
// resources?: {
// cpu?: string
// memory?: string
// }
// }
constructor(opts) {
super({ ...opts, typeOf: 'Service' });
if (opts.env !== undefined) {
this.env = opts.env;
}
if (opts.secrets !== undefined) {
this.secrets = opts.secrets;
}
}
}
export function isServiceObj(obj) {
return obj.typeOf === 'Service';
}
//# sourceMappingURL=runtime.js.map