【发布时间】:2018-09-09 11:42:07
【问题描述】:
我想跨多个区域部署相同的云功能。 有什么简单的方法吗?
【问题讨论】:
标签: firebase google-cloud-functions
我想跨多个区域部署相同的云功能。 有什么简单的方法吗?
【问题讨论】:
标签: firebase google-cloud-functions
由于您没有说要部署哪种类型的功能,我将假设 https 功能。将任何其他类型的(后台)功能部署到多个区域是没有意义的,因为每个区域都可能触发每个事件,这将是相当混乱的。使用 https 函数,每个函数都有一个不同的 URL
您可以将具有相同实现的两个不同功能部署到不同区域:
function f(req, res) {
// your https function implementation here
}
exports.f_asia_northeast1 = functions
.region('asia-northeast1')
.https.onRequest(f);
exports.f_us_central1 = functions
.region('us-central1')
.https.onRequest(f);
【讨论】:
我还没试过,但是the docs说:
您可以通过在
functions.region()中传递多个以逗号分隔的区域字符串来指定多个区域。
因此,类似
function f(req, res) {
// your https function implementation here
}
exports.thefunction = functions
.region('asia-northeast1', 'us-central1')
.https.onRequest(f);
应该适用于在多个区域部署相同的功能以及为所有“副本”分配相同的(唯一)名称。
【讨论】: