1
0
mirror of synced 2026-01-14 12:07:57 -05:00
Files
airbyte/airbyte-cdk/python/airbyte_cdk/sources/streams/availability_strategy.py
Ella Rohm-Ensing 221c9b1839 Reintroduce AvailabilityStrategy into the CDK (HttpAvailabilityStrategy default not turned on yet) (#21484)
* Restore AvailabilityStrategy 

* Add test for http availability strategy on empty stream from original bug fix 7c17351631

* fix flake errors

* Change CheckStream to use availability strategy

* Refactor test from bug fix

* fix flake errors

* Remove extra helper file from cherry-pick

* Merge tests for default http availability strategy

* turn off HttpAvailabilityStrategy as default (for now) (#21488)

* turn off HttpAvailabilityStrategy as default (for now)

* Update imports accordingly
2023-01-18 13:32:48 -05:00

34 lines
1007 B
Python

#
# Copyright (c) 2022 Airbyte, Inc., all rights reserved.
#
import logging
import typing
from abc import ABC, abstractmethod
from typing import Optional, Tuple
from airbyte_cdk.sources.streams import Stream
if typing.TYPE_CHECKING:
from airbyte_cdk.sources import Source
class AvailabilityStrategy(ABC):
"""
Abstract base class for checking stream availability.
"""
@abstractmethod
def check_availability(self, stream: Stream, logger: logging.Logger, source: Optional["Source"]) -> Tuple[bool, Optional[str]]:
"""
Checks stream availability.
:param stream: stream
:param logger: source logger
:param source: (optional) source
:return: A tuple of (boolean, str). If boolean is true, then the stream
is available, and no str is required. Otherwise, the stream is unavailable
for some reason and the str should describe what went wrong and how to
resolve the unavailability, if possible.
"""