зеркало из https://github.com/github/vitess-gh.git
61 строка
1.6 KiB
Python
61 строка
1.6 KiB
Python
|
#!/usr/bin/env python
|
||
|
|
||
|
import logging
|
||
|
import os
|
||
|
|
||
|
class ProtocolsFlavor(object):
|
||
|
"""Base class for protocols"""
|
||
|
|
||
|
def binlog_player_protocol_flags(self):
|
||
|
"""Returns the flags to pass to process to set the binlog player protocol."""
|
||
|
return []
|
||
|
|
||
|
def vtctl_client_protocol(self):
|
||
|
"""Returns the protocol to use for vtctl connections. Needs to be supported both in python and go."""
|
||
|
return ""
|
||
|
|
||
|
def tablet_manager_protocol_flags(self):
|
||
|
"""Returns the flags to use for specifying the tablet manager protocol."""
|
||
|
return ['-tablet_manager_protocol', 'bson']
|
||
|
|
||
|
def tabletconn_protocol_flags(self):
|
||
|
"""Returns the flags to use for specifying the query service protocol."""
|
||
|
return ['-tablet_protocol', 'gorpc']
|
||
|
|
||
|
class GoRpcProtocolsFlavor(object):
|
||
|
"""Overrides to use go rpc everywhere"""
|
||
|
|
||
|
def binlog_player_protocol_flags(self):
|
||
|
return ['-binlog_player_protocol', 'gorpc']
|
||
|
|
||
|
def vtctl_client_protocol(self):
|
||
|
return 'gorpc'
|
||
|
|
||
|
def tablet_manager_protocol_flags(self):
|
||
|
return ['-tablet_manager_protocol', 'bson']
|
||
|
|
||
|
def tabletconn_protocol_flags(self):
|
||
|
return ['-tablet_protocol', 'gorpc']
|
||
|
|
||
|
__knows_protocols_flavor_map = {
|
||
|
'gorpc': GoRpcProtocolsFlavor,
|
||
|
}
|
||
|
__protocols_flavor = None
|
||
|
|
||
|
def protocols_flavor():
|
||
|
return __protocols_flavor
|
||
|
|
||
|
def set_protocols_flavor(flavor):
|
||
|
global __protocols_flavor
|
||
|
|
||
|
if not flavor:
|
||
|
flavor = 'gorpc'
|
||
|
|
||
|
klass = __knows_protocols_flavor_map.get(flavor, None)
|
||
|
if not klass:
|
||
|
logging.error('Unknown protocols flavor %s', flavor)
|
||
|
exit(1)
|
||
|
__protocols_flavor = klass()
|
||
|
|
||
|
logging.debug('Using protocols flavor %s', flavor)
|