Rails:如何使我的Rails项目成为Hexagonal rails项目? [英] Rails: How do I make my rails project a Hexagonal rails project?

查看:111
本文介绍了Rails:如何使我的Rails项目成为Hexagonal rails项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我昨天参加了一次关于缩放Rails的聚会,其中一个主题是Hexagonal Rails.但是,我只从事Rails一年了,对MVC结构真的很满意(也许太满意),所以我不太了解适配器和消息队列是什么.

I attended a meetup yesterday on scaling Rails, and one topic was Hexagonal Rails. However, I've only been doing Rails for a year, and am really comfortable (maybe too comfortable) with the MVC structure, so I don't really understand what adapter and message queue are.

这是有关此的文章: http://victorsavkin.com/post/42542190528/hexagonal-architecture-for-rails-developers

和一张图片: http://blog.mattwynne. net/wp-content/uploads/2012/06/hexagonal_architecture_sketch.jpg

据我所知,我认为这是关于将各部分解耦,以便对动作进行专门过滤并传递到应用程序的某些位置,而不是为所有内容使用中央路由器".我认为这样可以最大程度地减少ActiveRecord的使用和创建一堆模块?我对此很困惑,所以我有几个问题:

To my understanding, I think it's about decoupling the parts so that actions are specifically filtered and passed to certain places of your application instead of having a central "router" for everything. I think this results in minimizing the use of ActiveRecord and the creation of a bunch of modules? I am pretty stumped on this so I have a few questions:

  1. 要使我的项目成为Hexagonal Rails项目,我应将这些模块准确放置在哪里(哪个文件夹?我要创建一个具有特定名称的新文件夹吗?)

  1. To make my project a Hexagonal Rails project, where exactly do I put these modules (what folder? Do I create a new folder of a specific name?)

这还用于内部维护吗?为了安全?

Is this more for internal maintenance? For security?

据我所知,如果Rails应用程序变得太大,您是否不能将某些部分拆分到另一个应用程序中(我相信这就是所谓的面向服务的体系结构?),而只是从您的主应用程序对其进行请求?或者,如果流量太重,则可以使用负载平衡器+多台服务器.

From what I know, if a rails app gets too large can't you just split certain parts into another app (I believe it's called service oriented architecture?) and just make requests to it from your main app? Or perhaps use a load balancer + multiple servers if traffic gets too heavy.

推荐答案

您链接的Victor Savkin帖子很好地表达了自己的观点:

The Victor Savkin post you linked to put it well:

六角形体系结构有助于将应用程序与交付机制分开.

The hexagonal architecture helps separate the application from the delivery mechanism.

我的理解是,六角体系结构起源于Rails,它只是实际应用的交付机制"(可能是其中的一种). 这是一种将您的应用程序与Rails隔离开来的尝试,并且超出了人们只是用引擎将应用程序拆分为较小部分时尝试做的事情.

My understanding is that Hexagonal Architecture has its roots in the view of Rails as just a "delivery mechanism" (possibly one of many) for your actual application. It is an attempt to isolate your app from Rails and goes way beyond what people are trying to do when they are just splitting an app into smaller pieces with engines.

DHH(Rails的创建者)将Hex体系结构视为" TDD引起的设计损伤"与TDD(Kent Beck)的创建者进行了系列对话和您一定要注意马丁·福勒(Martin Fowler).

DHH (the creator of Rails) views the Hex architecture as "TDD induced design damage" and there has been a series of talks with the creator of TDD (Kent Beck) and Martin Fowler which you should definitely watch.

我对您的问题的回答是:不.关于六边形建筑的对话现在正在发生.除非您迫切需要将应用程序代码与Rails分开,否则我建议您观看讨论并等到尘埃落定,看看这一切产生了什么.

My answer to your question would be: don't. The conversation about Hexagonal Architecture is happening right now. Unless you have some burning need to separate your application code from Rails, I suggest you watch the talks and wait until the dust settles to see what comes out of all this.

这篇关于Rails:如何使我的Rails项目成为Hexagonal rails项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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