forked from spring-attic/vscode-spring-cloud-dataflow
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- This is not even close to a planned structure but putting out concept of some sort to be able to play with ideas for better debug abstraction for streams and tasks. - This now also allows to result running task config if debug flags are set. - Relates spring-attic#3
- Loading branch information
Showing
10 changed files
with
216 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { DebugConfiguration } from 'vscode'; | ||
import { ServerRegistration } from '../service/server-registration-manager'; | ||
import { DebugProvider } from './debug-provider'; | ||
import { ScdfModel } from '../service/scdf-model'; | ||
|
||
export interface DebugHandler { | ||
|
||
attach(): Promise<void>; | ||
|
||
} | ||
|
||
export class DefaultStreamDebugHandler implements DebugHandler { | ||
|
||
constructor( | ||
private serverRegistration: ServerRegistration, | ||
private streamName: string, | ||
private appName: string, | ||
private debugProvider: DebugProvider | ||
) {} | ||
|
||
public async attach(): Promise<void> { | ||
const model = new ScdfModel(this.serverRegistration); | ||
const deployment = model.getStreamDeployment(this.streamName); | ||
const entry = await deployment; | ||
const name = `Debug (Attach) - ${this.streamName} ${this.appName}`; | ||
const port = +entry.deploymentProperties.log['spring.cloud.deployer.local.debug-port']; | ||
|
||
const config: DebugConfiguration = { | ||
type: 'java', | ||
name: name, | ||
request: 'attach', | ||
hostName: "localhost", | ||
port: port | ||
}; | ||
|
||
this.debugProvider.startDebug(config); | ||
} | ||
} | ||
|
||
export class DefaultTaskDebugHandler implements DebugHandler { | ||
|
||
constructor( | ||
private serverRegistration: ServerRegistration, | ||
private executionId: number, | ||
private debugProvider: DebugProvider | ||
) {} | ||
|
||
public async attach(): Promise<void> { | ||
const model = new ScdfModel(this.serverRegistration); | ||
const execution = await model.getTaskExecution(this.executionId); | ||
const name = `Debug (Attach) - ${execution.taskName} ${this.executionId}`; | ||
const port = +execution.deploymentProperties['deployer.timestamp.local.debug-port']; | ||
|
||
const config: DebugConfiguration = { | ||
type: 'java', | ||
name: name, | ||
request: 'attach', | ||
hostName: "localhost", | ||
port: port | ||
}; | ||
|
||
this.debugProvider.startDebug(config); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { injectable, multiInject } from 'inversify'; | ||
import { ServerRegistration } from '../service/server-registration-manager'; | ||
import { DefaultStreamDebugHandler, DebugHandler, DefaultTaskDebugHandler } from './debug-handler'; | ||
import { TYPES } from '../types'; | ||
import { DebugProvider } from './debug-provider'; | ||
|
||
@injectable() | ||
export class DebugManager { | ||
|
||
constructor( | ||
@multiInject(TYPES.DebugProvider) private debugProviders: DebugProvider[] | ||
) {} | ||
|
||
public getStreamDebugHandler( | ||
streamName: string, | ||
appName: string, | ||
serverRegistration: ServerRegistration | ||
): DebugHandler { | ||
// find debug provider which supports our env | ||
const debugProvider = this.debugProviders[0]; | ||
return new DefaultStreamDebugHandler(serverRegistration, streamName, appName, debugProvider); | ||
} | ||
|
||
public getTaskDebugHandler( | ||
executionId: number, | ||
serverRegistration: ServerRegistration | ||
): DebugHandler { | ||
// find debug provider which supports our env | ||
const debugProvider = this.debugProviders[0]; | ||
return new DefaultTaskDebugHandler(serverRegistration, executionId, debugProvider); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { DebugConfiguration, debug, WorkspaceFolder } from 'vscode'; | ||
import { injectable } from 'inversify'; | ||
|
||
export interface DebugProvider { | ||
|
||
getDebugType(): string; | ||
|
||
hasDebugger(): Promise<boolean>; | ||
|
||
startDebug(config: DebugConfiguration): Promise<boolean>; | ||
} | ||
|
||
@injectable() | ||
export class LocalDebugProvider implements DebugProvider { | ||
|
||
public getDebugType(): string { | ||
return 'java'; | ||
} | ||
|
||
public async hasDebugger(): Promise<boolean> { | ||
return true; | ||
} | ||
|
||
public async startDebug(config: DebugConfiguration): Promise<boolean> { | ||
const folder: WorkspaceFolder | undefined = undefined; | ||
const started = await debug.startDebugging(folder, config); | ||
return started; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2019 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import { ContainerModule } from 'inversify'; | ||
import { DebugProvider, LocalDebugProvider } from './debug-provider'; | ||
import { TYPES } from '../types'; | ||
import { DebugManager } from './debug-manager'; | ||
|
||
const debugContainerModule = new ContainerModule((bind) => { | ||
bind<DebugProvider>(TYPES.DebugProvider).to(LocalDebugProvider); | ||
bind<DebugManager>(TYPES.DebugManager).to(DebugManager).inSingletonScope(); | ||
}); | ||
export default debugContainerModule; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters