UNPKG

3.46 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { Observable } from 'rxjs';
9import { JsonValue, schema } from '../../json';
10import { Job, JobDescription, JobName, Registry, ScheduleJobOptions, Scheduler } from './api';
11export declare class JobArgumentSchemaValidationError extends schema.SchemaValidationException {
12 constructor(errors?: schema.SchemaValidatorError[]);
13}
14export declare class JobInboundMessageSchemaValidationError extends schema.SchemaValidationException {
15 constructor(errors?: schema.SchemaValidatorError[]);
16}
17export declare class JobOutputSchemaValidationError extends schema.SchemaValidationException {
18 constructor(errors?: schema.SchemaValidatorError[]);
19}
20/**
21 * Simple scheduler. Should be the base of all registries and schedulers.
22 */
23export declare class SimpleScheduler<MinimumArgumentT extends JsonValue = JsonValue, MinimumInputT extends JsonValue = JsonValue, MinimumOutputT extends JsonValue = JsonValue> implements Scheduler<MinimumArgumentT, MinimumInputT, MinimumOutputT> {
24 protected _jobRegistry: Registry<MinimumArgumentT, MinimumInputT, MinimumOutputT>;
25 protected _schemaRegistry: schema.SchemaRegistry;
26 private _internalJobDescriptionMap;
27 private _queue;
28 private _pauseCounter;
29 constructor(_jobRegistry: Registry<MinimumArgumentT, MinimumInputT, MinimumOutputT>, _schemaRegistry?: schema.SchemaRegistry);
30 private _getInternalDescription;
31 /**
32 * Get a job description for a named job.
33 *
34 * @param name The name of the job.
35 * @returns A description, or null if the job is not registered.
36 */
37 getDescription(name: JobName): Observable<JobDescription | null>;
38 /**
39 * Returns true if the job name has been registered.
40 * @param name The name of the job.
41 * @returns True if the job exists, false otherwise.
42 */
43 has(name: JobName): Observable<boolean>;
44 /**
45 * Pause the scheduler, temporary queueing _new_ jobs. Returns a resume function that should be
46 * used to resume execution. If multiple `pause()` were called, all their resume functions must
47 * be called before the Scheduler actually starts new jobs. Additional calls to the same resume
48 * function will have no effect.
49 *
50 * Jobs already running are NOT paused. This is pausing the scheduler only.
51 */
52 pause(): () => void;
53 /**
54 * Schedule a job to be run, using its name.
55 * @param name The name of job to be run.
56 * @param argument The argument to send to the job when starting it.
57 * @param options Scheduling options.
58 * @returns The Job being run.
59 */
60 schedule<A extends MinimumArgumentT, I extends MinimumInputT, O extends MinimumOutputT>(name: JobName, argument: A, options?: ScheduleJobOptions): Job<A, I, O>;
61 /**
62 * Filter messages.
63 * @private
64 */
65 private _filterJobOutboundMessages;
66 /**
67 * Return a new state. This is just to simplify the reading of the _createJob method.
68 * @private
69 */
70 private _updateState;
71 /**
72 * Create the job.
73 * @private
74 */
75 private _createJob;
76 protected _scheduleJob<A extends MinimumArgumentT, I extends MinimumInputT, O extends MinimumOutputT>(name: JobName, argument: A, options: ScheduleJobOptions, waitable: Observable<never>): Job<A, I, O>;
77}