Skip to main content

getServices()

EXPERIMENTAL

检索部署到 GCP Cloud Run 的 Remotion 服务列表。

🌐 Retrieves a list of Remotion services deployed to GCP Cloud Run.

参数 compatibleOnly 决定是否仅返回与已安装的 Remotion Cloud Run 版本兼容的服务。

🌐 The parameter compatibleOnly determines whether only services that are compatible with the installed version of Remotion Cloud Run should be returned.

note

Cloud Run 服务是有版本的,服务的版本必须与 @remotion/cloudrun 包的版本匹配。所以如果你升级 Remotion,你应该部署一个新的服务,否则你可能会从此函数得到一个空数组。

要获取有关单一服务的信息,请使用 getServiceInfo()

🌐 To get information about only a single service, use getServiceInfo().

如果你确定某个服务存在,你也可以使用 speculateServiceName() 猜测它的名称,从而节省一次对 Cloud Run 的 API 调用。

🌐 If you are sure that a service exists, you can also guess the name of it using speculateServiceName() and save an API call to Cloud Run.

示例

🌐 Example

import {getServices} from '@remotion/cloudrun/client';

const info = await getServices({
  region: 'us-east1',
  compatibleOnly: true,
});

for (const service of info) {
  console.log(service.serviceName); // "remotion--3-3-82--mem512mi--cpu1-0"
  console.log(service.timeoutInSeconds); // 300
  console.log(service.memoryLimit); // 512Mi
  console.log(service.cpuLimit); // 1.0
  console.log(service.remotionVersion); // "4.0.1"
  console.log(service.uri); // "https://remotion--3-3-82--mem512mi--cpu1-0--t-300-1a2b3c4d5e-ue.a.run.app"
  console.log(service.region); // "us-east1"
  console.log(service.consoleUrl); // "https://console.cloud.google.com/run/detail/us-east1/remotion--3-3-82--mem512mi--cpu1-0--t-300/logs"
}
note

@remotion/cloudrun/client 导入,而不是导入整个渲染器,因为整个渲染器无法打包。

参数

🌐 Argument

一个包含以下属性的对象:

🌐 An object containing the following properties:

region

你想查询的 GCP 区域

🌐 The GCP region that you would like to query.

import {getServices} from '@remotion/cloudrun';

const info = await getServices({
  region: 'us-west1',
  compatibleOnly: true,
});

for (const service of info) {
  console.log(service.serviceName); // "remotion--3-3-82--mem2gi--cpu2--t-1100"
  console.log(service.timeoutInSeconds); // 1100
  console.log(service.memoryLimit); // 2Gi
  console.log(service.cpuLimit); // 2
  console.log(service.remotionVersion); // "3.3.82"
  console.log(service.uri); // "https://remotion--3-3-82--mem2gi--cpu2--t-1100-1a2b3c4d5e-uw.a.run.app"
  console.log(service.region); // "us-west1"
  console.log(service.consoleUrl); // "https://console.cloud.google.com/run/detail/us-west1/remotion--3-3-82--mem2gi--cpu2--t-1100/logs"
}

compatibleOnly

如果是 true,则仅返回与当前 Remotion Cloud 运行包版本匹配的服务。如果是 false,则返回所有 Remotion 服务。

🌐 If true, only services that match the version of the current Remotion Cloud run package are returned. If false, all Remotion services are returned.

返回值

🌐 Return value

一个承诺解析为具有以下属性的对象数组

🌐 A promise resolving to an array of objects with the following properties:

serviceName

服务的名称。

🌐 The name of the service.

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.

remotionVersion

该服务的 Remotion 版本。Remotion 对 Cloud Run 服务进行版本控制,并且渲染只能从与服务版本匹配的 @remotion/cloudrun 版本触发。

🌐 The Remotion version of the service. Remotion is versioning the Cloud Run service and a render can only be triggered from a version of @remotion/cloudrun that is matching the one of the service.

timeoutInSeconds

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

🌐 The timeout that has been assigned to the Cloud Run service.

uri

服务的终点。

🌐 The endpoint of the service.

region

已部署服务的区域。如果向区域输入传递“所有区域”,则此项很有用。

🌐 The region of the deployed service. Useful if passing 'all regions' to the region input.

consoleUrl

此服务的 GCP 控制台页面的链接。具体来说,是日志显示的链接。

🌐 A link to the GCP console page for this service. Specifically, a link to logs display.

另请参阅

🌐 See also