1+ import { cluster } from ".." ;
12import { ApiClient } from "../api-client" ;
23import { ExecutionContextService , Language } from "../apis/executionContext" ;
3- import { Command } from "./Command" ;
4+ import { Cluster } from "./Cluster" ;
5+ import { Command , CommandWithResult , StatusUpdateListener } from "./Command" ;
46
57export class ExecutionContext {
68 readonly executionContextApi : ExecutionContextService ;
7- readonly clusterId : string ;
8- readonly client : ApiClient ;
99 id ?: string ;
1010
11- constructor ( client : ApiClient , clusterId : string ) {
12- this . client = client ;
11+ constructor (
12+ readonly client : ApiClient ,
13+ readonly cluster : Cluster ,
14+ readonly language : Language
15+ ) {
1316 this . executionContextApi = new ExecutionContextService ( client ) ;
14- this . clusterId = clusterId ;
1517 }
1618
1719 static async create (
1820 client : ApiClient ,
19- clusterId : string
21+ cluster : Cluster ,
22+ language : Language = "python"
2023 ) : Promise < ExecutionContext > {
21- let context = new ExecutionContext ( client , clusterId ) ;
24+ let context = new ExecutionContext ( client , cluster , language ) ;
2225 let response = await context . executionContextApi . create ( {
23- clusterId : context . clusterId ,
24- language : "python" ,
26+ clusterId : context . cluster . id ,
27+ language : context . language ,
2528 } ) ;
2629
2730 context . id = response . id ;
@@ -30,9 +33,9 @@ export class ExecutionContext {
3033
3134 async execute (
3235 command : string ,
33- language : Language = "python"
34- ) : Promise < Command > {
35- return await Command . execute ( this , command , language ) ;
36+ onStatusUpdate : StatusUpdateListener = ( ) => { }
37+ ) : Promise < CommandWithResult > {
38+ return await Command . execute ( this , command , onStatusUpdate ) ;
3639 }
3740
3841 async destroy ( ) {
@@ -41,7 +44,7 @@ export class ExecutionContext {
4144 }
4245
4346 await this . executionContextApi . destroy ( {
44- clusterId : this . clusterId ,
47+ clusterId : this . cluster . id ,
4548 contextId : this . id ,
4649 } ) ;
4750 }
0 commit comments