How to use the taskcluster-client.WebListener function in taskcluster-client

To help you get started, we’ve selected a few taskcluster-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github taskcluster / taskcluster-tools / src / lib / utils.jsx View on Github external
startListening(bindings) {
      // Get bindings if none are provided
      if (!bindings || bindings.length === 0) {
        return Promise.resolve();
      }

      // If not listening start listening
      if (!this.__listener) {
        assert(this.__bindings.length === 0, 'Hmm... check stopListening');
        // Create listener
        this.__listener = new taskcluster.WebListener();
        this.__listener.on('message', this.handleMessage);
        this.__listener.on('error', err => {
          debug('Error while listening: %s, %j', err, err);
          this.setState({listeningError: err || new Error('Unknown error')});
          this.stopListening();
        });

        // Bind to bindings
        const bound = bindings.map(binding => {
          this.__bindings.push(binding);
          return this.__listener.bind(binding);
        });

        this.setState({
          listening: null,
          listeningError: null,
github taskcluster / taskcluster-tools / src / views / UnifiedInspector / Inspector.js View on Github external
createTaskListener(taskId) {
    if (this.taskListener) {
      this.taskListener.close();
      this.taskListener = null;
    }

    if (!taskId) {
      return;
    }

    const { queueEvents } = this.props;
    const listener = new WebListener();
    const routingKey = { taskId };

    ['taskDefined', 'taskPending', 'taskRunning', 'artifactCreated', 'taskCompleted', 'taskFailed', 'taskException']
      .map(binding => listener.bind(queueEvents[binding](routingKey)));

    listener.on('message', this.handleTaskMessage);
    listener.resume();
    this.taskListener = listener;

    return listener;
  }
github taskcluster / taskcluster-tools / src / task-group-inspector / lib / utils.jsx View on Github external
export const queueEvents = new taskcluster.QueueEvents();

/**
* Authentication
*/
export const authentication = {
  login: credentials => {
    queue = new taskcluster.Queue({credentials});
  },
};

/**
* WebListener
* Setup bindings and event callbacks
*/
let listener = new taskcluster.WebListener();

export const webListener = {
  startListening: (taskGroupId, onMessageAction) => {
    const qkey = {taskGroupId};

    listener.bind(queueEvents.taskDefined(qkey));
    listener.bind(queueEvents.taskPending(qkey));
    listener.bind(queueEvents.taskRunning(qkey));
    listener.bind(queueEvents.artifactCreated(qkey));
    listener.bind(queueEvents.taskCompleted(qkey));
    listener.bind(queueEvents.taskFailed(qkey));
    listener.bind(queueEvents.taskException(qkey));

    listener.on('message', message => {
      onMessageAction(message);
    });
github taskcluster / taskcluster-tools / src / task-group-inspector / lib / utils.jsx View on Github external
stopListening() {
    listener.close();
    listener = new taskcluster.WebListener();
  },
};