UNPKG

5.36 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 * Force a refresh of the running kernels.
59 *
60 * @returns A promise that resolves when the running list has been refreshed.
61 *
62 * #### Notes
63 * This is not typically meant to be called by the user, since the
64 * manager maintains its own internal state.
65 */
66 refreshRunning(): Promise<void>;
67 /**
68 * Start a new kernel.
69 *
70 * @param createOptions - The kernel creation options
71 *
72 * @param connectOptions - The kernel connection options
73 *
74 * @returns A promise that resolves with the kernel connection.
75 *
76 * #### Notes
77 * The manager `serverSettings` will be always be used.
78 */
79 startNew(createOptions?: IKernelOptions, connectOptions?: Omit<Kernel.IKernelConnection.IOptions, 'model' | 'serverSettings'>): Promise<Kernel.IKernelConnection>;
80 /**
81 * Shut down a kernel by id.
82 *
83 * @param id - The id of the target kernel.
84 *
85 * @returns A promise that resolves when the operation is complete.
86 */
87 shutdown(id: string): Promise<void>;
88 /**
89 * Shut down all kernels.
90 *
91 * @returns A promise that resolves when all of the kernels are shut down.
92 */
93 shutdownAll(): Promise<void>;
94 /**
95 * Find a kernel by id.
96 *
97 * @param id - The id of the target kernel.
98 *
99 * @returns A promise that resolves with the kernel's model.
100 */
101 findById(id: string): Promise<Kernel.IModel | undefined>;
102 /**
103 * Execute a request to the server to poll running kernels and update state.
104 */
105 protected requestRunning(): Promise<void>;
106 /**
107 * Handle a kernel starting.
108 */
109 private _onStarted;
110 private _onDisposed;
111 private _onStatusChanged;
112 private _isReady;
113 private _ready;
114 private _kernelConnections;
115 private _models;
116 private _pollModels;
117 private _runningChanged;
118 private _connectionFailure;
119}
120/**
121 * The namespace for `KernelManager` class statics.
122 */
123export declare namespace KernelManager {
124 /**
125 * The options used to initialize a KernelManager.
126 */
127 interface IOptions extends BaseManager.IOptions {
128 /**
129 * When the manager stops polling the API. Defaults to `when-hidden`.
130 */
131 standby?: Poll.Standby | (() => boolean | Poll.Standby);
132 }
133 /**
134 * A no-op kernel manager to be used when starting kernels.
135 */
136 class NoopManager extends KernelManager {
137 /**
138 * Whether the manager is active.
139 */
140 get isActive(): boolean;
141 /**
142 * Used for testing.
143 */
144 get parentReady(): Promise<void>;
145 /**
146 * Start a new kernel - throws an error since it is not supported.
147 */
148 startNew(createOptions?: IKernelOptions, connectOptions?: Omit<Kernel.IKernelConnection.IOptions, 'model' | 'serverSettings'>): Promise<Kernel.IKernelConnection>;
149 /**
150 * Connect to an existing kernel - throws an error since it is not supported.
151 */
152 connectTo(options: Omit<Kernel.IKernelConnection.IOptions, 'serverSettings'>): Kernel.IKernelConnection;
153 /**
154 * Shut down a kernel by id - throws an error since it is not supported.
155 */
156 shutdown(id: string): Promise<void>;
157 /**
158 * A promise that fulfills when the manager is ready (never).
159 */
160 get ready(): Promise<void>;
161 /**
162 * Execute a request to the server to poll running kernels and update state.
163 */
164 protected requestRunning(): Promise<void>;
165 private _readyPromise;
166 }
167}
168
\No newline at end of file