2727from rust_decider import Decision
2828from rust_decider import FeatureNotFoundException
2929from rust_decider import make_ctx
30+ from rust_decider import ValueTypeMismatchException
3031from typing_extensions import Literal
3132
3233
@@ -712,7 +713,7 @@ def get_bool(self, feature_name: str, default: bool = False) -> bool:
712713
713714 :return: the boolean value of the dyanimc config if it is active/exists, :code:`default` parameter otherwise.
714715 """
715- return self ._get_dynamic_config_value (feature_name , default , [ bool ] )
716+ return self ._get_dynamic_config_value (feature_name , default , bool )
716717
717718 def get_int (self , feature_name : str , default : int = 0 ) -> int :
718719 """Fetch a Dynamic Configuration of int type.
@@ -724,7 +725,7 @@ def get_int(self, feature_name: str, default: int = 0) -> int:
724725
725726 :return: the int value of the dyanimc config if it is active/exists, :code:`default` parameter otherwise.
726727 """
727- return self ._get_dynamic_config_value (feature_name , default , [ int ] )
728+ return self ._get_dynamic_config_value (feature_name , default , int )
728729
729730 def get_float (self , feature_name : str , default : float = 0.0 ) -> float :
730731 """Fetch a Dynamic Configuration of float type.
@@ -736,7 +737,7 @@ def get_float(self, feature_name: str, default: float = 0.0) -> float:
736737
737738 :return: the float value of the dyanimc config if it is active/exists, :code:`default` parameter otherwise.
738739 """
739- return self ._get_dynamic_config_value (feature_name , default , [ float , int ] )
740+ return self ._get_dynamic_config_value (feature_name , default , float )
740741
741742 def get_string (self , feature_name : str , default : str = "" ) -> str :
742743 """Fetch a Dynamic Configuration of string type.
@@ -748,7 +749,7 @@ def get_string(self, feature_name: str, default: str = "") -> str:
748749
749750 :return: the string value of the dyanimc config if it is active/exists, :code:`default` parameter otherwise.
750751 """
751- return self ._get_dynamic_config_value (feature_name , default , [ str ] )
752+ return self ._get_dynamic_config_value (feature_name , default , str )
752753
753754 def get_map (self , feature_name : str , default : Optional [dict ] = None ) -> Optional [dict ]:
754755 """Fetch a Dynamic Configuration of map type.
@@ -760,7 +761,7 @@ def get_map(self, feature_name: str, default: Optional[dict] = None) -> Optional
760761
761762 :return: the map value of the dyanimc config if it is active/exists, :code:`default` parameter otherwise.
762763 """
763- return self ._get_dynamic_config_value (feature_name , default , [ dict ] )
764+ return self ._get_dynamic_config_value (feature_name , default , dict )
764765
765766 def get_all_dynamic_configs (self ) -> List [Dict [str , Any ]]:
766767 """Return a list of dynamic configuration dicts in this format:
@@ -818,7 +819,7 @@ def _get_dynamic_config_value(
818819 self ,
819820 feature_name : str ,
820821 default : Any ,
821- dc_types : List [ type ] ,
822+ dc_type : Any ,
822823 ) -> Any :
823824 if self ._internal is None :
824825 logger .error ("rs_decider is None--did not initialize." )
@@ -827,21 +828,22 @@ def _get_dynamic_config_value(
827828 ctx = self ._decider_context .to_dict ()
828829
829830 try :
830- decision = self ._internal .choose (feature_name = feature_name , context = ctx )
831+ value = eval ( f" self._internal.get_ { dc_type . __name__ } " ) (feature_name = feature_name , context = ctx )
831832 except FeatureNotFoundException as exc :
832833 warnings .warn (str (exc ))
833834 return default
835+ except ValueTypeMismatchException as exc :
836+ logger .info (str (exc ))
837+ return default
834838 except DeciderException as exc :
835839 logger .info (str (exc ))
836840 return default
837841
838- value = decision . value
839-
840- if type ( value ) not in dc_types :
842+ try :
843+ return dc_type ( value )
844+ except TypeError :
841845 return default
842846
843- return value
844-
845847 def _value_to_dc_dict (self , feature_name : str , value : Optional [Any ]) -> Dict [str , Any ]:
846848 return {
847849 "name" : feature_name ,
0 commit comments