<p>Let's say I'm writing a new dating site in Ruby on Rails, but I want to run the matching algorithm in a golang routine because it's a lot data and Ruby isn't very performant with that sort of thing.</p>
<p>I have data for each user in the form -</p>
<pre><code>[
"1" => {
name: "Regina Phalange",
age: "33",
interests: [
"golang",
"surfing",
"guitar hero"
]
}
"2" => {
name: "Seymour Butts",
age: "32",
interests: [
"sports",
"calculus",
"hanging with tha homies"
]
}
]
</code></pre>
<p>And let's say I'm running on Heroku - 1 dyno runs my RoR app, the other runs my Go instance. </p>
<p>What's the best way to send data back and forth between these two apps? Should I set up an HTTP endpoint on either end and <code>POST</code> the data back and forth? Should I dump all this large amount of JSON data to a file and send the file over?</p>
<p>I'm fairly new to golang and was just curious what the best practices here are.</p>
<p>Thank you for the help!</p>
<hr/>**评论:**<br/><br/>Rhaseven7h: <pre><p>Yes, and no, ideally both apps should have access to the same database, post the request to go, and proxy the responsa back to the client. If the load is big, and the fact that this is not real-time information you may run scheduled jobs to calculate them, that way in the future you can scale to hadoop or cassandra.</p></pre>phcostabh: <pre><p>You can build a shared library and use it with Ruby-FFI. Give it a read: <a href="https://c7.se/go-and-ruby-ffi/" rel="nofollow">https://c7.se/go-and-ruby-ffi/</a></p></pre>dhondu_bhikaji_joshi: <pre><p>If you want an asynchronous solution:
<a href="http://redistogo.com/documentation/resque" rel="nofollow">http://redistogo.com/documentation/resque</a>
<a href="https://github.com/benmanns/goworker" rel="nofollow">https://github.com/benmanns/goworker</a></p>
<p>For synchronous, a HTTP call should be good.</p></pre>
Just getting started with golang - how do I send data from my Rails app to a golang program?
blov · · 442 次点击这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传