Esempio n. 1
0
def base64_thrift(thrift_obj):
    trans = TMemoryBuffer()
    tbp = TBinaryProtocol(trans)

    thrift_obj.write(tbp)

    return b64encode(bytes(trans.getvalue())).strip()
Esempio n. 2
0
 def read_it(stream):
     stream_bytes = stream.read()
     transport_in = TMemoryBuffer(stream_bytes)
     protocol_in = TBinaryProtocol(transport_in)
     topology = storm_thrift.StormTopology()
     topology.read(protocol_in)
     cls._topology = topology
     cls.thrift_bolts = topology.bolts
     cls.thrift_spouts = topology.spouts
     # Can't reconstruct Python specs from Thrift.
     cls.specs = []
Esempio n. 3
0
 def write_it(stream):
     transport_out = TMemoryBuffer()
     protocol_out = TBinaryProtocol(transport_out)
     cls._topology.write(protocol_out)
     transport_bytes = transport_out.getvalue()
     stream.write(transport_bytes)
Esempio n. 4
0
 def get_proto(self):
     """Create a TBinaryProtocol instance
     """
     self.trans = TBufferedTransport(self.sock)
     return TBinaryProtocol(self.trans)
Esempio n. 5
0
def _build_log_message(span):
    trans = TMemoryBuffer()
    protocol = TBinaryProtocol(trans=trans)
    span.write(protocol)
    return base64.b64encode(trans.getvalue())