Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use a struct defined in a Thrift file using keyword "include"

I'm a newbie with Thrift. I have the following question: Suppose that I defined a struct in file "Ex1.thrift" as follow:

namespace java tut1
struct Address {
 1:string nameStreet,
 2:i32 idHouse
}

I want to use struct Address in file "Ex2.thrift", how could I do that? I tried this way but Thrift compiler doesn't work:

include "Ex1.thrift"
namespace java tut2
struct Student {
 1:string name,
 2:i32 age,
 3:Address add
}

service ExampleService {
 list<Student> getListStudent()
}

Thank you so much for any answer.

like image 970
zungnv Avatar asked Dec 08 '11 05:12

zungnv


1 Answers

You need to provide Ex1 prefix while using address in Ex2.thrift

    include "Ex1.thrift"
    namespace java tut2
    struct Student {
    1:string name,
    2:i32 age,
    3:Ex1.Address add
    }

    service ExampleService {
    list<Student> getListStudent()
    }

This works in Thrift 0.8.0

like image 123
gt5050 Avatar answered Oct 15 '22 22:10

gt5050