Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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
}
});
});
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
}
});
});
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('.');
// 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
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
};