Git Product home page Git Product logo

cloud-debug-proxy-common's Introduction

Common Module for Stackdriver Debugger Proxies

This is not an official Google product. This library may be changed in backwards-incompatible ways and is not subject to any SLA or deprecation policy.

This project is a common module for developers of Stackdriver Debugger proxies. Stackdriver Debugger is a feature of Google Cloud Platform that lets users debug their applications in production, in real-time, without stopping or pausing their apps. The Stackdriver Debugger proxies interface between Stackdriver Debugger and various IDES, allowing users to debug using Stackdriver Debugger from their favourite environment. You can use this common module as a base to develop your own Stackdriver Debugger proxy.

List of Stackdriver Debugger Proxies

Sample Usage

Please check out some of the above Stackdriver Debugger proxies to see their actual implementations. A high-level summary of features is provided below:

stackdriver = require('cloud-debug-proxy-common');

class CustomDebugProxy {
  constructor() {
    this.debugProxy = new stackdriver.DebugProxy({
      debuggerId: 'debuggerId',
      sourceDirectory: './',
    });
  }

  // Call this to initialize your proxy.
  async initialize() {
    // Prompt the user to choose a keyFile, or leave blank to use the default.
    await this.debugProxy.setProjectByKeyFile();

    // Prompt the user to select a debuggee from the list.
    const debuggeeList = await this.debugProxy.getDebuggees();
    console.log(debuggeeList);
    this.debugProxy.setDebuggeeId(debuggeeList[0].id);

    // Listen for breakpoint changes.
    this.debugProxy.on('breakpointHit', () => {
      console.log('hit a breakpoint!');
    });
  }

  // Call this after your proxy is fully initialized.
  async pollForPendingBreakpoints() {
    while (true) {
      await this.debugProxy.updatePendingBreakpoints(true);
   }
  }

  // Call this when the user adds a breakpoint in the IDE.
  // This sample breakpoint has path, line, and condition properties.
  async setBreakpoint(breakpoint) {
    const stackdriverBreakpoint = await this.debugProxy.setBreakpoint({
      action: stackdriver.Action.CAPTURE,
      location: {
        path: breakpoint.path,
        line: breakpoint.line,
      },
      condition: breakpoint.condition,
    });
    return {
      path: stackdriverBreakpoint.location.path,
      line: stackdriverBreakpoint.location.line,
      condition: stackdriverBreakpoint.condition,
    };
  }
}

cloud-debug-proxy-common's People

Contributors

eyqs avatar iantalarico avatar ofrobots avatar renovate[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.