2023-10-17 22:14:08 +07:00
|
|
|
/**
|
2023-04-03 21:52:40 +04:00
|
|
|
* Copyright 2023 Fluence Labs Limited
|
2023-02-13 17:41:35 +03:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
2023-10-17 22:14:08 +07:00
|
|
|
|
2023-11-06 17:42:24 +07:00
|
|
|
import { CallParameters } from "@fluencelabs/marine-worker";
|
2023-10-17 22:14:08 +07:00
|
|
|
|
2023-11-06 17:42:24 +07:00
|
|
|
import { IStartable } from "../util/commonTypes.js";
|
2024-03-04 18:27:51 +07:00
|
|
|
import type { JSONObject, JSONValue, JSONArray } from "../util/types.js";
|
2023-02-13 17:41:35 +03:00
|
|
|
|
|
|
|
/**
|
2023-04-03 21:52:40 +04:00
|
|
|
* Contract for marine host implementations. Marine host is responsible for creating calling and removing marine services
|
2023-02-13 17:41:35 +03:00
|
|
|
*/
|
2023-04-03 21:52:40 +04:00
|
|
|
export interface IMarineHost extends IStartable {
|
2023-10-17 22:14:08 +07:00
|
|
|
/**
|
|
|
|
* Creates marine service from the given module and service id
|
|
|
|
*/
|
|
|
|
createService(
|
|
|
|
serviceModule: ArrayBuffer | SharedArrayBuffer,
|
|
|
|
serviceId: string,
|
|
|
|
): Promise<void>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes marine service with the given service id
|
|
|
|
*/
|
|
|
|
removeService(serviceId: string): Promise<void>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if any service with the specified service id is registered
|
|
|
|
*/
|
|
|
|
hasService(serviceId: string): Promise<boolean>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Calls the specified function of the specified service with the given arguments
|
|
|
|
*/
|
|
|
|
callService(
|
|
|
|
serviceId: string,
|
|
|
|
functionName: string,
|
|
|
|
args: JSONArray | JSONObject,
|
2023-11-06 17:42:24 +07:00
|
|
|
callParams?: CallParameters,
|
2023-10-17 22:14:08 +07:00
|
|
|
): Promise<JSONValue>;
|
2023-02-13 17:41:35 +03:00
|
|
|
}
|