You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Dirk Breuer (JIRA)" <ji...@apache.org> on 2009/04/30 10:05:30 UTC

[jira] Created: (THRIFT-474) Generating Ruby on Rails friendly code

Generating Ruby on Rails friendly code
--------------------------------------

                 Key: THRIFT-474
                 URL: https://issues.apache.org/jira/browse/THRIFT-474
             Project: Thrift
          Issue Type: Improvement
          Components: Compiler (Ruby)
            Reporter: Dirk Breuer
         Attachments: t_rb_generator.cc.patch

As already quoted in issue THRIFT-468 we are trying to integrate Thrift as our RPC solution into Rails applications. Since Rails uses its own class loading mechanism with {{require_dependency}} there should be no regular require within your Rails application (The mechanism requires automatically any Constant you call). I extended the Thrift Ruby generator with a {{rails}} option to use {{require_dependency}} instead of {{require}}. In addition to this I basically changed the generated folder structure. Like in Java for instance you should nest namespaced classes in a directory structure which represent that namespace. Due to this is valid even for non-Rails related code I integrated this feature without any switch. But it is especially relevant for Rails, because its auto class loading mechanism expects to find a namespaced class under an appropriate directory layout within the load path.

I'm not a C++ guy so I would be really thankful if you could give me some useful feedback to this patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-474) Generating Ruby on Rails friendly code

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12704696#action_12704696 ] 

Bryan Duxbury commented on THRIFT-474:
--------------------------------------

I don't disagree that generating the folder structure to match the namespace structure is a good idea, but that *is* a breaking change, so I wonder if that shouldn't be in it's own issue and patch instead of under this one.

For what it's worth, we use Thrift objects in Rails too, but we just require them in environment.rb. Is it important for the autoloading to pick up Thrift objects?

> Generating Ruby on Rails friendly code
> --------------------------------------
>
>                 Key: THRIFT-474
>                 URL: https://issues.apache.org/jira/browse/THRIFT-474
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Ruby)
>            Reporter: Dirk Breuer
>         Attachments: t_rb_generator.cc.patch
>
>
> As already quoted in issue THRIFT-468 we are trying to integrate Thrift as our RPC solution into Rails applications. Since Rails uses its own class loading mechanism with {{require_dependency}} there should be no regular require within your Rails application (The mechanism requires automatically any Constant you call). I extended the Thrift Ruby generator with a {{rails}} option to use {{require_dependency}} instead of {{require}}. In addition to this I basically changed the generated folder structure. Like in Java for instance you should nest namespaced classes in a directory structure which represent that namespace. Due to this is valid even for non-Rails related code I integrated this feature without any switch. But it is especially relevant for Rails, because its auto class loading mechanism expects to find a namespaced class under an appropriate directory layout within the load path.
> I'm not a C++ guy so I would be really thankful if you could give me some useful feedback to this patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-474) Generating Ruby on Rails friendly code

Posted by "Dirk Breuer (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-474?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dirk Breuer updated THRIFT-474:
-------------------------------

    Attachment: t_rb_generator.cc.patch

> Generating Ruby on Rails friendly code
> --------------------------------------
>
>                 Key: THRIFT-474
>                 URL: https://issues.apache.org/jira/browse/THRIFT-474
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Ruby)
>            Reporter: Dirk Breuer
>         Attachments: t_rb_generator.cc.patch
>
>
> As already quoted in issue THRIFT-468 we are trying to integrate Thrift as our RPC solution into Rails applications. Since Rails uses its own class loading mechanism with {{require_dependency}} there should be no regular require within your Rails application (The mechanism requires automatically any Constant you call). I extended the Thrift Ruby generator with a {{rails}} option to use {{require_dependency}} instead of {{require}}. In addition to this I basically changed the generated folder structure. Like in Java for instance you should nest namespaced classes in a directory structure which represent that namespace. Due to this is valid even for non-Rails related code I integrated this feature without any switch. But it is especially relevant for Rails, because its auto class loading mechanism expects to find a namespaced class under an appropriate directory layout within the load path.
> I'm not a C++ guy so I would be really thankful if you could give me some useful feedback to this patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-474) Generating Ruby on Rails friendly code

Posted by "Dirk Breuer (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-474?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12708793#action_12708793 ] 

Dirk Breuer commented on THRIFT-474:
------------------------------------

Bryan, I agree on the folder structure change. This surely will break existing code. 

For your other point, it isn't really necessary that's right but in my opinion it fits much better in the Rails 'convention over configuration' principle.

FYI, we are using those changes successfully in all our thrift sub-projects (we are having 5 of them).

> Generating Ruby on Rails friendly code
> --------------------------------------
>
>                 Key: THRIFT-474
>                 URL: https://issues.apache.org/jira/browse/THRIFT-474
>             Project: Thrift
>          Issue Type: Improvement
>          Components: Compiler (Ruby)
>            Reporter: Dirk Breuer
>         Attachments: t_rb_generator.cc.patch
>
>
> As already quoted in issue THRIFT-468 we are trying to integrate Thrift as our RPC solution into Rails applications. Since Rails uses its own class loading mechanism with {{require_dependency}} there should be no regular require within your Rails application (The mechanism requires automatically any Constant you call). I extended the Thrift Ruby generator with a {{rails}} option to use {{require_dependency}} instead of {{require}}. In addition to this I basically changed the generated folder structure. Like in Java for instance you should nest namespaced classes in a directory structure which represent that namespace. Due to this is valid even for non-Rails related code I integrated this feature without any switch. But it is especially relevant for Rails, because its auto class loading mechanism expects to find a namespaced class under an appropriate directory layout within the load path.
> I'm not a C++ guy so I would be really thankful if you could give me some useful feedback to this patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.