UNPKG

4.08 kBTypeScriptView Raw
1import { IIterator } from '@lumino/algorithm';
2import { Poll } from '@lumino/polling';
3import { ISignal } from '@lumino/signaling';
4import { ServerConnection } from '..';
5import * as Kernel from './kernel';
6import { BaseManager } from '../basemanager';
7import { IKernelOptions } from './restapi';
8/**
9 * An implementation of a kernel manager.
10 */
11export declare class KernelManager extends BaseManager implements Kernel.IManager {
12 /**
13 * Construct a new kernel manager.
14 *
15 * @param options - The default options for kernel.
16 */
17 constructor(options?: KernelManager.IOptions);
18 /**
19 * The server settings for the manager.
20 */
21 readonly serverSettings: ServerConnection.ISettings;
22 /**
23 * Test whether the manager is ready.
24 */
25 get isReady(): boolean;
26 /**
27 * A promise that fulfills when the manager is ready.
28 */
29 get ready(): Promise<void>;
30 /**
31 * A signal emitted when the running kernels change.
32 */
33 get runningChanged(): ISignal<this, Kernel.IModel[]>;
34 /**
35 * A signal emitted when there is a connection failure.
36 */
37 get connectionFailure(): ISignal<this, Error>;
38 /**
39 * Dispose of the resources used by the manager.
40 */
41 dispose(): void;
42 /**
43 * Connect to an existing kernel.
44 *
45 * @returns The new kernel connection.
46 *
47 * #### Notes
48 * This will use the manager's server settings and ignore any server
49 * settings passed in the options.
50 */
51 connectTo(options: Omit<Kernel.IKernelConnection.IOptions, 'serverSettings'>): Kernel.IKernelConnection;
52 /**
53 * Create an iterator over the most recent running kernels.
54 *
55 * @returns A new iterator over the running kernels.
56 */
57 running(): IIterator<Kernel.IModel>;
58 /**
59 * Force a refresh of the running kernels.
60 *
61 * @returns A promise that resolves when the running list has been refreshed.
62 *
63 * #### Notes
64 * This is not typically meant to be called by the user, since the
65 * manager maintains its own internal state.
66 */
67 refreshRunning(): Promise<void>;
68 /**
69 * Start a new kernel.
70 *
71 * @param createOptions - The kernel creation options
72 *
73 * @param connectOptions - The kernel connection options
74 *
75 * @returns A promise that resolves with the kernel connection.
76 *
77 * #### Notes
78 * The manager `serverSettings` will be always be used.
79 */
80 startNew(createOptions?: IKernelOptions, connectOptions?: Omit<Kernel.IKernelConnection.IOptions, 'model' | 'serverSettings'>): Promise<Kernel.IKernelConnection>;
81 /**
82 * Shut down a kernel by id.
83 *
84 * @param id - The id of the target kernel.
85 *
86 * @returns A promise that resolves when the operation is complete.
87 */
88 shutdown(id: string): Promise<void>;
89 /**
90 * Shut down all kernels.
91 *
92 * @returns A promise that resolves when all of the kernels are shut down.
93 */
94 shutdownAll(): Promise<void>;
95 /**
96 * Find a kernel by id.
97 *
98 * @param id - The id of the target kernel.
99 *
100 * @returns A promise that resolves with the kernel's model.
101 */
102 findById(id: string): Promise<Kernel.IModel | undefined>;
103 /**
104 * Execute a request to the server to poll running kernels and update state.
105 */
106 protected requestRunning(): Promise<void>;
107 /**
108 * Handle a kernel starting.
109 */
110 private _onStarted;
111 private _onDisposed;
112 private _onStatusChanged;
113 private _isReady;
114 private _ready;
115 private _kernelConnections;
116 private _models;
117 private _pollModels;
118 private _runningChanged;
119 private _connectionFailure;
120}
121/**
122 * The namespace for `KernelManager` class statics.
123 */
124export declare namespace KernelManager {
125 /**
126 * The options used to initialize a KernelManager.
127 */
128 interface IOptions extends BaseManager.IOptions {
129 /**
130 * When the manager stops polling the API. Defaults to `when-hidden`.
131 */
132 standby?: Poll.Standby;
133 }
134}