Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRefactor callback concept #107
Comments
Suggestion as discussed (exception would be a subtype of
rest looks good :) |
|
Hi @heshamMassoud
Does this apply only to the error callback or to warning one as well?
What
By resource draft I understand one list item passed to this methods:
|
|
Hi, @jarzynp, of course! that would be great :)
I think It would be useful if we return
Sorry, the issue was described in a rush. Let me try to rephrase a bit: The
It could be that the user would want to selectively choose if he/she wants to continue the sync process or actually continue after such error occurs.
Yes, by that we mean with one resource draft error. For example one
Good point. In that sense, b sounds more user-friendly. But all the update action utils have the ordering of *a
No, it doesn't exist yet. It is a proposal to have a kind of a parent |
I am not sure if return value is necessary as the caller can throw own exception to break sync execution - if needed. If callback is defined in the same class where the sync instance is created then one could also catch own error an eventually also access/log sync statistics from existing sync instance.
indeed :) |
|
Ok, so what's the final decision for return value?
|
|
Hi @jarzynp, here is polished version of my previous comment :)
For now we do not have clear business use-case so let's just take option 4 and apply other suggested changes: As discussed, an exception would be a subtype of errorCallback:
warningCallback
@heshamMassoud You agree? |
|
Hi, PR ready for review: #367 Happy New Year! :) |
- QuadConsumer - Optional<List -> List - order in error/warning properties - reverted formatting changes for ProductVariantPriceUpdateActionUtil - renaming CallBack -> Callback in InventorySyncOptions - rename CallBack -> Callback in BaseSyncOptions
|
Besides checking existing PR comments and addressing conflicts, make sure that we use a context object which is propagated everywhere needed down the update actions utils, so that we can get the old and new resources deep down the method chain without the need of applying workarounds (e.g. the generic types of the util class). The idea is to propagate to the callback the whole resource (new or old) and not just failed sub resource (e.g. assets, prices, etc..) |
* #107: refactor callback concept * #107: further review fixes * #107: review fixes: - QuadConsumer - Optional<List -> List - order in error/warning properties - reverted formatting changes for ProductVariantPriceUpdateActionUtil - renaming CallBack -> Callback in InventorySyncOptions - rename CallBack -> Callback in BaseSyncOptions * Fix unit tests. * Fix integration tests. * #522:Add products to call back * 107:Publish changes to codebase. * 107:Fix checkstyle issues. * 107:Add proper parameter to test. * 107:Remove unused null check. * Add additional test. * Add final. * Add new test. * 107:Add new test. * Add new test. * fix checkstyle issue. * 107:Fix findbug issue. * Adjust javadoc. * Fix findbug issue. * Fix failing test. * Remove unneeded type definition. * Update src/main/java/com/commercetools/sync/categories/helpers/CategoryAssetActionFactory.java Co-authored-by: Lam Tran <lam.tran@commercetools.de> * Remove whitespace. * Update src/main/java/com/commercetools/sync/categories/utils/CategoryAssetUpdateActionUtils.java Co-authored-by: Lam Tran <lam.tran@commercetools.de> * Update src/main/java/com/commercetools/sync/categories/utils/CategoryAssetUpdateActionUtils.java Co-authored-by: Lam Tran <lam.tran@commercetools.de> * Change interface method. * Update src/main/java/com/commercetools/sync/commons/utils/AssetsUpdateActionUtils.java Co-authored-by: Lam Tran <lam.tran@commercetools.de> * Fix typo * Add spaces. * Overload method. * Update src/main/java/com/commercetools/sync/producttypes/ProductTypeSync.java Co-authored-by: Lam Tran <lam.tran@commercetools.de> * Update src/main/java/com/commercetools/sync/producttypes/ProductTypeSync.java Co-authored-by: Lam Tran <lam.tran@commercetools.de> * Fix failing test number. * Use variable. * Rename variable. * Adjust javadoc. * Refactor handle error method. * Update src/test/java/com/commercetools/sync/inventories/InventorySyncTest.java Co-authored-by: Lam Tran <lam.tran@commercetools.de> * Rename method. * pass null instead optional. * Update src/test/java/com/commercetools/sync/producttypes/ProductTypeSyncTest.java Co-authored-by: Lam Tran <lam.tran@commercetools.de> * Rename test * Add propert comment. * Modifiy interface. * Remove whitespace. * Change typedef of AssetActionFactory. * Generalize interface. * Fix example. * Update javadoc * rewrite javadoc. * Fix checkstyle issues. * Improve documentation. * Change formatting. * Add Release notes. * Update Versions. * Adjust template. Co-authored-by: piotr <p.jarzynski@ambsoft.pl> Co-authored-by: aoz <bilmuhahmet@gmail.com> Co-authored-by: andreas Halberkamp <andreas.halberkamp@commercetools.de>
Callback should support returning boolean. This is to support the use case of continuing or not when one update action building fails. Should the entire product/category still be synced with the rest of the successful update actions or not.
Right now, if one update action fails, the callback would be applied but the rest of the update actions for the product would still be applied.
(Enum ErrorType, String errorMessage, T oldResource, S newDraft)(String errorMessage, T oldResource, S newDraft, Throwable exception)Update
Referencing TODOs from #336 (comment):
errorCallbackandwarningCallbackshould be clearly defined and documented.nullable. It should always have an exception object. (Think about removing theerrorMessageString)