UNPKG

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