speculateServiceName()
Cloud Run 处于 Alpha 状态,且尚未积极开发。
推测将由 deployService() 或其 CLI 等效命令 npx remotion cloudrun services deploy 创建的 Cloud Run 服务的名称。在已提前知道 Cloud Run 服务配置的情况下,并且需要服务名称时,这可能会很有用。
🌐 Speculate the name of the Cloud Run service that will be created by deployService() or its CLI equivalent, npx remotion cloudrun services deploy. This could be useful in cases when the configuration of the Cloud Run service is known in advance, and the name of the service is needed.
如果你不确定某项服务是否存在,请使用 getServiceInfo(),并捕获如果它不存在时抛出的错误。
🌐 If you are not sure whether a service exists, use getServiceInfo() and catch the error that gets thrown if it does not exist.
如果你想获取已部署服务的列表,请使用 getServices() 替代。
🌐 If you want to get a list of deployed services, use getServices() instead.
服务名称模式
🌐 Service name pattern
服务名称取决于以下参数:
🌐 The service name depends on the following parameters:
- Remotion 版本
- 内存限制
- CPU 限制
- 超时时间(秒)
该服务的名称类似于以下模式:
🌐 The name of the service resembles the following pattern:
remotion--3-3-96--mem2gi--cpu1-0--t-1900
^^^^^^ ^^^ ^^^ ^^^
| | | |-- Timeout in seconds
| | |----------- Cpu limit
| |------------------- Memory limit
|--------------------------- Remotion version with dots replaced by dashes示例
🌐 Example
import {speculateServiceName } from '@remotion/cloudrun';
const speculatedServiceName = speculateServiceName ({
memoryLimit : '2Gi',
cpuLimit : '2',
timeoutSeconds : 300,
});
console .log (speculatedServiceName ); // remotion--3-3-96--mem2gi--cpu2-0--t-300参数
🌐 Arguments
一个具有以下属性的对象:
🌐 An object with the following properties:
memoryLimit
Cloud Run 服务可以消耗的 RAM 的上限。
🌐 The upper bound on the amount of RAM that the Cloud Run service can consume.
cpuLimit
Cloud Run 服务可以使用来处理请求的最大 CPU 核心数。
🌐 The maximum number of CPU cores that the Cloud Run service can use to process requests.
timeoutSeconds
已分配给 Cloud Run 服务的超时时间。
🌐 The timeout that has been assigned to the Cloud Run service.
返回值
🌐 Return value
一个包含该服务推测名称的字符串。
🌐 A string with the speculated name of the service.
另请参阅
🌐 See also
- 此函数的源代码
- deployService()
deployService()的命令行版本:npx remotion cloudrun services deploy