MCPcopy Index your code
hub / github.com/browserless/browserless / constructor

Method constructor

src/limiter.ts:33–76  ·  view source on GitHub ↗
(
    protected config: Config,
    protected metrics: Metrics,
    protected monitor: Monitoring,
    protected webhooks: WebHooks,
    protected hooks: Hooks,
  )

Source from the content-addressed store, hash-verified

31 protected logger = new Logger('limiter');
32
33 constructor(
34 protected config: Config,
35 protected metrics: Metrics,
36 protected monitor: Monitoring,
37 protected webhooks: WebHooks,
38 protected hooks: Hooks,
39 ) {
40 super({
41 autostart: true,
42 concurrency: config.getConcurrent(),
43 timeout: config.getTimeout(),
44 });
45 this.queued = config.getQueued();
46
47 this.logger.debug(
48 `Concurrency: ${this.concurrency} queue: ${this.queued} timeout: ${this.timeout}ms`,
49 );
50
51 config.on('concurrent', (concurrency: number) => {
52 this.logger.debug(`Concurrency updated to ${concurrency}`);
53 this.concurrency = concurrency;
54 });
55
56 config.on('queued', (queued: number) => {
57 this.logger.debug(`Queue updated to ${queued}`);
58 this.queued = queued;
59 });
60
61 config.on('timeout', (timeout: number) => {
62 this.logger.debug(`Timeout updated to ${timeout}ms`);
63 this.timeout = timeout <= 0 ? 0 : timeout;
64 });
65
66 // eslint-disable-next-line @typescript-eslint/no-explicit-any
67 this.addEventListener('timeout', this.handleJobTimeout.bind(this) as any);
68
69 // eslint-disable-next-line @typescript-eslint/no-explicit-any
70 this.addEventListener('success', this.handleSuccess.bind(this) as any);
71
72 // eslint-disable-next-line @typescript-eslint/no-explicit-any
73 this.addEventListener('error', this.handleFail.bind(this) as any);
74
75 this.addEventListener('end', this.handleEnd.bind(this));
76 }
77
78 protected _errorHandler({
79 detail: { error },

Callers

nothing calls this directly

Calls 4

getConcurrentMethod · 0.80
getQueuedMethod · 0.80
debugMethod · 0.80
getTimeoutMethod · 0.45

Tested by

no test coverage detected