How to use the taskcluster-client.createClient 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 / mozilla-taskcluster / test / setup.js View on Github external
await commitPublisher.assertExchanges(
    PushExchange,
    RetriggerExchange,
    // Dummy exchange for test messages from treeherder...
    {
      config: {
        exchange: 'treeherder-job-actions'
      }
    }
  );

  // We only need the connection to assert the exchanges after that we can
  // shut it down...
  await commitPublisher.close();

  this.events = new (taskcluster.createClient(commitPublisher.toSchema(
    PushExchange,
    RetriggerExchange
  )))();

  this.treeherder = new THProject('try', {
    consumerKey: 'try',
    consumerSecret: 'try',
    baseUrl: this.config.treeherder.apiUrl
  });
});
github taskcluster / taskcluster / services / github / bin / worker.js View on Github external
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
  await webHookListener.bind(githubEvents.pullRequest(
    {organization: '*', repository: '*', action: '*'}));

  // Launch jobs for push events as well.
  await webHookListener.bind(githubEvents.push(
    {organization: '*', repository: '*'}));

  // Listen for, and handle, changes in graph/task state: to reset status
  // messages, send notifications, etc....
  let schedulerEvents = new taskcluster.SchedulerEvents();
  let route = 'route.taskcluster-github.*.*.*';
  webHookListener.bind(schedulerEvents.taskGraphRunning(route));
  webHookListener.bind(schedulerEvents.taskGraphBlocked(route));
github taskcluster / taskcluster / services / auth / src / scoperesolver.js View on Github external
async reloadOnNotifications({exchangeReference, pulseClient, rootUrl}) {
    const AuthEvents = taskcluster.createClient(exchangeReference);
    const authEvents = new AuthEvents({rootUrl: rootUrl});

    // This is a perfect use-case for ephemeral consumers: every process that
    // runs a ScopeResolver should have its own queue, so that it gets it own
    // copy of each message; and those queues should be cleaned up when
    // processes go away.  The price we pay for this is that when we reconnect
    // to pulse, we may have missed messages, so we must reload all clients and
    // roles.

    this._clientPq = await consume({
      client: pulseClient,
      ephemeral: true,
      bindings: [
        authEvents.clientCreated(),
        authEvents.clientUpdated(),
        authEvents.clientDeleted(),
github taskcluster / taskcluster / services / github / src / handlers.js View on Github external
debug('Setting up handlers...');
    assert(!this.jobPq, 'Cannot setup twice!');
    assert(!this.resultStatusPq, 'Cannot setup twice!');
    assert(!this.initialTaskStatusPq, 'Cannot setup twice!');
    assert(!this.deprecatedResultStatusPq, 'Cannot setup twice!');
    assert(!this.deprecatedInitialStatusPq, 'Cannot setup twice!');

    // This is a simple Queue client without scopes to use throughout the handlers for simple things
    // Where scopes are needed, use this.queueClient.use({authorizedScopes: scopes}).blahblah
    // (see this.createTasks for example)
    this.queueClient = new taskcluster.Queue({
      rootUrl: this.context.cfg.taskcluster.rootUrl,
    });

    // Listen for new jobs created via the api webhook endpoint
    const GithubEvents = taskcluster.createClient(this.reference);
    const githubEvents = new GithubEvents({rootUrl: this.rootUrl});
    const jobBindings = [
      githubEvents.pullRequest(),
      githubEvents.push(),
      githubEvents.release(),
    ];

    const schedulerId = this.context.cfg.taskcluster.schedulerId;
    const queueEvents = new taskcluster.QueueEvents({rootUrl: this.rootUrl});

    const statusBindings = [
      queueEvents.taskFailed(`route.${this.context.cfg.app.checkTaskRoute}`),
      queueEvents.taskException(`route.${this.context.cfg.app.checkTaskRoute}`),
      queueEvents.taskCompleted(`route.${this.context.cfg.app.checkTaskRoute}`),
    ];
github taskcluster / taskcluster-tools / src / ami-sets / amisetmanager.jsx View on Github external
import React from 'react';
import {Col, ButtonToolbar, Button, Glyphicon, Row, Table} from 'react-bootstrap';
import _ from 'lodash';
import AmiSetEditor from './amiseteditor';
import * as utils from '../lib/utils';
import taskcluster from 'taskcluster-client';
// temporary until we have an updated taskcluster-client with the new methods in it
import reference from './temp-aws-prov-reference';

const AmiSetManager = React.createClass({
  mixins: [
    utils.createTaskClusterMixin({
      clients: {
        awsProvisioner: taskcluster.createClient(reference),
      },
      clientOpts: {
        awsProvisioner: {
          baseUrl: 'https://aws-provisioner.taskcluster.net/v1',
        },
      },
    }),
    // Serialize state.selectedAmiSet to location.hash as string
    utils.createLocationHashMixin({
      keys: ['selectedAmiSet'],
      type: 'string',
    }),
  ],

  getInitialState() {
    return {
github taskcluster / taskcluster-tools / src / ami-sets / amiseteditor.jsx View on Github external
import './amiseteditor.less';

const initialAmiSet = {
  amis: [{
    region: '...',
    hvm: '...',
    pv: '...',
  }],
};

/** Create amiSet editor/viewer (same thing) */
const AmiSetEditor = React.createClass({
  mixins: [
    utils.createTaskClusterMixin({
      clients: {
        awsProvisioner: taskcluster.createClient(reference),
      },
      clientOpts: {
        awsProvisioner: {
          baseUrl: 'https://aws-provisioner.taskcluster.net/v1',
        },
      },
      reloadOnProps: ['currentAmiSet'],
    }),
  ],

  propTypes: {
    // AmiSet to update, null of none
    amiSet: React.PropTypes.string,
    refreshAmiSetsList: React.PropTypes.func.isRequired,
    selectAmiSet: React.PropTypes.func.isRequired,
  },
github taskcluster / taskcluster / services / worker-manager / src / provisioner.js View on Github external
constructor({providers, iterateConf, Worker, WorkerPool, monitor, notify, pulseClient, reference, rootUrl, ownName}) {
    this.providers = providers;
    this.WorkerPool = WorkerPool;
    this.Worker = Worker;
    this.monitor = monitor;
    this.notify = notify;
    this.pulseClient = pulseClient;

    // lib-iterate will have loops stand on top of each other
    // so we will explicitly grab a mutex in each loop to ensure
    // we're the only one going at any given time
    this.provisioningLoopAlive = false;

    const WorkerManagerEvents = taskcluster.createClient(reference);
    const workerManagerEvents = new WorkerManagerEvents({rootUrl});
    this.bindings = [
      workerManagerEvents.workerPoolCreated(),
      workerManagerEvents.workerPoolUpdated(),
    ];

    this.iterate = new Iterate({
      maxFailures: 10,
      watchdogTime: 0,
      waitTime: 10000,
      maxIterationTime: 300000, // We really should be making it through the list at least once every 5 minutes
      ...iterateConf,
      name: ownName,
      handler: async () => {
        await this.provision();
      },
github taskcluster / taskcluster / services / notify / src / irc.js View on Github external
async start() {
    await new Promise((resolve, reject) => {
      try {
        this.client.connect(resolve);
      } catch (err) {
        if (err.command !== 'rpl_welcome') {
          reject(err);
        }
        resolve();
      }
    });

    const NotifyEvents = taskcluster.createClient(this.reference);
    const notifyEvents = new NotifyEvents({rootUrl: this.rootUrl});

    this.pq = await consume({
      client: this.pulseClient,
      bindings: [notifyEvents.ircRequest()],
      queueName: this.pulseQueueName,
    },
    this.monitor.timedHandler('notification', this.onMessage.bind(this)),
    );
  }