66
77from splitio .models .telemetry import MethodExceptionsAndLatencies
88
9+ _MAP_METHOD_TO_ENUM = {'treatment' : MethodExceptionsAndLatencies .TREATMENT ,
10+ 'treatments' : MethodExceptionsAndLatencies .TREATMENTS ,
11+ 'treatment_with_config' : MethodExceptionsAndLatencies .TREATMENT_WITH_CONFIG ,
12+ 'treatments_with_config' : MethodExceptionsAndLatencies .TREATMENTS_WITH_CONFIG ,
13+ 'track' : MethodExceptionsAndLatencies .TRACK
14+ }
15+
916SdkMetadata = namedtuple (
1017 'SdkMetadata' ,
1118 ['sdk_version' , 'instance_name' , 'instance_ip' ]
1219)
1320
1421def _get_hostname_and_ip (config ):
22+ """
23+ Get current hostname and IP address if config parameters are not set.
24+
25+ :param config: User supplied config augmented with defaults.
26+ :type config: dict
27+
28+ :return: IP address and Hostname
29+ :rtype: Tuple (str, str)
30+ """
1531 if config .get ('IPAddressesEnabled' ) is False :
1632 return 'NA' , 'NA'
1733 ip_from_config = config .get ('machineIp' )
@@ -35,13 +51,10 @@ def get_metadata(config):
3551 return SdkMetadata (version , hostname , ip_address )
3652
3753def get_method_constant (method ):
38- if method == 'treatment' :
39- return MethodExceptionsAndLatencies .TREATMENT
40- elif method == 'treatments' :
41- return MethodExceptionsAndLatencies .TREATMENTS
42- elif method == 'treatment_with_config' :
43- return MethodExceptionsAndLatencies .TREATMENT_WITH_CONFIG
44- elif method == 'treatments_with_config' :
45- return MethodExceptionsAndLatencies .TREATMENTS_WITH_CONFIG
46- elif method == 'track' :
47- return MethodExceptionsAndLatencies .TRACK
54+ """
55+ Get method name mapped to the Method Enum object
56+
57+ :return: method name
58+ :rtype: str
59+ """
60+ return _MAP_METHOD_TO_ENUM [method ]
0 commit comments