Skip to main content

推测服务名称()

EXPERIMENTAL

Cloud Run 处于 Alpha 阶段,这意味着 API 可能会在任何版本中更改,文档尚未完成。请查看 更改日志 以了解最新的重大更改。

推测由 deployService() 或其 CLI 等效命令 npx remotion cloudrun services deploy 创建的 Cloud Run 服务的名称。在已知 Cloud Run 服务配置且需要服务名称的情况下,这可能会很有用。

如果不确定服务是否存在,请使用 getServiceInfo() 并捕获如果服务不存在则抛出的错误。

如果要获取已部署服务的列表,请改用 getServices()

服务名称模式

服务名称取决于以下参数:

  • Remotion 版本
  • 内存限制
  • CPU 限制
  • 超时时间(秒)

服务名称类似于以下模式:

remotion--3-3-96--mem2gi--cpu1-0--t-1900
^^^^^^ ^^^ ^^^ ^^^
| | | |-- Timeout in seconds
| | |----------- Cpu limit
| |------------------- Memory limit
|--------------------------- Remotion version with dots replaced by dashes
remotion--3-3-96--mem2gi--cpu1-0--t-1900
^^^^^^ ^^^ ^^^ ^^^
| | | |-- Timeout in seconds
| | |----------- Cpu limit
| |------------------- Memory limit
|--------------------------- Remotion version with dots replaced by dashes

示例

ts
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
ts
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

参数

一个具有以下属性的对象:

memoryLimit

Cloud Run 服务可以消耗的 RAM 上限。

cpuLimit

Cloud Run 服务用于处理请求的 CPU 核心的最大数量。

timeoutSeconds

已分配给 Cloud Run 服务的超时时间。

返回值

一个包含服务推测名称的字符串。

另请参阅

I'm ready to translate the Markdown content into Chinese. Please go ahead and paste the content for translation.