-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: move AbstractProvider to openfeature.provider (#314)
Signed-off-by: Federico Bond <federicobond@gmail.com>
- Loading branch information
1 parent
cd605c4
commit 96ba793
Showing
7 changed files
with
103 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,11 @@ | ||
import typing | ||
from abc import abstractmethod | ||
import warnings | ||
|
||
from openfeature.evaluation_context import EvaluationContext | ||
from openfeature.event import ProviderEvent, ProviderEventDetails | ||
from openfeature.flag_evaluation import FlagResolutionDetails | ||
from openfeature.hook import Hook | ||
from openfeature.provider import FeatureProvider | ||
from openfeature.provider.metadata import Metadata | ||
from openfeature.provider import AbstractProvider | ||
|
||
__all__ = ["AbstractProvider"] | ||
|
||
|
||
class AbstractProvider(FeatureProvider): | ||
def initialize(self, evaluation_context: EvaluationContext) -> None: | ||
pass | ||
|
||
def shutdown(self) -> None: | ||
pass | ||
|
||
@abstractmethod | ||
def get_metadata(self) -> Metadata: | ||
pass | ||
|
||
def get_provider_hooks(self) -> typing.List[Hook]: | ||
return [] | ||
|
||
@abstractmethod | ||
def resolve_boolean_details( | ||
self, | ||
flag_key: str, | ||
default_value: bool, | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[bool]: | ||
pass | ||
|
||
@abstractmethod | ||
def resolve_string_details( | ||
self, | ||
flag_key: str, | ||
default_value: str, | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[str]: | ||
pass | ||
|
||
@abstractmethod | ||
def resolve_integer_details( | ||
self, | ||
flag_key: str, | ||
default_value: int, | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[int]: | ||
pass | ||
|
||
@abstractmethod | ||
def resolve_float_details( | ||
self, | ||
flag_key: str, | ||
default_value: float, | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[float]: | ||
pass | ||
|
||
@abstractmethod | ||
def resolve_object_details( | ||
self, | ||
flag_key: str, | ||
default_value: typing.Union[dict, list], | ||
evaluation_context: typing.Optional[EvaluationContext] = None, | ||
) -> FlagResolutionDetails[typing.Union[dict, list]]: | ||
pass | ||
|
||
def emit_provider_ready(self, details: ProviderEventDetails) -> None: | ||
self.emit(ProviderEvent.PROVIDER_READY, details) | ||
|
||
def emit_provider_configuration_changed( | ||
self, details: ProviderEventDetails | ||
) -> None: | ||
self.emit(ProviderEvent.PROVIDER_CONFIGURATION_CHANGED, details) | ||
|
||
def emit_provider_error(self, details: ProviderEventDetails) -> None: | ||
self.emit(ProviderEvent.PROVIDER_ERROR, details) | ||
|
||
def emit_provider_stale(self, details: ProviderEventDetails) -> None: | ||
self.emit(ProviderEvent.PROVIDER_STALE, details) | ||
|
||
def emit(self, event: ProviderEvent, details: ProviderEventDetails) -> None: | ||
from openfeature.provider._registry import provider_registry | ||
|
||
provider_registry.dispatch_event(self, event, details) | ||
warnings.warn( | ||
"openfeature.provider.provider is deprecated, use openfeature.provider instead", | ||
DeprecationWarning, | ||
stacklevel=1, | ||
) |