-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Have StateBuilder return our actual state object and not simply a dict (
- Loading branch information
Showing
5 changed files
with
79 additions
and
149 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
# Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
|
||
from typing import Any, Dict, List | ||
from typing import Any, List | ||
|
||
from airbyte_protocol.models import AirbyteStateMessage | ||
|
||
|
||
class StateBuilder: | ||
def __init__(self) -> None: | ||
self._state: List[Dict[str, Any]] = [] | ||
self._state: List[AirbyteStateMessage] = [] | ||
|
||
def with_stream_state(self, stream_name: str, state: Any) -> "StateBuilder": | ||
self._state.append({ | ||
self._state.append(AirbyteStateMessage.parse_obj({ | ||
"type": "STREAM", | ||
"stream": { | ||
"stream_state": state, | ||
"stream_descriptor": { | ||
"name": stream_name | ||
} | ||
} | ||
}) | ||
})) | ||
return self | ||
|
||
def build(self) -> List[Dict[str, Any]]: | ||
def build(self) -> List[AirbyteStateMessage]: | ||
return self._state |
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
Oops, something went wrong.