我想在一种运输方式(Thrift)上使用多种服务 [英] I'd like to use multiple services on one transport ( Thrift )

查看:110
本文介绍了我想在一种运输方式(Thrift)上使用多种服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建多个服务,并且希望将它们与不同的标识符一起使用. 所以我的意思是:

I'd like to create several services, and I want to use them with different identifiers. So I mean :

我有一个用户和项目服务. 我想同时使用它们.

I've got a Users and Projects service . I want to use these at the same time.

我的意思是我可以在xmlrpc的"handlermap"中添加更多的服务".

I mean I can add more 'services' to the "handlermap" on xmlrpc.

http://ws.apache.org/xmlrpc/server.html

phm.addHandler("Users",
             Users.class); 
phm.addHandler("Projects",
               Projects.class);

我想在节俭中做同样的事情.

I would like to do the same in the thrift.

这是一个简单的例子: test.thrift

Here is a simple example : test.thrift

typedef i64 UserId

struct Bonk
{
  1: string message,
  2: i32 type
}

struct Insanity
{
  1: map<Bonk, UserId> userMap,
  2: list<Bonk> xtructs
}



service ThriftTest
{
  void         testVoid(),
  string       testString(1: string test),
  byte         testByte(1: byte test),
  i32          testI32(1: i32 test),
  i64          testI64(1: i64 test),
  double       testDouble(1: double test),
  list<map<i32,i32>> testMap(1: map<i32,i32> test),
  map<string,string> testStringMap(1: map<string,string> test),
  set<i32>     testSet(1: set<i32> test),
  map<i32,map<i32,i32>> testMapMap(1: i32 test),
  map<UserId, map<i32,Insanity>> testInsanity(1: Insanity argument)
}

然后,我创建一个Implementatino,然后将其添加到TServer的实例中.

Then I create an implementatino, then add it to the instance of TServer .

Users.Processor users_proccesor = new Users.Processor(New UsersImpl());
Projects.Processor project_processor = new Projects.Processors(new ProjectsImp());
// I would like to add Users and Projects  
ThriftTest.Processor prc = new ThriftTest.Processor(new ThiftTestImp());
            TServerTransport serverTransport = new TServerSocket(9090);
            TServer server = new TSimpleServer(new Args(serverTransport).processor( prc ));

这是我的大问题,我无法添加服务器的多个实例.

And here's my big problem, I can't add multiple instances of the server.

谢谢您的帮助.

推荐答案

现在已经集成了多路复用服务(本质上就是您要在此处执行的操作).已经有针对多种语言的补丁程序,这些补丁程序已经被接受或正在接受审核.

Multiplexed Services (in essence that's what you want to do here) are being integrated right now. There are already patches for a number of languages available, either already accepted or in the process of being reviewed.

https://issues.apache.org/jira/browse/THRIFT-563 是一个很好的起点.

https://issues.apache.org/jira/browse/THRIFT-563 is a good place to start.

PS:欢迎评论者和贡献者;-)

PS: Reviewers and contributions are welcome ;-)

这篇关于我想在一种运输方式(Thrift)上使用多种服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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