重构 Google App Engine 数据存储

发布于 2024-11-17 05:30:48 字数 430 浏览 2 评论 0原文

在我的数据存储中,我有数百个 PlayerStatistic 类型的实体,我想将其重命名为 GamePlayRecord。在开发服务器上,通过在交互式控制台中编写一个小脚本很容易做到这一点。但是,部署应用程序后,就没有交互式控制台了。

相反,我将该脚本复制到一个文件中,并在 app.yaml 中链接该文件。我部署了该脚本,打算运行一次然后将其删除。然而,我遇到了另一个问题,那就是脚本运行了超过30秒。脚本总是会在完成之前被中断。

我的解决方案最终是重写脚本,以便它一次创建和删除一个实体。这样,即使超时,脚本也可以从中断处继续。由于我只有几百个实体,因此大约需要刷新 5 次。

有没有更好的方法在 Google App Engine 上运行一次性重构脚本?有没有一个好方法可以绕过 30 秒的限制来运行这些重构脚本?

In my datastore I had a few hundred entities of kind PlayerStatistic that I wanted to rename to GamePlayRecord. On the dev server it was easy to do this by writing a small script in the Interactive Console. However there is no Interactive Console once the app has been deployed.

Instead, I copied that script into a file and linked the file in app.yaml. I deployed the script, intending to run it once and then delete it. However, I ran into another problem, which is that the script ran for over 30 seconds. The script would always get cut off before it could complete.

My solution ended up being rewriting the script so that it creates and deletes the entities one at a time. That way, even when it timed out, the script could continue where it left off. Since I only have a few hundred entities this took about 5 refreshes.

Is there a better way to run one-time refactoring scripts on Google App Engine? Is there a good way to get around the 30 second limit in order to run these refactoring scripts?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

唱一曲作罢 2024-11-24 05:30:48

使用任务队列。

任务可以比 Web 请求运行更长的时间。您还可以将工作分成许多任务,这样它们就会并行运行并更快地完成。完成任务后,您可以通过编程方式插入新任务,因此整个过程是自动化的,无需手动刷新。

Use the task queue.

Tasks can run for more much longer than web requests. You can also split up the work into many tasks, so they will run parallel and finish faster. When you finish the task, you can programmatically insert a new task, so the whole process is automated and you don't need to manually refresh.

从﹋此江山别 2024-11-24 05:30:48

appengine-mapreduce 是进行数据存储区重构的好方法。它处理了您在手动编写任务代码时必须处理的许多混乱细节。

appengine-mapreduce is a good way to do datastore refactoring. It takes care of a lot of the messy details that you would have to grapple with when writing task code by hand.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文