-
Notifications
You must be signed in to change notification settings - Fork 89
Description
Feature scope
Taps (catalog, state, stream maps, etc.)
Description
The current pattern we enforce through our documentation and cookiecutter for adding new streams to an HTTP tap is implement a custom MyTap.discover_streams that returns a list of the desired stream instances.
This pattern may provide some consistency but it could be mildly annoying for a developer to remember they have to:
-
import the new stream class,
-
add the class to a module-level collection,
-
implement (once) the
discover_streamsmethod:from tap_example.streams import NewStream STREAM_CLASSES = [NewStream] class TapExample(Tap): def discover_streams(self): return [stream_class(self) for stream_class in STREAM_CLASSES]
A better approach might get inspiration from other OOP frameworks, like Django. There, database models/tables are defined as classes and whenever some abstraction is required for a set of models, it's also a model class, but explicitly declared as abstract, so it doesn't map to a table in the database.
So, a similar thing in the SDK might look like this:
class MyAPIStream(RESTStream, abstract=True):
...
class UsersStream(MyAPIStream):
name = "users"Under the hood
MyAPIStreamwould not be registered, as it's declared to be abstract,UsersStreamwould be registered,- The default implementation of
discover_streamswould readUsersStreamfrom the underlying class registry and instantiate them appropriately.