Comments (8)
What benefits do you have in mind when using this approach?
On May 17, 2015 7:20 PM, "Grégory Horion" [email protected] wrote:
Hey,
This looks pretty cool. One improvement would be to include modules to
decorate the classes instead of using inheritance.
Here is what i have in mind:workflows/sample_workflow.rbclass SampleWorkflow
include Gush::Workflow
gush do
run FetchJob1
run FetchJob2, params: {some_flag: true, url: 'http://url.com'}run PersistJob1, after: FetchJob1 run PersistJob2, after: FetchJob2 run Normalize, after: [PersistJob1, PersistJob2], before: Index run Index
endend
class FetchJob1
include Gush::Job
def self.perform(params={})
# do some fetching from remote APIsparams #=> {url: "http://some.com/url"}
endend
what do you think?
—
Reply to this email directly or view it on GitHub
#6.
from gush.
Using inheritance is a constraint that force me the have classes that are Gush::Workflow or Gush::Job and nothing else, where in practice, it's not always the case.
In the following example, i have my SignupWorkflow
that already inherit from a class. Of course, i do not want to make ClassA to inherit from Gush::Workflow cause it is not. In this simple case, how could i make SignupWorkflow a Gush::Workflow?
class ClassA
# some stuffs
end
class SignupWorkflow < ClassA; end
Same idea for the job, how should i use Gush here and make User::EmailResetPassword
a Gush::Job
? :)
class User::EmailResetPassword < SomeClass; end
Adding a specific DSL by including Gush::Workflow might not only allow me to use it with classes that already inherit from another one, but also prevent class method name conflicts.
from gush.
Inheriting workflows makes zero sense, because jobs are defined on the instance level. But will change to include
s.
from gush.
Also the block gush do
doesn't really add anything beside pointless complexity.
from gush.
@gregory the only purpose for *Workflow
classes is to provide a DSL for workflows and they're never meant to be instantiated by the users. Look at the DSL that rack uses for configuration. Did you ever need to customize the way how rack apps are configured?
Using custom subclasses for Job
s makes more sense, but I can't see why would it be better than something like this:
class ResetEmailJob < Gush::Job
def work
User::EmailResetPassword.new.whatever(params)
end
end
from gush.
@pokonski for the gush do
i actually meant to avoid using #configure
to avoid method name conflict with a class that would have that method already defined...
This doesnt makes sens to you?
class ClassA
def common_params
end
end
class Workflow1 < ClassA
def self.configure
run FetchJob1, params: common_params
end
end
class Workflow2 < ClassA
def self.configure
run FetchJob2, params: common_params
end
end
@mlen If this is a DSL, why should that be nested in a configure method? The DSL should be enough right?
class ResetEmailJob < Gush::Job
def work
User::EmailResetPassword.new.whatever(params)
end
end
=> Now you are forcing me into your architecture style.
That would mean that in order to have a job, i'd have to create new classes in my codebase just to wrap the call? ...
To be honnest, i'm not even sure why we need to include/inherit from Gush::Job we should just call .perform just like Resque does, and maybe open to customization like this: run FetchJob2, params: {some_flag: true, url: 'http://url.com'}, perform_method: :foobar
what do you guys think about that?
from gush.
In version 1.0 the jobs will no longer need to be inherited from Gush::Job, so stay tuned!
from gush.
Closing due to inactivity and general change of direction since my comment
from gush.
Related Issues (20)
- Allow redis 5 HOT 1
- Update Redis gem HOT 1
- Make gush handle wokflows with 1000s of jobs HOT 13
- Many mutex fails after #49000a30fd34ac21cabdc7d HOT 9
- Activejob callbacks not available in the Gush::Job
- Long-running jobs and human job completion HOT 11
- Jobs that eventually succeed will not queue downstream jobs HOT 6
- Gush.configure with namespace issue HOT 3
- Can we run same workflow parallelly with different arguments? HOT 1
- bundle exec viz workflow with parameters HOT 6
- Shortcircuit workflows HOT 15
- Cannot assign requested address - connect(2) for [::1]:6379 HOT 12
- Overlapping workflows HOT 1
- Update Gem on RubyGems HOT 3
- Project status HOT 8
- Can I create a dynamic workflow based on job's output? HOT 1
- Project Idea - Web UI HOT 1
- cannot create workflow instance HOT 2
- Dead Link to "Parallelizing Operations With Dependencies" by Stephen Toub
- Polling scenario in job HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gush.