-
Notifications
You must be signed in to change notification settings - Fork 25
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
adding additional steps in wrap #61
Comments
Hey @Quantenradierer!! The reason So How about you use inheritance here to achieve similar thing ? # in engine
class BaseOperation < Trailblazer::Operation
step :load_something
step :save_something
end
# in your project
class TestOperation < BaseOperation
step :change_something, after: :load_something
end
# in your operation
step Wrap(Transaction) {
step Subprocess(TestOperation)
} |
Thank you for the response. I have thought about this as well and in the few cases for transactions or exceptions this is okay. But for metrics which shall document if a operation failed/succeeded/raised an error it would add one additional class since we need to wrap all operations. This is our current implementation for metrics, which overwrites the call from operations:
Is there a reason why like:
I am not familiar enough with the code to implement this yet but maybe in a year or so there will be a PR, if you think this belongs into trailblazer :) Can be closed once you answer. |
Good point about the "chained" ids!! But I think patching is more explicit and configurable. What if you want to add a step in nested operation which is 2 level deeper using Current implementation of If you want to avoid defining extra classes for class BaseOperation < Trailblazer::Operation
step :load_something
step :save_something
end
class TestOperation < Trailblazer::Operation
# Defining this as class method in order to access it in BaseOperation scope
def self.change_something(ctx, **)
end
step Wrap(Transaction) {
step Subprocess(BaseOperation, patch: -> { step TestOperation.method(:change_something), after: :load_something })
}
end |
Doesn't patching work here? https://trailblazer.to/2.1/docs/activity.html#activity-dsl-options-patching This implements "chained IDs" the way @Quantenradierer need it. |
@yogeshjain999 I don't think this is suitable for us. One of our requirements is that the engine must define a whole usable process. I have tried the patching @apotonick but it does not work for wraps. The class is being copied and modified (via I also tried to modify the wrap activity without copying it and it worked. This was just for testing purposes, don't use this code:
I also looked into before/after parameters. Allowing |
So, do we agree we have a patching bug here, then? Regarding the |
@Quantenradierer How would you use the insertion logic with an array? You mean you want to insert a bunch of sequential steps at a certain point at once? |
Maybe you're misunderstanding patching? It is possible and designed to insert/alter as many steps as you need into nested operations, isn't that what you need? 😂 |
I would expect that
results in this:
|
Let's take the example:
This won't do it, cause I need to define the wrap in the BaseOperation. And then I can't modify the inside of it in the TestOperation |
Thanks - that clarifies it! You'd use patch as follows to add/alter the nested OP (pseudo code!!!). class TestOperation < Trailblazer::Operation
step Wrap(Transaction), patch: [:base_operation] -> { step added_step, after ... }] We need to test this, though. Anyway, the idea is to be able to change internals from |
Yo @Quantenradierer, moin! I am envisioning a more intuitive syntax for patching, how about this? class TestOperation < Trailblazer::Operation
patch: ["wrap/Transaction", :base_operation] -> { step added_step, after ... }] Something like that, so you don't have to repeat |
Hey,
We have a rails engine which defines business processes. A few other projects use this engine and make minor changes to the business processes, depending on the specific application.
Now the engine defines a wrap around a few steps, while a project wants to add a step in this wrap:
This of course won't work when
:load_something
is wrapped.I already looked into various documentation about
after
,before
and even subprocess patching but I can't find anything how to add/replace/delete steps in a Wrap?Thank you
The text was updated successfully, but these errors were encountered: