-
Notifications
You must be signed in to change notification settings - Fork 83
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
feat/Job for live entity #285
Merged
BartArys
merged 67 commits into
kordlib:live-entity-life-cycle
from
Distractic:fix/shutdown_action_live_entity
May 20, 2021
Merged
Changes from 62 commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
4243405
test: Begin test for LiveMessage
Distractic 8e28ebe
test: Add tests for LiveMessage class
Distractic 1c8c405
chore: Remove useless imports
Distractic 6e42365
fix: shutdown action for live entity
Distractic 1fe0e5f
fix: Cancel live entity when kord is cancel
Distractic e73dc58
Merge pull request #1 from Distractic/fix/shutdown_action_live_entity
Distractic 4f2e896
Merge branch 'fix/live_entity_life_cycle' into test/live_entity
Distractic e41d2d6
fix: Resolve issue listening for onShutdown, chore: Refactor name shu…
Distractic 99dfd36
test: Add abstract class to tests live entity
Distractic 267575e
test: Add tests for abstract live entity and general behavior
Distractic 82292e8
chore: Add generic type live entity in abstract class test
Distractic bee2dd4
chore: Deprecate onCreate method never called by entity
Distractic 350d69d
test: Add tests for Member, Role and User live entity
Distractic c68974e
feat: Support BanAddEvent in live guild
Distractic 7fdc816
test: Change test classes to simulate event and manage it
Distractic 9ede98d
chore: Remove annotation need token bot
Distractic 305dad6
chore: Adapt Role & User live test with send manual event
Distractic 6b9f570
chore: Adapt Role & User live test with send manual event
Distractic ad5ccfe
test: Add check equality field of event, implements member live test
Distractic 7361019
chore: Remove optIn no used
Distractic 3d13743
fix: Correction tests to send fake event instead of real interaction
Distractic aaa94c0
test: Refactor test to build test with valid and random id
Distractic 0ddf083
fix: Fix flow issue with delay ..
Distractic cda911d
fix: Rename package to resolve gradle issue
Distractic 445b02a
test: Add Atomic counter to test event
Distractic cb66e45
test: End tests for guild live entity
Distractic 2a76eb4
chore: Place deprecated annotation on live entity
Distractic 71661d8
test: Live category test
Distractic f17bb71
chore: Use sequence random id from other tests
Distractic 38b84de
test: Tests for all live entities category
Distractic 144269d
test: Add Integrations update for guild live entity
Distractic eda09c0
fix: Add delay between creation job and send event
Distractic 2b99aa0
chore: Add deprecated annotation on GuildCreateEvent for live channel
Distractic 07e278b
fix: Use guild test channel type (according to GuildMessageChannel)
Distractic dc438c2
chore: format
Distractic 15356f1
chore: change package name and function name
Distractic ab33a22
chore: Use randomID, refactor send event
Distractic 04819cd
Merge pull request #2 from Distractic/test/live_entity
Distractic 4b80450
chore: Doc about shutdown action
Distractic 1757b45
chore: Change ReplaceWith in Deprecated annotation, rename shutdown m…
Distractic 05ccd86
fix: Remove shutdown action property
Distractic 2f42ea7
feat: Add cause of shut down live entity
Distractic fe70c9b
chore: Set deprecate level to Error
Distractic a20407f
test: Add test for LiveGuild with method onGuildCreate
Distractic 3142059
chore: Rename method about completion of job
Distractic 2ec9e38
feat: Add cancellation exception class for live entity
Distractic 69fa448
feat: Add cause of cancellation to retrieve event for each live entity
Distractic b088a88
chore: format
Distractic bc4a24c
tests: Remove delay and use queue to manage action
Distractic a48cc6a
tests: Add tests for LiveCancellationException constructor
Distractic 4d3f7be
chore: Refactor property of LiveCancellationException
Distractic 35b8bd1
fix: Null pointer in live entities tests
Distractic a730fbe
chore: try to add delay in tests
Distractic ea0b2f4
chore: Create constante for delay time in tests
Distractic 7adb7a7
chore: try old system for tests with CI
Distractic 060f588
Merge remote-tracking branch 'origin/fix/shutdown_action_live_entity'…
Distractic 445c4d3
fix: Remove non-existent code
Distractic f2c07ac
Retry github action
Distractic 973a4af
tests: Check data event caused shutDown
Distractic 0000500
Retry github action
Distractic 8a88c2d
Retry github action
Distractic 4392058
Retry github action
Distractic 2e6321d
chore: Change sentence in deprecated annotation
Distractic 6bfab84
chore: Remove replaceWith
Distractic 10ac5da
chore: Homogenize cancel message
Distractic 5557a64
chore: Fix imports and ReplaceWith for Deprecated annotation
Distractic 3841ae9
chore: Remove ReplaceWith for forgotten Deprecated annotation
Distractic 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
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.
This is a computed property, even if you launched the flow, consequent calls of the
events
property will create a new flow. Am I missing something? (I will edit this if I found out why)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.
I don't really understand the issue here
The property has been declared as 'final' so that it is not overloaded
The use here of "launchIn" allows to listen to the events about the death of the entity
When using the events property, it allows to use the events of kord while applying a filter and a behavior.
In the current case, this makes it possible to create a flow which is filtered according to the data of the entity (id or others, see filter method) while applying a behavior (update), which here will be specifically the "shutDown" method
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.
But a user will launch their own flow
Who is listening to the flow we launched in this code?
Final means it can't be overriden, but the field itself is still computed
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.
If an entity is to be able to observe its death (so it can cancel its scope), it has to listen to events. Under normal use this isn't a problem since a user will always listen to at least one event type, prompting the entity to process all events. This is here to cover the edge case where a user, for whatever reason, does not listen to any events but does want to observer the deletion of the entity.
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.
Yes the user will launch their own flow, BUT, when we use the method
on<Event>{...}
, we receive aJob
.The job can be cancelled, so the live entity no longer has children .. and in case where the live entity must be shut down (for LiveMessage, if the message is deleted for example), there is no more childrens to listen the death of the live entity.
So to resolve that, we listen the events from the beginning (without keep a reference to the job, because when the live entity is cancel, the job too), thus all jobs created and cancelled by the user, will always leave a alone job child to keep possibility to listen death events (GuildDelete, MessageDelete, etc.).
It's because we don't need to store the flow .. the method
on
will exploit the new flow computed and create a job.. So we need a new Flow each timesThere 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.
The parent (LiveEntity) needs at least one children (Job) to know his death and executes shut down (from update method)