Skip to content

Commit

Permalink
feat: Export opts for all services
Browse files Browse the repository at this point in the history
Make `attach` calls more consistent by allowing the current state to be passed in.

fixes #4277
fixes #4278
  • Loading branch information
GordonSmith committed Nov 1, 2024
1 parent fbbef05 commit d1ac742
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 17 deletions.
4 changes: 1 addition & 3 deletions packages/comms/src/ecl/activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ export class Activity extends StateObject<UActivityState, IActivityState> implem
_activity = new Activity(optsConnection);
}
if (state) {
_activity.set({
...state
});
_activity.set(state);
}
return _activity;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/comms/src/ecl/logicalFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ export class LogicalFile extends StateObject<FileDetailEx, FileDetailEx> impleme

get properties(): FileDetailEx { return this.get(); }

static attach(optsConnection: IOptions | IConnection | DFUService, Cluster: string, Name: string): LogicalFile {
static attach(optsConnection: IOptions | IConnection | DFUService, Cluster: string, Name: string, state?: FileDetailEx): LogicalFile {
const retVal: LogicalFile = _store.get({ BaseUrl: optsConnection.baseUrl, Cluster, Name }, () => {
return new LogicalFile(optsConnection, Cluster, Name);
});
if (state) {
retVal.set(state);
}
return retVal;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/comms/src/ecl/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ export class Query extends StateObject<QueryEx, QueryEx> implements QueryEx {
} as QueryEx);
}

static attach(optsConnection: IOptions | IConnection, querySet: string, queryId: string): Query {
static attach(optsConnection: IOptions | IConnection, querySet: string, queryId: string, state?: QueryEx): Query {
const retVal: Query = _queries.get({ BaseUrl: optsConnection.baseUrl, QuerySet: querySet, QueryId: queryId } as QueryEx, () => {
return new Query(optsConnection, querySet, queryId);
});
if (state) {
retVal.set(state);
}
return retVal;
}

Expand Down
4 changes: 1 addition & 3 deletions packages/comms/src/ecl/targetCluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ export class TargetCluster extends StateObject<UTargetClusterState, ITargetClust
return new TargetCluster(optsConnection, name);
});
if (state) {
retVal.set({
...state
});
retVal.set(state);
}
return retVal;
}
Expand Down
5 changes: 4 additions & 1 deletion packages/comms/src/ecl/topology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,13 @@ export class Topology extends StateObject<TopologyStateEx, TopologyStateEx> impl
get LogicalClusters(): WsTopology.TpLogicalCluster[] { return this.get("LogicalClusters"); }
get Services(): WsTopology.ServiceList { return this.get("Services"); }

static attach(optsConnection: IOptions | IConnection | TopologyService) {
static attach(optsConnection: IOptions | IConnection | TopologyService, state?: TopologyStateEx): Topology {
const retVal: Topology = _topology.get({ BaseUrl: optsConnection.baseUrl }, () => {
return new Topology(optsConnection);
});
if (state) {
retVal.set(state);
}
return retVal;
}

Expand Down
8 changes: 8 additions & 0 deletions packages/comms/src/espConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,12 @@ export class Service {
constructor(optsConnection: IOptions | IConnection, service: string, version: string) {
this._connection = new ESPConnection(optsConnection, service, version);
}

opts() {
return this._connection.opts();
}

connection(): ESPConnection {
return this._connection.clone();
}
}
8 changes: 0 additions & 8 deletions packages/comms/src/services/wsWorkunits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,6 @@ export class WorkunitsService extends WorkunitsServiceBase {
super(optsConnection);
}

opts() {
return this._connection.opts();
}

connection(): ESPConnection {
return this._connection.clone();
}

Ping(): Promise<WsWorkunits.WsWorkunitsPingResponse> {
return this._connection.send("Ping", {}, "json", false, undefined, "WsWorkunitsPingResponse").then((response) => {
return { result: true };
Expand Down

0 comments on commit d1ac742

Please sign in to comment.