I started to use apache thrift (programming for java) and It’s very hard to find documentation which explain in deeply about it – so I hope you’ll be able to help me.
I’m trying to make an service (interface) which has a function that return a field with functions (for example: another interface).
I tried this code:
namespace java test
service A {
string somefunc()
}
service B {
string somefunc2(),
A getA()
}
But I didn’t success.. when I try to compile the thrift file I get an error that it in service B – A field is not defined.
I tried also:
namespace java test
struct A {
1: string somefunc()
}
service B {
A getA()
}
This time it compiled successfully but it didn’t count somefunc as a function however as a field in type of string.
Is there anyway make something like what I want?
Thanks!
Thrift sends serialized data structures over the wire. There’s no standart way to send executable code. Various languages allow transferring code over the wire (i.e., java
.classfile or python script in text form) but can’t be made interoperable and thus not supported by thrift.However, thrift might be used for service discovery, if it’s what you need. Single thrift service is always bound on specific host/port. So, thrift definition for service discovery code might look like this:
The service discovery code might look like this:
If it’s needed,
Endpointdefinition might be extended with protocol/transport metadata allowing to choose between binary/compact/JSON protocols and TTransport/TFramedTransport/etc..