GAE向所有活动实例发送请求

2024-04-28 11:40:28 发布

您现在位置:Python中文网/ 问答频道 /正文

有没有办法向googleappengine中的模块/服务的所有活动实例发送请求?在

如果我能得到所有活动实例id的列表,我就可以对每个实例发出类似https://instance-dot-version-dot-service-dot-app-id.appspot.com的请求。在

在非常不寻常的情况下,我需要这个来更改一些内存的全局变量(这样可以节省对数据存储或memcache的请求和时间)。如果它们是频繁更改,我显然更喜欢使用memcache。。。在


Tags: 模块实例instancehttpscomidapp列表
1条回答
网友
1楼 · 发布于 2024-04-28 11:40:28

您可以使用Google App Engine Admin API的REST^{}方法获取特定服务版本的实例列表:

Lists the instances of a version.

HTTP request

GET https://appengine.googleapis.com/v1/{parent=apps/*/services/*/versions/*}/instances

The URL uses Google API HTTP annotation syntax.

另请参见相应的Google App Engine Admin API Client Library for Python的pydoc页面here。在

有了实例列表,您可以使用GAE的routing via URL根据需要向每个特定实例发送请求。在

重要提示与问题中的假设相关:

If I can get the list of all the active instances ids, I could make a request like https://instance-dot-version-dot-service-dot-app-id.appspot.com for each instance.

Targeted routing

Note: Targeting an instance is not supported in services that are configured for auto scaling or basic scaling.

相关问题 更多 >