Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bdd/step-definitions/hub/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Then("I see a sequence called {string}", function(string: string) {
Then("the output of an instance of {string} is as in {string} file", async function(this: CustomWorld, sequenceId, outputContentsFile) {
const fileData = await readFile(outputContentsFile, "utf-8");
const hostClient = getHostClient();
const instance = this.cliResources.instances?.find(inst => inst.sequence === sequenceId);
const instance = this.cliResources.instances?.find(inst => inst.sequence.id === sequenceId);

if (!instance) throw new Error("Instance not found");

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/helpers/instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const instanceRestart = async (
instanceId: string
) => {
const instanceInfo = await getInstance(instanceId).getInfo();
const sequenceId = instanceInfo.sequence;
const sequenceId = instanceInfo.sequence.id;
const sequenceClient = SequenceClient.from(sequenceId, getHostClient());
const { provides, requires, args } = instanceInfo;
const appConfig = instanceInfo.appConfig || {};
Expand Down
3 changes: 1 addition & 2 deletions packages/host/src/lib/cpm-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,8 @@ export class CPMConnector extends TypedEmitter<Events> {
*/
async sendInstanceInfo(instance: Instance, instanceStatus: InstanceMessageCode): Promise<void> {
this.logger.trace("Send instance status update", instanceStatus);

await this.communicationStream?.whenWrote(
[CPMMessageCode.INSTANCE, { ...instance, status: instanceStatus }]
[CPMMessageCode.INSTANCE, { instance, status: instanceStatus }]
);

this.logger.trace("Instance status update sent", instanceStatus);
Expand Down
6 changes: 3 additions & 3 deletions packages/host/src/lib/csi-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -785,11 +785,11 @@ export class CSIController extends TypedEmitter<Events> {
args: this.args,
provides: this.provides,
requires: this.requires,
sequence: this.sequence.id,
sequenceInfo: {
sequence: {
id: this.sequence.id,
config: this.sequence.config,
name: this.sequence.name
name: this.sequence.name,
location : this.sequence.location
},
ports: this.info.ports,
created: this.info.created,
Expand Down
9 changes: 7 additions & 2 deletions packages/host/src/lib/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -931,7 +931,12 @@ export class Host implements IComponent {
id: csic.id,
appConfig: csic.appConfig,
args: csic.args,
sequence: sequenceId,
sequence: (info => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { instances, ...rest } = info;

return rest;
})(sequence),
ports: csic.info.ports,
created: csic.info.created,
started: csic.info.started,
Expand Down Expand Up @@ -1040,7 +1045,7 @@ export class Host implements IComponent {

await this.cpmConnector?.sendInstanceInfo({
id: csic.id,
sequence: sequence.id
sequence: sequence
}, InstanceMessageCode.INSTANCE_ENDED);

this.auditor.auditInstance(id, InstanceMessageCode.INSTANCE_ENDED);
Expand Down
9 changes: 4 additions & 5 deletions packages/types/src/instance-store.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { AppConfig } from "./app-config";
import { InstanceId, InstanceStatus } from "./instance";

export type InstanceArgs = any[];
import { InstanceArgs, InstanceId, InstanceStatus } from "./instance";
import { SequenceInfoInstance } from "./sequence-adapter";

export type Instance = {
id: InstanceId,
appConfig?: AppConfig,
args?: InstanceArgs,
provides?: string,
requires?: string,
sequence: string,
ports?: Record<string, number>
sequence: SequenceInfoInstance,
ports?: Record<string, number>,
created?: Date,
started?: Date,
ended?: Date,
Expand Down
3 changes: 3 additions & 0 deletions packages/types/src/instance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export type InstanceId = string;

export type InstanceArgs = any[];

export const enum InstanceStatus {
INITIALIZING = "initializing",
STARTING = "starting",
Expand Down
5 changes: 3 additions & 2 deletions packages/types/src/messages/instance.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { CPMMessageCode, InstanceMessageCode } from "@scramjet/symbols";
import { Instance } from "../instance-store";

export type InstanceMessageData = {
id: string;
sequence: string;
status: InstanceMessageCode;
instance: Instance;
//id : string
}

export type InstanceMessage = { msgCode: CPMMessageCode.INSTANCE } & InstanceMessageData;
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/rest-api-manager/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export type ConnectedSTHInfo = {
selfHosted: boolean,
isConnectionActive: boolean,
description?: string,
tags?: Array<string>,
tags?: string[],
disconnectReason?: string;
};

Expand Down
10 changes: 6 additions & 4 deletions packages/types/src/rest-api-manager/get-entities.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { GetEntitiesResponse as STHRestAPIGetEntitiesResponse } from "../rest-api-sth";

export type GetEntitiesResponse =
(STHRestAPIGetEntitiesResponse & { hostId: string })[]
export type GetEntitiesResponse = {
hubs: string[],
topics: string[],
sequences: string[],
instances: string[],
}
4 changes: 3 additions & 1 deletion packages/types/src/rest-api-manager/get-instance.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export type GetInstanceResponse = string
import { Instance } from "../instance-store";

export type GetInstanceResponse = Instance
4 changes: 2 additions & 2 deletions packages/types/src/rest-api-manager/get-instances.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { GetSequencesResponse } from "./get-sequences";
import { GetInstanceResponse } from "../rest-api-sth";

export type GetInstancesResponse = GetSequencesResponse[][];
export type GetInstancesResponse = GetInstanceResponse[];
15 changes: 15 additions & 0 deletions packages/types/src/rest-api-manager/get-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { ConnectedSTHInfoDetails } from "./common";

export type GetListResponse = {
id: string,
info: ConnectedSTHInfoDetails,
healthy: boolean,
selfHosted: boolean,
isConnectionActive: boolean,
description?: string,
tags?: string[],
disconnectReason?: string,
topics : string[],
sequences: string[],
instances: string[],
}[]
1 change: 1 addition & 0 deletions packages/types/src/rest-api-manager/get-sequence-ids.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type GetSequenceIDSResponse = string[];
7 changes: 7 additions & 0 deletions packages/types/src/rest-api-manager/get-topics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
export type GetTopicsResponse = {
name: string;
contentType: string;
actors: {
hostId?:string;
stream: boolean,
retired: boolean,
role: string,
type: string
}[]
}[];
2 changes: 2 additions & 0 deletions packages/types/src/rest-api-manager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ export * from "./get-health";
export * from "./get-load";
export * from "./get-sequences";
export * from "./get-sequence";
export * from "./get-sequence-ids";
export * from "./get-instance";
export * from "./get-instances";
export * from "./get-topics";
export * from "./get-list";
export * from "./get-store-items";
export * from "./put-store-item";
export * from "./get-entities";
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/rest-api-sth/get-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { DeepPartial } from "../utils";
import { GetSequenceResponse } from "./get-sequence";

export type GetInstanceResponse = Instance & {
sequenceInfo: DeepPartial<GetSequenceResponse>
sequence: DeepPartial<GetSequenceResponse>
};
2 changes: 1 addition & 1 deletion packages/types/src/runner-config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// TODO: Rename. it is not a runner config but response from Pre-runner. - valid!!!

import { InstanceLimits } from "./instance-limits";
import { InstanceArgs } from "./instance-store";
import { InstanceArgs } from "./instance";
import { PortConfig } from "./sequence-package-json";
import { RunnerContainerConfiguration } from "./sth-configuration";

Expand Down
4 changes: 3 additions & 1 deletion packages/types/src/sequence-adapter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SequenceConfig } from "./runner-config";
import { Readable } from "stream";
import { IObjectLogger } from "./object-logger";
import { SequenceConfig } from "./runner-config";

export type SequenceInfo = {
config: SequenceConfig;
Expand All @@ -10,6 +10,8 @@ export type SequenceInfo = {
name? : string;
}

export type SequenceInfoInstance = Omit<SequenceInfo, "instances">;

export interface ISequenceAdapter {
/**
* Adapter name.
Expand Down
2 changes: 1 addition & 1 deletion packages/types/src/sequence-package-json.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { InstanceArgs } from "./instance-store";
import { InstanceArgs } from "./instance";

export type PortConfig = `${number}/${"tcp" | "udp"}`

Expand Down