简体   繁体   中英

How can I sort multiple outputs of a Google Cloud Function together?

I have a cloud function that is triggered 4 times to process a different set of data in each execution. Every time the function runs, it produces a list.

I would like to somehow get these lists together and sort them after the 4th execution is over.

Is this possible to achieve?

As specified in documentation :

There is no guarantee that the state of a Cloud Function will be preserved for future invocations. However, Cloud Functions often recycles the execution environment of a previous invocation. If you declare a variable in global scope, its value can be reused in subsequent invocations without having to be recomputed.

Meaning that, it's possible to preserve a list of items between two or more function executions, but you have no guarantees that this list will keep its state, because cold starts can always happen for scalability reasons. When a cold start happens, everything is recreated.

If there's a need to share state across function executions, then a secondary service dedicated to persist shared data should be accessed during each execution, such as Firebase .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM