Skip to content

Commit

Permalink
feat(kernel): add startNew in LibroKernelManager
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinesmilelk authored and BroKun committed Feb 5, 2024
1 parent f2fca0f commit c688886
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/libro-kernel/src/kernel/libro-kernel-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
LibroKernelConnectionFactory,
} from './libro-kernel-protocol.js';
import type { LibroKernel } from './libro-kernel.js';
import type { IKernelOptions } from './restapi.js';
import { KernelRestAPI } from './restapi.js';

@singleton()
Expand Down Expand Up @@ -96,6 +97,29 @@ export class LibroKernelManager {
return this._ready;
}

/**
* Start a new kernel.
*
* @param createOptions - The kernel creation options
*
* @param connectOptions - The kernel connection options
*
* @returns A promise that resolves with the kernel connection.
*
* #### Notes
* The manager `serverSettings` will be always be used.
*/
async startNew(
createOptions: IKernelOptions = {},
connectOptions: Omit<KernelConnectionOptions, 'model' | 'serverSettings'> = {},
): Promise<IKernelConnection> {
const model = await this.kernelRestAPI.startNew(createOptions);
return this.connectToKernel({
...connectOptions,
model,
});
}

/**
* A signal emitted when the running kernels change.
*/
Expand Down

0 comments on commit c688886

Please sign in to comment.