Grails 作为单个应用程序或不同的后端和前端应用程序 [英] Grails as single app or different back-end and front end app

查看:30
本文介绍了Grails 作为单个应用程序或不同的后端和前端应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们是 grails 的新手,并且担心以下问题:

We are new to grails and are concerned about the following issues:

  1. 可扩展性问题

  1. scalability concerns

为不同的应用程序使用相同的后端

Using same back-end for different applications

所以坚持一个单一的 grails 是个好主意,或者我们应该分离关注点,甚至使用其他框架,如 node.js 来使用 rest.

So sticking to a single grails is good idea or we should separate concerns and even use other framework like node.js for frontend using rest.

其次我不是很清楚,我们应该将业务逻辑放在 grail 应用程序中的什么位置.我认为理想的地方应该是服务

Secondly i am not very clear ,where we should put business logic in grail app.Ideal place should be services i suppose

我们正在研究 Angular.js,因为它似乎比 gsp 页面更快,前端的当前风格和与 grail 的集成也更容易.想检查这个选项是否正确.

We are examining Angular.js since it seems to faster than gsp pages,current flavour for frontend and integration with grail is also easier.Wanted to check is this correct option or not.

推荐答案

Grails 非常适合快节奏的开发需求,如果您对它有基本的了解,就会喜欢上它.您可以使用任何框架/语言编写性能不佳的应用程序.我建议的一件事是深入了解 Hibernate,它是底层的持久性库.如果您了解它的工作原理,它应该可以帮助您避免在数据库级别犯任何愚蠢的错误.

Grails is very well suited fast paced development needs and you will love it when you get basic understanding of it. You can write a badly performing application in any framework/language. One thing I'd recommend is getting a good understanding of Hibernate which is the underlying persistence library. If you understand how that works, it should help you avoid making any silly mistakes at the DB level.

对于您问题的第一部分,您的 Web 应用程序的可扩展性实际上并不取决于您选择使用的语言/框架,而是您的应用程序的构建方式.您可以在 Grails 中构建一个可扩展的 Web 应用程序,就像您可以在 C++ 中构建一个非常慢的应用程序一样.如果 Grails 是您想使用的框架,那么就使用它;如果需要,您总是可以用 Java 或其他快速语言重写慢的部分.(毕竟,这就是 Twitter 对 Scala 所做的.)

For the first part of your question the scalability of your web application won't really depend on what language/framework you choose to use, but rather how your application is built. You can build a scalable web application in Grails, just as you can build an incredibly slow application in C++. If Grails is the framework you would like to use, then use it; you can always rewrite the slow parts in Java or another fast language, if need be. (After all, that's what Twitter did with Scala.)

在我们公司,我们使用 grails 作为客户端交互/许可服务器,并使用多个 Node.js 服务器进行分析.因此,客户端提供的所有内容都存储在 grails 服务器上,然后将功能数据发送到 Node.js 服务器集群进行进一步处理.来自 Node.js 服务器的分析数据由 grails 服务器使用 http 构建器获取,用于在仪表板上绘制图表和数据.

In our company what we do is use grails as a client interaction/licensing server and use multiple Node.js servers for analytics. So all what client gives gets stored on grails server and then the functional data is sent to Node.js server cluster for further processing. The analytics data from Node.js server is fetched by grails server using http builder and is used to plot charts and data on dashboard.

//------------- 更新问题的答案--------------

//------------- Updating answer for updated question ----------------------

  • Node.js 是服务器端技术,它不适用于前端,即客户端
  • 在 grails 中,您将所有传入(到服务器)和传出(从服务器)的内容写入控制器.
  • 虽然您的所有业务逻辑/计算/数据库查询都会进入您的服务方法.完成后,通过 return 语句将计算数据发送回控制器,控制器将在 GSP 上发送/显示它.
  • 虽然关于你的 angular JS 问题,我会说你不能用 angular JS 替换 GSP,因为 GSP 只不过是一种服务器端脚本,你可以在其中以 script-lets 形式编写 grails/groovy/java 代码以及普通的 HTML 代码和它被渲染成完整的 HTML 并被发送到客户端.因此,您只能通过向其添加像 Angular 这样的前端 MVC 来增强其功能,而无法替代它.功能明智的 Angular 是极好的框架.将任何类型的 JS 添加到您的 GSP 并享受它们.

附言- 一旦你掌握了 GSP 标签,你就会开始喜欢 GSP,因为它很容易做很多事情.

P.S. - You'll start loving GSP once you get hang of GSP tags which are so easy to do many things.

这篇关于Grails 作为单个应用程序或不同的后端和前端应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆