You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@thrift.apache.org by Nan Zhu <zh...@gmail.com> on 2012/09/28 19:21:56 UTC

回复: Modify the design of RPC framework?

Hi, Ted,   

Thanks for your replying,  

 18 class UserStorageHandler : virtual public UserStorageIf {
 19  public:
 20   UserStorageHandler() {
 21     // Your initialization goes here
 22   }
 23  
 24   void store(const UserProfile& user) {
 25     // Your implementation goes here
 26     printf("store\n");
 27   }
 28  
 29   void retrieve(UserProfile& _return, const int32_t uid) {
 30     // Your implementation goes here
 31     printf("retrieve\n");
 32   }
 33  
 34 };


the above is the generated code, do you mean I should remove those {} and printf(), and change this generated cpp file as a header file, and then implement the functions in a cpp?

Best


--  
Nan Zhu
School of Computer Science,
McGill University

在 2012年9月28日星期五,下午1:13,Ted Dunning 写道:  
> You should never modify the generated code by hand. Implement them in a
> separate file.
>  
> On Fri, Sep 28, 2012 at 1:07 PM, Nan Zhu <zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com)> wrote:
>  
> > Hi, all
> >  
> > I met a question during my development using Thrift
> >  
> > e.g. at the beginning of the project, I generate the c++ code from
> > ".thrift" file, and then I work on those RPC callees to implement them,
> > after that, I found I need to add another callee to the system, I modify
> > the .thrift file and generate the C++ code again,
> >  
> > how should I merge the new version of generated code with my implemented
> > version? do I need to copy the related part manually(e.g. new callee
> > declaration)?
> >  
> > Thank you!
> >  
> > Best,
> >  
> > --
> > Nan Zhu
> > School of Computer Science,
> > McGill University
> >  
>  
>  
>  



回复: Modify the design of RPC framework?

Posted by Nan Zhu <zh...@gmail.com>.
Wow, thank you Patrick,   

I finally know which file is what I should refer to

Best,  

--  
Nan Zhu
School of Computer Science,
McGill University

在 2012年9月28日星期五,下午1:38,Patrick Scott 写道:  
> The c++ generator does generate interfaces. I think the file you are
> referring to is UserStorage_server.skeleton.cpp which the compiler
> generates. You do not need to modify this file. Instead, create your own
> implementation file that does something very similar.
>  
> I use the c++ generator heavily and I ignore the skeleton file in compiling
> and just create my own implementation file that implements the service
> interface.
>  
> On Fri, Sep 28, 2012 at 1:29 PM, Nan Zhu <zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com)> wrote:
>  
> > Ted, Thank you for the answering
> >  
> > any one using C++ can give me a help?
> >  
> > Best,
> >  
> > --
> > Nan Zhu
> > School of Computer Science,
> > McGill University
> >  
> > 在 2012年9月28日星期五,下午1:23,Ted Dunning 写道:
> > > I haven't used C++ with Thrift. In Java, the generator builds interfaces.
> > >  
> > > On Fri, Sep 28, 2012 at 1:21 PM, Nan Zhu <zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com) (mailto:
> > zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com))> wrote:
> > >  
> > > > Hi, Ted,
> > > >  
> > > > Thanks for your replying,
> > > >  
> > > > 18 class UserStorageHandler : virtual public UserStorageIf {
> > > > 19 public:
> > > > 20 UserStorageHandler() {
> > > > 21 // Your initialization goes here
> > > > 22 }
> > > > 23
> > > > 24 void store(const UserProfile& user) {
> > > > 25 // Your implementation goes here
> > > > 26 printf("store\n");
> > > > 27 }
> > > > 28
> > > > 29 void retrieve(UserProfile& _return, const int32_t uid) {
> > > > 30 // Your implementation goes here
> > > > 31 printf("retrieve\n");
> > > > 32 }
> > > > 33
> > > > 34 };
> > > >  
> > > >  
> > > > the above is the generated code, do you mean I should remove those {}
> > and
> > > > printf(), and change this generated cpp file as a header file, and then
> > > > implement the functions in a cpp?
> > > >  
> > > > Best
> > > >  
> > > >  
> > > > --
> > > > Nan Zhu
> > > > School of Computer Science,
> > > > McGill University
> > > >  
> > > > 在 2012年9月28日星期五,下午1:13,Ted Dunning 写道:
> > > > > You should never modify the generated code by hand. Implement them
> > > >  
> > > >  
> > >  
> >  
> > in a
> > > > > separate file.
> > > > >  
> > > > > On Fri, Sep 28, 2012 at 1:07 PM, Nan Zhu <zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com)(mailto:
> > zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com)) (mailto:
> > > > zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com))> wrote:
> > > > >  
> > > > > > Hi, all
> > > > > >  
> > > > > > I met a question during my development using Thrift
> > > > > >  
> > > > > > e.g. at the beginning of the project, I generate the c++ code from
> > > > > > ".thrift" file, and then I work on those RPC callees to implement
> > > > > >  
> > > > >  
> > > > >  
> > > >  
> > > >  
> > >  
> >  
> > them,
> > > > > > after that, I found I need to add another callee to the system, I
> > > > >  
> > > >  
> > > >  
> > > > modify
> > > > > > the .thrift file and generate the C++ code again,
> > > > > >  
> > > > > > how should I merge the new version of generated code with my
> > > > implemented
> > > > > > version? do I need to copy the related part manually(e.g. new
> > > > >  
> > > >  
> > > >  
> > >  
> >  
> > callee
> > > > > > declaration)?
> > > > > >  
> > > > > > Thank you!
> > > > > >  
> > > > > > Best,
> > > > > >  
> > > > > > --
> > > > > > Nan Zhu
> > > > > > School of Computer Science,
> > > > > > McGill University
> > > > > >  
> > > > >  
> > > >  
> > >  
> >  
> >  
>  
>  
>  



Re: 回复: Modify the design of RPC framework?

Posted by Patrick Scott <pa...@springmetrics.com>.
The c++ generator does generate interfaces. I think the file you are
referring to is UserStorage_server.skeleton.cpp which the compiler
generates. You do not need to modify this file. Instead, create your own
implementation file that does something very similar.

I use the c++ generator heavily and I ignore the skeleton file in compiling
and just create my own implementation file that implements the service
interface.

On Fri, Sep 28, 2012 at 1:29 PM, Nan Zhu <zh...@gmail.com> wrote:

> Ted, Thank you for the answering
>
> any one using C++ can give me a help?
>
> Best,
>
> --
> Nan Zhu
> School of Computer Science,
> McGill University
>
> 在 2012年9月28日星期五,下午1:23,Ted Dunning 写道:
> > I haven't used C++ with Thrift. In Java, the generator builds interfaces.
> >
> > On Fri, Sep 28, 2012 at 1:21 PM, Nan Zhu <zhunansjtu@gmail.com (mailto:
> zhunansjtu@gmail.com)> wrote:
> >
> > > Hi, Ted,
> > >
> > > Thanks for your replying,
> > >
> > > 18 class UserStorageHandler : virtual public UserStorageIf {
> > > 19 public:
> > > 20 UserStorageHandler() {
> > > 21 // Your initialization goes here
> > > 22 }
> > > 23
> > > 24 void store(const UserProfile& user) {
> > > 25 // Your implementation goes here
> > > 26 printf("store\n");
> > > 27 }
> > > 28
> > > 29 void retrieve(UserProfile& _return, const int32_t uid) {
> > > 30 // Your implementation goes here
> > > 31 printf("retrieve\n");
> > > 32 }
> > > 33
> > > 34 };
> > >
> > >
> > > the above is the generated code, do you mean I should remove those {}
> and
> > > printf(), and change this generated cpp file as a header file, and then
> > > implement the functions in a cpp?
> > >
> > > Best
> > >
> > >
> > > --
> > > Nan Zhu
> > > School of Computer Science,
> > > McGill University
> > >
> > > 在 2012年9月28日星期五,下午1:13,Ted Dunning 写道:
> > > > You should never modify the generated code by hand. Implement them
> in a
> > > > separate file.
> > > >
> > > > On Fri, Sep 28, 2012 at 1:07 PM, Nan Zhu <zhunansjtu@gmail.com(mailto:
> zhunansjtu@gmail.com) (mailto:
> > > zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com))> wrote:
> > > >
> > > > > Hi, all
> > > > >
> > > > > I met a question during my development using Thrift
> > > > >
> > > > > e.g. at the beginning of the project, I generate the c++ code from
> > > > > ".thrift" file, and then I work on those RPC callees to implement
> them,
> > > > > after that, I found I need to add another callee to the system, I
> > > > >
> > > >
> > > >
> > >
> > > modify
> > > > > the .thrift file and generate the C++ code again,
> > > > >
> > > > > how should I merge the new version of generated code with my
> > > implemented
> > > > > version? do I need to copy the related part manually(e.g. new
> callee
> > > > > declaration)?
> > > > >
> > > > > Thank you!
> > > > >
> > > > > Best,
> > > > >
> > > > > --
> > > > > Nan Zhu
> > > > > School of Computer Science,
> > > > > McGill University
> > > > >
> > > >
> > >
> > >
> >
> >
> >
>
>
>

回复: Modify the design of RPC framework?

Posted by Nan Zhu <zh...@gmail.com>.
Ted, Thank you for the answering

any one using C++ can give me a help?

Best,  

--  
Nan Zhu
School of Computer Science,
McGill University

在 2012年9月28日星期五,下午1:23,Ted Dunning 写道:  
> I haven't used C++ with Thrift. In Java, the generator builds interfaces.
>  
> On Fri, Sep 28, 2012 at 1:21 PM, Nan Zhu <zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com)> wrote:
>  
> > Hi, Ted,
> >  
> > Thanks for your replying,
> >  
> > 18 class UserStorageHandler : virtual public UserStorageIf {
> > 19 public:
> > 20 UserStorageHandler() {
> > 21 // Your initialization goes here
> > 22 }
> > 23
> > 24 void store(const UserProfile& user) {
> > 25 // Your implementation goes here
> > 26 printf("store\n");
> > 27 }
> > 28
> > 29 void retrieve(UserProfile& _return, const int32_t uid) {
> > 30 // Your implementation goes here
> > 31 printf("retrieve\n");
> > 32 }
> > 33
> > 34 };
> >  
> >  
> > the above is the generated code, do you mean I should remove those {} and
> > printf(), and change this generated cpp file as a header file, and then
> > implement the functions in a cpp?
> >  
> > Best
> >  
> >  
> > --
> > Nan Zhu
> > School of Computer Science,
> > McGill University
> >  
> > 在 2012年9月28日星期五,下午1:13,Ted Dunning 写道:
> > > You should never modify the generated code by hand. Implement them in a
> > > separate file.
> > >  
> > > On Fri, Sep 28, 2012 at 1:07 PM, Nan Zhu <zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com) (mailto:
> > zhunansjtu@gmail.com (mailto:zhunansjtu@gmail.com))> wrote:
> > >  
> > > > Hi, all
> > > >  
> > > > I met a question during my development using Thrift
> > > >  
> > > > e.g. at the beginning of the project, I generate the c++ code from
> > > > ".thrift" file, and then I work on those RPC callees to implement them,
> > > > after that, I found I need to add another callee to the system, I
> > > >  
> > >  
> > >  
> >  
> > modify
> > > > the .thrift file and generate the C++ code again,
> > > >  
> > > > how should I merge the new version of generated code with my
> > implemented
> > > > version? do I need to copy the related part manually(e.g. new callee
> > > > declaration)?
> > > >  
> > > > Thank you!
> > > >  
> > > > Best,
> > > >  
> > > > --
> > > > Nan Zhu
> > > > School of Computer Science,
> > > > McGill University
> > > >  
> > >  
> >  
> >  
>  
>  
>  



Re: 回复: Modify the design of RPC framework?

Posted by Ted Dunning <te...@gmail.com>.
I haven't used C++ with Thrift.  In Java, the generator builds interfaces.

On Fri, Sep 28, 2012 at 1:21 PM, Nan Zhu <zh...@gmail.com> wrote:

> Hi, Ted,
>
> Thanks for your replying,
>
>  18 class UserStorageHandler : virtual public UserStorageIf {
>  19  public:
>  20   UserStorageHandler() {
>  21     // Your initialization goes here
>  22   }
>  23
>  24   void store(const UserProfile& user) {
>  25     // Your implementation goes here
>  26     printf("store\n");
>  27   }
>  28
>  29   void retrieve(UserProfile& _return, const int32_t uid) {
>  30     // Your implementation goes here
>  31     printf("retrieve\n");
>  32   }
>  33
>  34 };
>
>
> the above is the generated code, do you mean I should remove those {} and
> printf(), and change this generated cpp file as a header file, and then
> implement the functions in a cpp?
>
> Best
>
>
> --
> Nan Zhu
> School of Computer Science,
> McGill University
>
> 在 2012年9月28日星期五,下午1:13,Ted Dunning 写道:
> > You should never modify the generated code by hand. Implement them in a
> > separate file.
> >
> > On Fri, Sep 28, 2012 at 1:07 PM, Nan Zhu <zhunansjtu@gmail.com (mailto:
> zhunansjtu@gmail.com)> wrote:
> >
> > > Hi, all
> > >
> > > I met a question during my development using Thrift
> > >
> > > e.g. at the beginning of the project, I generate the c++ code from
> > > ".thrift" file, and then I work on those RPC callees to implement them,
> > > after that, I found I need to add another callee to the system, I
> modify
> > > the .thrift file and generate the C++ code again,
> > >
> > > how should I merge the new version of generated code with my
> implemented
> > > version? do I need to copy the related part manually(e.g. new callee
> > > declaration)?
> > >
> > > Thank you!
> > >
> > > Best,
> > >
> > > --
> > > Nan Zhu
> > > School of Computer Science,
> > > McGill University
> > >
> >
> >
> >
>
>
>