Ejemplo n.º 1
0
import os
import sys
import thriftpy

thrift_dir = os.path.dirname(os.path.realpath(__file__))
thrift_file = open(os.path.join(thrift_dir, 'scribe.thrift'), 'r')


# This is a hack to support python3 as ply expects a string result from file.read()
class FileDecoder(object):
    def __init__(self, file):
        self.file = file

    def read(self):
        byte_string = self.file.read()
        if isinstance(byte_string, str):
            return byte_string
        return byte_string.decode('utf-8')

if sys.version_info >= (3, 0):
    thrift_file = FileDecoder(thrift_file)

scribe_thrift = thriftpy.load_fp(FileDecoder(thrift_file), module_name='scribe_thrift')
Ejemplo n.º 2
0
  2: HBPulse pulse,
  3: bool boolval,
  4: HBRecords records,
  5: HBNodes nodes,
  7: optional binary message_blob;
}

struct HBMessage {
  1: HBServerMessageType type,
  2: HBMessageData data,
  3: optional i32 message_id = -1,
}

exception HBAuthorizationException {
  1: required string msg;
}

exception HBExecutionException {
  1: required string msg;
}
"""

storm_thrift = thriftpy.load_fp(io.StringIO(_THRIFT_STR),
                                module_name="storm_thrift")
# Fix a lovely issue where GlobalStreamIds didn't have consistent hash values
storm_thrift.GlobalStreamId.__hash__ = lambda self: (hash(self.componentId) ^
                                                     hash(self.streamId))

# Import everything so it's actually available within this module
from storm_thrift import *
Ejemplo n.º 3
0
import thriftpy
from thriftpy.rpc import make_client
import msgpack
import time
from os import path
import platform
import sys
import threading
import socket

thrift_path = path.join(sys.modules["ROOT_DIR"], "jqdata.thrift")
thrift_path = path.abspath(thrift_path)
module_name = path.splitext(path.basename(thrift_path))[0]
thrift = None
with open(thrift_path) as f:
    thrift = thriftpy.load_fp(f, "jqdata_thrift")


class JQDataClient(object):

    _threading_local = threading.local()
    _auth_params = {}

    @classmethod
    def instance(cls):
        _instance = getattr(cls._threading_local, '_instance', None)
        if _instance is None:
            _instance = JQDataClient(**cls._auth_params)
            cls._threading_local._instance = _instance
        return _instance
Ejemplo n.º 4
0
struct DRPCRequest {
  1: required string func_args;
  2: required string request_id;
}

exception DRPCExecutionException {
  1: required string msg;
}

service DistributedRPC {
  string execute(1: string functionName, 2: string funcArgs) throws (1: DRPCExecutionException e, 2: AuthorizationException aze);
}

service DistributedRPCInvocations {
  void result(1: string id, 2: string result) throws (1: AuthorizationException aze);
  DRPCRequest fetchRequest(1: string functionName) throws (1: AuthorizationException aze);
  void failRequest(1: string id) throws (1: AuthorizationException aze);
}
"""

io_class = io.StringIO if six.PY3 else io.BytesIO
storm_thrift = thriftpy.load_fp(io_class(_THRIFT_STR),
                                module_name='storm_thrift')
# Fix a lovely issue where GlobalStreamIds didn't have consistent hash values
storm_thrift.GlobalStreamId.__hash__ = lambda self: (hash(self.componentId) ^
                                                     hash(self.streamId))

# Import everything so it's actually available within this module
from storm_thrift import *
Ejemplo n.º 5
0
   */
  StormTopology getUserTopology(1: string id) throws (1: NotAliveException e, 2: AuthorizationException aze);
}

struct DRPCRequest {
  1: required string func_args;
  2: required string request_id;
}

exception DRPCExecutionException {
  1: required string msg;
}

service DistributedRPC {
  string execute(1: string functionName, 2: string funcArgs) throws (1: DRPCExecutionException e, 2: AuthorizationException aze);
}

service DistributedRPCInvocations {
  void result(1: string id, 2: string result) throws (1: AuthorizationException aze);
  DRPCRequest fetchRequest(1: string functionName) throws (1: AuthorizationException aze);
  void failRequest(1: string id) throws (1: AuthorizationException aze);
}
"""

io_class = io.StringIO if six.PY3 else io.BytesIO
storm_thrift = thriftpy.load_fp(io_class(_THRIFT_STR),
                                module_name='storm_thrift')
# Fix a lovely issue where GlobalStreamIds didn't have consistent hash values
storm_thrift.GlobalStreamId.__hash__ = lambda self: (hash(self.componentId) ^
                                                     hash(self.streamId))
Ejemplo n.º 6
0
import os
import sys
import thriftpy

thrift_dir = os.path.dirname(os.path.realpath(__file__))
thrift_file = open(os.path.join(thrift_dir, 'zipkinCore.thrift'), 'r')


# This is a hack to support python3 as ply expects a string result from file.read()
class FileDecoder(object):
    def __init__(self, file):
        self.file = file

    def read(self):
        byte_string = self.file.read()
        if isinstance(byte_string, str):
            return byte_string
        return byte_string.decode('utf-8')


if sys.version_info >= (3, 0):
    thrift_file = FileDecoder(thrift_file)

ttypes = thriftpy.load_fp(FileDecoder(thrift_file),
                          module_name='zipkin_core_thrift')
Ejemplo n.º 7
0
  2: HBPulse pulse,
  3: bool boolval,
  4: HBRecords records,
  5: HBNodes nodes,
  7: optional binary message_blob;
}

struct HBMessage {
  1: HBServerMessageType type,
  2: HBMessageData data,
  3: optional i32 message_id = -1,
}

exception HBAuthorizationException {
  1: required string msg;
}

exception HBExecutionException {
  1: required string msg;
}
"""

storm_thrift = thriftpy.load_fp(io.StringIO(_THRIFT_STR), module_name="storm_thrift")
# Fix a lovely issue where GlobalStreamIds didn't have consistent hash values
storm_thrift.GlobalStreamId.__hash__ = lambda self: (
    hash(self.componentId) ^ hash(self.streamId)
)

# Import everything so it's actually available within this module
from storm_thrift import *
Ejemplo n.º 8
0
import os
import sys
import thriftpy

thrift_dir = os.path.dirname(os.path.realpath(__file__))
thrift_file = open(os.path.join(thrift_dir, 'scribe.thrift'), 'r')


# This is a hack to support python3 as ply expects a string result from file.read()
class FileDecoder(object):
    def __init__(self, file):
        self.file = file

    def read(self):
        byte_string = self.file.read()
        if isinstance(byte_string, str):
            return byte_string
        return byte_string.decode('utf-8')


if sys.version_info >= (3, 0):
    thrift_file = FileDecoder(thrift_file)

scribe_thrift = thriftpy.load_fp(FileDecoder(thrift_file),
                                 module_name='scribe_thrift')