1 | import { Environment } from "../environment/environment";
|
2 | import { Nest } from "./nest";
|
3 | import { FileJob } from "./../job/fileJob";
|
4 | import { FolderJob } from "./../job/folderJob";
|
5 | /**
|
6 | * A folder nest is a nest which contains a backing folder at a specific path. If the folder does not exist,
|
7 | * antfarm can optionally create it.
|
8 | */
|
9 | export declare class FolderNest extends Nest {
|
10 | protected path: string;
|
11 | protected allowCreate: boolean;
|
12 | protected heldJobs: (FileJob | FolderJob)[];
|
13 | constructor(e: Environment, path?: string, allowCreate?: boolean);
|
14 | /**
|
15 | * Check if the path for the backing folder is created. If not, optionally create it.
|
16 | * @param directory
|
17 | */
|
18 | protected checkDirectorySync(directory: any): void;
|
19 | /**
|
20 | * Function that creates and arrives new jobs. Can produce file or folder jobs.
|
21 | * @param path
|
22 | * @param arrive
|
23 | * @returns {FolderJob|FileJob}
|
24 | */
|
25 | protected createJob(path: string, arrive?: boolean): any;
|
26 | /**
|
27 | * Initial load of the contents of the directory.
|
28 | * @param hold {boolean} Optional flag to hold jobs found.
|
29 | */
|
30 | load(hold?: boolean): void;
|
31 | /**
|
32 | * Watches the folder.
|
33 | * @param hold {boolean} Optional flag to hold jobs found.
|
34 | */
|
35 | watch(hold?: boolean): void;
|
36 | /**
|
37 | * Watches and holds jobs found.
|
38 | */
|
39 | watchHold(): void;
|
40 | /**
|
41 | * Arrive function that calls the super.
|
42 | * @param job
|
43 | */
|
44 | arrive(job: FileJob): void;
|
45 | /**
|
46 | * Picks up a job from another nest.
|
47 | * @param job
|
48 | * @param callback Callback is given the job in its parameter.
|
49 | */
|
50 | take(job: FileJob, callback: any): void;
|
51 | /**
|
52 | * Loads jobs that have piled up in the nest if it was not watched.
|
53 | * No longer used.
|
54 | * @returns {Array} Array of jobs
|
55 | */
|
56 | getUnwatchedJobs(): any[];
|
57 | /**
|
58 | * Returns all held jobs.
|
59 | * @returns {(FileJob|FolderJob)[]}
|
60 | */
|
61 | getHeldJobs(): (FileJob | FolderJob)[];
|
62 | /**
|
63 | * Adds job to array of held jobs.
|
64 | * @param job
|
65 | */
|
66 | protected holdJob(job: (FileJob | FolderJob)): void;
|
67 | /**
|
68 | * Get a held job with a job id. Removes it from the held job queue,
|
69 | * so you should move it out of the folder after using this.
|
70 | * @param jobId
|
71 | * @returns {FileJob|FolderJob}
|
72 | * #### Example
|
73 | * ```js
|
74 | * var tunnel = af.createTunnel("Checkpoint example");
|
75 | * var webhook = af.createWebhookNest(["test", "example"], "get");
|
76 | * var holding_folder = af.createAutoFolderNest(["test", "checkpoint"]);
|
77 | *
|
78 | * var im = webhook.getInterfaceManager();
|
79 | *
|
80 | * // Watch for jobs, hold, and provide to the interface.
|
81 | * im.checkNest(holding_folder);
|
82 | * tunnel.watch(webhook);
|
83 | *
|
84 | * tunnel.run(function(job, nest){
|
85 | * // Get the job_id from the webhook request
|
86 | * var job_id = job.getParameter("job_id");
|
87 | * // Get the held job from the holding folder
|
88 | * var checkpoint_job = holding_folder.getHeldJob(job_id);
|
89 | * // Move somewhere else
|
90 | * checkpoint_job.move(af.createAutoFolderNest(["test", "outfolder"]));
|
91 | * });
|
92 | * ```
|
93 | */
|
94 | getHeldJob(jobId: string): any;
|
95 | }
|