UNPKG

951 BJavaScriptView Raw
1"use strict";
2var shortid = require("shortid");
3/**
4 * A nest is a resource that holds or produces jobs.
5 */
6var Nest = (function () {
7 function Nest(e, name) {
8 this.e = e;
9 this.id = shortid.generate();
10 this.name = name;
11 }
12 Nest.prototype.getId = function () {
13 return this.id;
14 };
15 Nest.prototype.toString = function () {
16 return "Nest";
17 };
18 Nest.prototype.getName = function () {
19 return this.name;
20 };
21 Nest.prototype.getTunnel = function () {
22 return this.tunnel;
23 };
24 Nest.prototype.register = function (tunnel) {
25 this.tunnel = tunnel;
26 };
27 Nest.prototype.arrive = function (job) {
28 var ns = this;
29 ns.e.log(1, "Job \"" + job.getName() + "\" arrived in Nest \"" + ns.name + "\".", ns);
30 job.setTunnel(ns.tunnel);
31 job.setNest(ns);
32 ns.tunnel.arrive(job, ns);
33 };
34 return Nest;
35}());
36exports.Nest = Nest;