-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Core] Create webhooks only resync #1225
Open
matan84
wants to merge
18
commits into
main
Choose a base branch
from
PORT-11272-create-webhooks-only-resync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+84
−7
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d5cec88
alla huakbar
matan84 96bf312
Merge branch 'main' into create-run-modes
matan84 9859914
Merge branch 'main' into create-run-modes
matan84 c9dc8e9
Added webhooks only event listener
matan84 9163d7e
Chaned ocean version
matan84 e229bca
Updated changelog
matan84 d8eae9f
fixed lints
matan84 479a7d3
Merge branch 'main' into PORT-11272-create-webhooks-only-resync
matan84 c5dec85
Fixed start
matan84 4030247
Changed implementation to not use literal webhooks_only
matan84 0e47d90
Merge branch 'main' into PORT-11272-create-webhooks-only-resync
matan84 48e6f04
added types
matan84 ab46b4e
Removed should_create_resources_on_start
matan84 1738c0b
Merge branch 'main' into PORT-11272-create-webhooks-only-resync
matan84 c2304c2
Fixed pr comments
matan84 8f87ee0
Merge branch 'main' into PORT-11272-create-webhooks-only-resync
matan84 058ca11
Updated log message
matan84 489f27c
Removed useless override
matan84 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,10 @@ | |
BaseEventListener, | ||
EventListenerEvents, | ||
) | ||
from port_ocean.core.event_listener.webhooks_only import ( | ||
WebhooksOnlyEventListener, | ||
WebhooksOnlyEventListenerSettings, | ||
) | ||
from port_ocean.exceptions.core import UnsupportedEventListenerTypeException | ||
|
||
|
||
|
@@ -88,7 +92,11 @@ async def create_event_listener(self) -> BaseEventListener: | |
config, OnceEventListenerSettings | ||
), assert_message.format(type(config)) | ||
event_listener = OnceEventListener(wrapped_events, config) | ||
|
||
case "webhooks_only": | ||
Tankilevitch marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we manage those consts from one place? |
||
assert isinstance( | ||
config, WebhooksOnlyEventListenerSettings | ||
), assert_message.format(type(config)) | ||
event_listener = WebhooksOnlyEventListener(wrapped_events, config) | ||
case _: | ||
raise UnsupportedEventListenerTypeException( | ||
f"Event listener {_type} not supported" | ||
|
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from typing import Literal | ||
|
||
from loguru import logger | ||
|
||
from port_ocean.core.event_listener.base import ( | ||
BaseEventListener, | ||
EventListenerEvents, | ||
EventListenerSettings, | ||
) | ||
|
||
|
||
class WebhooksOnlyEventListenerSettings(EventListenerSettings): | ||
""" | ||
This class inherits from `EventListenerSettings`, which provides a foundation for creating event listener settings. | ||
""" | ||
|
||
type: Literal["WEBHOOKS_ONLY"] | ||
should_resync: bool = False | ||
|
||
|
||
class WebhooksOnlyEventListener(BaseEventListener): | ||
""" | ||
No resync event listener. | ||
|
||
It is used to handle events exclusively through webhooks without supporting resync events. | ||
|
||
Parameters: | ||
events (EventListenerEvents): A dictionary containing event types and their corresponding event handlers. | ||
event_listener_config (OnceEventListenerSettings): The event listener configuration settings. | ||
""" | ||
|
||
def __init__( | ||
self, | ||
events: EventListenerEvents, | ||
event_listener_config: WebhooksOnlyEventListenerSettings, | ||
): | ||
super().__init__(events) | ||
self.event_listener_config = event_listener_config | ||
|
||
async def _start(self) -> None: | ||
logger.info("Starting Webhooks-only event listener") |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this?