简体   繁体   English

Rails中的重复HTTP请求

[英]Repetitive HTTP requests in Rails

Every 30 seconds within my application, I would like to make HTTP request to my second server. 在我的应用程序中,每30秒我要向第二台服务器发出HTTP请求。 I would like to write the result into the database. 我想将结果写入数据库。

I am relatively new to Ruby and Rails, and I am not sure what is a standard way to accomplish this. 我是Ruby和Rails的新手,我不确定实现此目的的标准方法是什么。 Should I use some kind or timer? 我应该使用某种计时器吗? Loop? 环? Should it be in model of my application? 应该在我的应用程序模型中吗? Or somewhere else? 或者别的地方?

Thank you in advance! 先感谢您!

Here is a list of screencasts for running background jobs in rails. 这是在Rails中运行后台作业的屏幕录像的列表。 Once you've decided how you're going to implement it, you can do everything you need to with the ruby standard library. 一旦决定了如何实现它,就可以使用ruby标准库来完成所需的一切。 Just use the http library . 只需使用http库

You can write the results to a db like SQLite or whatever your application is using. 您可以将结果写入SQLite之类的数据库,也可以将其写入应用程序中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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