-
Notifications
You must be signed in to change notification settings - Fork 1
Support for sync actions #56
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
5b9b7ef
Remove any loading before config is loaded
tomasfejfar 6da1642
Add test for run action
tomasfejfar a4cdd46
Sync actions support
tomasfejfar 3b3881d
Ensure run is not public to make sure BC break is noticable
tomasfejfar 39ee018
Remove stdout output from tests
tomasfejfar 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Keboola\Component\Exception; | ||
|
||
use Exception; | ||
|
||
class BaseComponentException extends Exception | ||
{ | ||
public static function invalidSyncAction(string $action): self | ||
{ | ||
return new self(sprintf( | ||
'Unknown sync action "%s", method does not exist in class', | ||
$action | ||
)); | ||
} | ||
|
||
public static function runCannotBeSyncAction(): self | ||
{ | ||
return new self('"run" cannot be a sync action'); | ||
} | ||
|
||
public static function runMethodCannotBePublic(): self | ||
{ | ||
return new self('Method "run" cannot be public since version 7'); | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Keboola\Component\Logger; | ||
|
||
interface AsyncActionLogging | ||
{ | ||
public function setupAsyncActionLogging(): void; | ||
} |
This file contains hidden or 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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Keboola\Component\Logger; | ||
|
||
interface SyncActionLogging | ||
{ | ||
/** | ||
* Sync actions MUST NOT output anything to stdout | ||
*/ | ||
public function setupSyncActionLogging(): void; | ||
} |
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.
to je zoufale nahovno bcbreak. run.php se testuje zpravidla jen integracnima testama a ty zase zpravidla netestujou sync akce. to znamena, ze kdyz updatnes komponentu a zapomenes ji zmenit run.php tak testy projdou, ale sync akce nebudou fungovat.
premyslim jak z toho vybruslit a nejjednodussi se mi zda, prejmenovat
run
narunAction
, coz se me sice nelibi, protoze se pak trosku zbytecne bude plest se sync akcema, ale udela to poradnej bc break, kterej zajisti, ze se pokazenejrun.php
nedostane do produkce.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.
taky bych do bc breaku pridal, ze testovaci konfigurace musi mit run, v testech to casto chybi, protoze to melo default hodnotu
Uh oh!
There was an error while loading. Please reload this page.
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.
Myšlenka byla, že když na tom teď závisíme (předtím jsme nikde v kódu run metodu nevyžadovali) tak bysme měli run vyžadovat.
Ale na druhou stranu si říkám, že by asi bylo lepší ten BC break udělat co nejmenší - aby to byl co nejmenší pain upgradovat.
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.
Což ale neudělá nic.
MyComponent::run()
furt existuje a furt se volá z indexu. A nemusí volat parent::run(), takže ani kdybych tam dal exceptionu, tak to nepomůže.Napadá mě v konstruktoru přes reflexi zkontrolovat, že run není public ale protected. Když bude protected, tak nejde zavolat z indexu a problem solved. A komponenty určitě parent constructor volají. Jinak by přišli o většinu cool věcí, co component umí :)
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.
Zkusím to vykopnout a pushnout.
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.
no tak z teho komentara su jelen :)
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.
z komentare jsem jelen, ale myslim, ze by to tak mohlo byt
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.
Ve zkratce:
index.php
mám$myComponent->run()
Component::run()
naComponent::runAction()
MyComponent::run
se nepřejmenuje, takže volání v 1. stále proběhne jako by nicOproti tomu, když něco přidám do konstruktoru, tak tam je slušná jistota, že se to zavolá i v poděděné komponentě.
To jsem tím chtěl říct.
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.
neprobehene, protoze neexistuje parent::run()
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.
Což předpokládá, že v metodě mycomponent::run se zavolá parent::run. Což myslím, že se moc neděje.