thrift

Default arguments with default values in Thrift Python client

最后都变了- 提交于 2019-12-07 08:47:46
问题 I have Python client calls a Thrift service with some optional parameters like this: bool postTweet(1: required Tweet tweet, 2: i32 x = 100); If I tried to call this service from Python client without passing the optional parameter x, I get an exception: TypeError: postTweet() takes exactly 2 arguments (1 given) Any clues why I get this exception however it is optional parameter with a default value? 回答1: It's not possible to define a thrift function with default value (well at least from my

How can write or find a PHP extension for Apache Thrift

南楼画角 提交于 2019-12-07 07:37:40
Apache Thrift now only support PHP source files (copy [thrift-source]/lib/php/lib to own project to use). But, Can i find a .dll PHP extension file instead that? Where can i find it? Otherwise, i have to write it. Could you tell me how to do that (i usually use Apache server)? Is that right if I install C++ Lib of Apache Thrift and write PHP extension base on it? Or, can i generate from thrift-source (i have looked cpp files [thrift-source]/lib/php/src/ext , but maybe protocol only)? 来源: https://stackoverflow.com/questions/26623610/how-can-write-or-find-a-php-extension-for-apache-thrift

How can I add a generated source folder to my source path in Gradle and IntelliJ?

倖福魔咒の 提交于 2019-12-07 05:19:21
问题 I use thrift and it generates some source java files(interfaces) under build directory (build/generated-sources/thrift/<package name>/<class>) but under my src/main/java I have my classes which has the same package definition as in the generated java files and my classes also implements the interfaces generated by the thrift so how can I configure this in my build.gradle so it works on i ntelliJ as well as the build plugins { id "org.jruyi.thrift" version "0.3.1" } apply plugin: 'idea' apply

How to set rpc timeout in thrift python client?

有些话、适合烂在心里 提交于 2019-12-07 04:59:01
问题 I'm writing python client using thrift, but I can't find any available option to set rpc time out. My client code goes below: socket = TSocket.TSocket(address, port) transport = TTransport.TBufferedTransport(socket) protocol = TBinaryProtocol.TBinaryProtocol(transport) server = Client.Client(protocol) transport.open() 回答1: You can use socket.setTimeout() method. from thrift.transport.THttpClient import THttpClient socket = THttpClient(server_url) socket.setTimeout(SERVICE_TIMEOUT_IN_mS)

How can you reverse engineer a binary thrift file?

梦想的初衷 提交于 2019-12-07 04:49:37
问题 I've been asked to process some files serialized as binary (not text/JSON unfortunately) Thrift objects, but I don't have access to the program or programmer that created the files, so I have no idea of their structure, field order, etc. Is there a way using the Thrift libraries to open a binary file and analyze it, getting a list of the field types, values, nesting, etc.? 回答1: Unfortunately it appears that Thrift's binary protocol does not do very much tagging of data at all; to decode it

configure: error: no acceptable C compiler found in $PATH

可紊 提交于 2019-12-07 02:38:35
问题 I am trying to Build and Install the Apache Thrift compiler and libraries I had to type this command is shown in instructions ./configure && make But I get this error: checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: in `/PATH/TO/thrift-0.9.3': configure: error: no acceptable C compiler found in $PATH When I type in my command prompt gcc --version I get this gcc (GCC) 5.3.0 Copyright (C) 2015 Free Software Foundation, Inc. This is free software; see the

Convert an object to a JSON string with thrift json serialization

时光总嘲笑我的痴心妄想 提交于 2019-12-07 01:52:32
问题 I'm new to the thrift. I need to convert my data object to a JSON string with Thrift JSON serialization. I tried in this way. TSerializer serializer = new TSerializer(new TSimpleJSONProtocol.Factory()); String json = serializer.toString(object_name); In here is an error, that object_name should be in TBase . How can I resolve this ? 回答1: In here is an error, that object_name should be in TBase. Next time, please post the exact error message (use copy+paste), this makes it easier for all of us

High performance object serialization library supporting sum types

放肆的年华 提交于 2019-12-07 01:37:19
问题 I wonder if any of the high performance serialization libraries (like Google protocol buffers) support sum types. Sum types are tagged unions, basically the ability to say that something is either A, B, or C. Sum types are used in languages such as Haskell and ML which support Algebraic Data Types 回答1: If by "like Google protocol buffers" you mean ability to generate code for multiple languages then probably such thing doesn't exist. Emulating sum types in languages which don't support them

I'd like to use multiple services on one transport ( Thrift )

不羁岁月 提交于 2019-12-07 01:11:38
问题 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. 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. Here is a simple example : test.thrift typedef i64 UserId struct Bonk { 1: string message,

Thrift的java和php数据交互

落花浮王杯 提交于 2019-12-06 19:03:59
Thrift是一个软件框架(远程过程调用框架),用来进行可扩展且跨语言的服务的开发,封装了数据传输格式(二进制、json)和网络通信的服务框架,提供多语言(C++, Java, Python, PHP, Ruby, Erlang, Perl, Haskell, C#, Cocoa, JavaScript, Node.js, Smalltalk, and OCaml)的网络服务器端和客户端程序组件 适用于搭建大型数据交换及存储的通用工具,对于大型系统中的内部数据传输相对于JSON和xml无论在性能、传输大小上有明显的优势。 本文以注册服务接口和登录服务器接口为教程, Thrift开发的几个概念: Server 服务模型 Handler 数据处理接口 Processor 数据处理对象 Protocol 数据传输协议 Transport 数据传输方式 (1)支持的传输格式 TBinaryProtocol – 二进制格式. TCompactProtocol – 压缩格式 TJSONProtocol – JSON格式 TSimpleJSONProtocol –提供JSON只写协议, 生成的文件很容易通过脚本语言解析。 TDebugProtocol – 使用易懂的可读的文本格式,以便于debug (2) 支持的通信方式(数据传输方式)(Transport) TFileTransport:文件