@@ -11,7 +11,6 @@ import { Ec2Client } from '../../shared/clients/ec2Client'
11
11
import { updateInPlace } from '../../shared/utilities/collectionUtils'
12
12
import { Commands } from '../../shared/vscode/commands'
13
13
import globals from '../../shared/extensionGlobals'
14
- import { ToolkitError } from '../../shared/errors'
15
14
16
15
export const parentContextValue = 'awsEc2ParentNode'
17
16
export type Ec2Node = Ec2InstanceNode | Ec2ParentNode
@@ -22,7 +21,7 @@ export class Ec2ParentNode extends AWSTreeNodeBase {
22
21
protected readonly placeHolderMessage = '[No EC2 Instances Found]'
23
22
protected ec2InstanceNodes : Map < string , Ec2InstanceNode >
24
23
public override readonly contextValue : string = parentContextValue
25
- protected pollingNodes : Set < string > = new Set < string > ( )
24
+ protected pollingNodes : Set < Ec2InstanceNode > = new Set < Ec2InstanceNode > ( )
26
25
private pollTimer ?: NodeJS . Timeout
27
26
28
27
public constructor (
@@ -60,34 +59,23 @@ export class Ec2ParentNode extends AWSTreeNodeBase {
60
59
return this . pollingNodes . size !== 0
61
60
}
62
61
63
- public startPolling ( instanceId : string ) {
64
- this . pollingNodes . add ( instanceId )
62
+ public startPolling ( childNode : Ec2InstanceNode ) {
63
+ this . pollingNodes . add ( childNode )
65
64
this . pollTimer =
66
65
this . pollTimer ?? globals . clock . setInterval ( this . updatePollingNodes . bind ( this ) , pollingInterval )
67
66
}
68
67
69
68
public updatePollingNodes ( ) {
70
- console . log ( 'here' )
71
- this . pollingNodes . forEach ( async value => {
72
- const instanceNode = this . getChild ( value )
73
- await instanceNode . updateStatus ( )
69
+ this . pollingNodes . forEach ( async childNode => {
70
+ await childNode . updateStatus ( )
74
71
75
- if ( instanceNode . status != 'pending' ) {
76
- this . pollingNodes . delete ( value )
72
+ if ( childNode . getStatus ( ) != 'pending' ) {
73
+ this . pollingNodes . delete ( childNode )
77
74
}
78
75
} )
79
76
this . refreshNode ( )
80
77
}
81
78
82
- public getChild ( instanceId : string ) : Ec2InstanceNode {
83
- if ( ! this . ec2InstanceNodes . has ( instanceId ) ) {
84
- throw new ToolkitError ( `Unable to retrieve child instance requested with id: ${ instanceId } ` , {
85
- code : 'MissingChild' ,
86
- } )
87
- }
88
- return this . ec2InstanceNodes . get ( instanceId ) !
89
- }
90
-
91
79
public async clearChildren ( ) {
92
80
this . ec2InstanceNodes = new Map < string , Ec2InstanceNode > ( )
93
81
}
0 commit comments