Coder Social home page Coder Social logo

Comments (4)

nvasilevski avatar nvasilevski commented on August 20, 2024 1

Instead of using callbacks

Perhaps I'm missing a particular use-case but generally Active Support notifications are not a substitution for callbacks. A callback is something that is specific to a single maintenance task and will go away along with the task while notifications subscriptions will most likely stay in the application itself as it will be global for all tasks. Also the execution context is different, callbacks are executed within the task itself which means you can access data available in the task or choose how the task should proceed with the execution. While a notification is a fact of an event with no control on the even itself and the context is limited by the values passed along with the notification.

Having said that, I still think that it might be reasonable to have active support notifications added to maintenance tasks. However, since maintenance_tasks is using job-iteration (https://github.com/Shopify/job-iteration) under the hood - it already has all notifications issued by job-iteration, for example - https://github.com/Shopify/job-iteration/blob/c5c299af110bceff60091c5bfec8e2353b069198/lib/job-iteration/iteration.rb#L140

The naming like build_enumerator.iteration is not the friendliest in scope of the maintenance tasks gem as it requires some internal knowledge of job-iteration while maintenance tasks is trying to provide a higher-level API for job-iteration so maybe mirroring job-iteration notifications in maintenance tasks is reasonable assuming that this improves the UX and removes the need to be aware of job-iteration internals without necessity.

from maintenance_tasks.

elfassy avatar elfassy commented on August 20, 2024

A callback is something that is specific to a single maintenance task and will go away along with the task

That doesn't seem to be what's hinted at in the readme:
https://github.com/Shopify/maintenance_tasks/blob/main/README.md?plain=1#L378-L391

from maintenance_tasks.

nvasilevski avatar nvasilevski commented on August 20, 2024

That doesn't seem to be what's hinted at in the readme

This is just a way to mass-define a callback. It's fair that in this case the callback won't go away with the deletion of the task but execution wise it still stays specific to a given task. So a callback is something that is attached to a task when it comes to an execution and a notification subscriber is something that exists in an application and just listens for events. Ultimately in an application there could be two maintenance tasks frameworks that issue the same notifications on similar events while callbacks will have to be duplicated in both of them even if it's going to be a single meta-programming solution that evals code in parent classes. This is why I don't consider notifications to be a complete substitution to callbacks. We should have both

from maintenance_tasks.

github-actions avatar github-actions commented on August 20, 2024

This issue has been marked as stale because it has not been commented on in two months.
Please reply in order to keep the issue open. Otherwise, it will close in 14 days.
Thank you for contributing!

from maintenance_tasks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.