@@ -305,6 +305,59 @@ def __eq__(self, other):
305
305
def __ne__ (self , other ):
306
306
return not (self == other )
307
307
308
+
309
+ # TODO(yingchun): host_port is now just a place holder and not well implemented, need improve it
310
+ class host_port :
311
+
312
+ thrift_spec = (
313
+ (1 , TType .STRING , 'host' , None , None , ), # 1
314
+ (2 , TType .I16 , 'port' , None , None , ), # 2
315
+ )
316
+
317
+ def __init__ (self ):
318
+ self .host = ""
319
+ self .port = 0
320
+
321
+ def is_valid (self ):
322
+ return self .port != 0
323
+
324
+ def from_string (self , host_port ):
325
+ host_and_port = host_port .split (':' )
326
+ if len (host_and_port ) != 2 :
327
+ return False
328
+ self .host = host_and_port [0 ]
329
+ self .port = int (host_and_port [1 ])
330
+ return True
331
+
332
+ def to_host_port (self ):
333
+ return self .host , self .port
334
+
335
+ def read (self , iprot ):
336
+ self .host = iprot .readString ()
337
+ self .port = iprot .readI16 ()
338
+
339
+ def write (self , oprot ):
340
+ oprot .writeString (self .host )
341
+ oprot .writeI16 (self .port )
342
+
343
+ def validate (self ):
344
+ return
345
+
346
+ def __hash__ (self ):
347
+ return hash (self .host ) ^ self .port
348
+
349
+ def __repr__ (self ):
350
+ L = ['%s=%r' % (key , value )
351
+ for key , value in self .__dict__ .items ()]
352
+ return '%s(%s)' % (self .__class__ .__name__ , ', ' .join (L ))
353
+
354
+ def __eq__ (self , other ):
355
+ return other .__class__ .__name__ == "host_port" and self .__dict__ == other .__dict__
356
+
357
+ def __ne__ (self , other ):
358
+ return not (self == other )
359
+
360
+
308
361
class gpid :
309
362
310
363
thrift_spec = (
0 commit comments