How to use the taskcluster-client.PulseListener 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 / libraries / testing / src / pulse.js View on Github external
PulseTestReceiver.prototype.listenFor = function(name, binding) {
  // Check that the `name` haven't be used before in this test. Remember
  // that we reset this._promisedMessages before each test (via setup) in mocha.
  if (this._promisedMessages[name] !== undefined) {
    throw new Error('name: \'' + name + '\' have already been used in this test');
  }

  // Create new listener using the existing PulseConnection, so no new TCP
  // connection is opened, it just creates an AMQP channel within the existing
  // TCP connection, this is much faster.
  var listener = new taskcluster.PulseListener({
    connection: this._connection,
  });

  // Add listener to list so we can cleanup later
  this._listeners.push(listener);

  // Create a promise that we got a message
  var gotMessage = new Promise(function(accept, reject) {
    listener.on('message', accept);
    listener.on('error', reject);
  });

  // Insert the promise gotMessage into this._promisedMessages for name, so
  // that we can return it when `.waitFor(name)` is called
  this._promisedMessages[name] = gotMessage;
github taskcluster / mozilla-taskcluster / test / setup.js View on Github external
setup(function() {
  // Note listener is for messages/exchanges we generate...
  this.listener = new taskcluster.PulseListener({
    credentials: {
      connectionString: this.config.commitPublisher.connectionString
    }
  });

  // Pulse is for things external components generate...
  this.pulse = new taskcluster.PulseListener({
    credentials: {
      connectionString: this.config.treeherderTaskcluster.connectionString
    }
  });
});
github taskcluster / mozilla-taskcluster / test / setup.js View on Github external
setup(function() {
  // Note listener is for messages/exchanges we generate...
  this.listener = new taskcluster.PulseListener({
    credentials: {
      connectionString: this.config.commitPublisher.connectionString
    }
  });

  // Pulse is for things external components generate...
  this.pulse = new taskcluster.PulseListener({
    credentials: {
      connectionString: this.config.treeherderTaskcluster.connectionString
    }
  });
});
github taskcluster / taskcluster / services / treeherder / treeherder / handlers.js View on Github external
Handlers.prototype.setup = function() {
  assert(this.listener === null, "Cannot setup twice!");
  var that = this;

  // Create listener
  this.listener = new taskcluster.PulseListener({
    credentials:          this.pulse,
    queueName:            this.queueName,
    prefetch:             this.prefetch
  });

  // Regular expression to parse route pattern:
  // ..
  var routeRegExp = new RegExp("^" + this.routePrefix + "\\.([^.]+).([^.]+)$");

  // Construct routing pattern
  var routingPattern = [
    'route',
    that.routePrefix,
    '*',              // project
    '*'               // revisionHash
  ].join('.');
github taskcluster / taskcluster / services / github / bin / worker.js View on Github external
// A context to be passed into message handlers
  let context = {cfg, githubAPI, scheduler, validator};

  // Start monitoring the process
  base.stats.startProcessUsageReporting({
    drain:      statsDrain,
    component:  cfg.get('taskclusterGithub:statsComponent'),
    process:    'worker'
  });

  let pulseCredentials = cfg.get('pulse')
  assert(pulseCredentials.username, 'Username must be supplied for pulse connection');
  assert(pulseCredentials.password, 'Password must be supplied for pulse connection');

  var webHookListener = new taskcluster.PulseListener({
    queueName:  profile,
    credentials: {
      username: pulseCredentials.username,
      password: pulseCredentials.password
    }
  });

  let exchangeReference = exchanges.reference({
    exchangePrefix:   cfg.get('taskclusterGithub:exchangePrefix'),
    credentials:      cfg.get('pulse')
  });

  let GitHubEvents = taskcluster.createClient(exchangeReference);
  let githubEvents = new GitHubEvents();

  // Attempt to launch jobs for any possible pull request action
github taskcluster / mozilla-taskcluster / src / bin / pulse_listener.js View on Github external
async function setupActionHandler(runtime, config) {
  let listener = new taskcluster.PulseListener({
    credentials: {
      connectionString: config.treeherderActions.connectionString
    },
    queueName: config.treeherderActions.queue,
    prefetch: config.treeherderActions.prefetch
  });

  let routingPattern = [
    config.treeherderActions.routePrefix,
    '#'
  ].join('.');

  let binding = {
    exchange: config.treeherderActions.exchange,
    routingKeyPattern: routingPattern
  };