Skip to content
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

Feature: Speed up compilation with finalize! #63

Open
apotonick opened this issue Nov 13, 2022 · 3 comments
Open

Feature: Speed up compilation with finalize! #63

apotonick opened this issue Nov 13, 2022 · 3 comments
Labels
enhancement New feature or request
Milestone

Comments

@apotonick
Copy link
Member

apotonick commented Nov 13, 2022

We could avoid having to compile the activity with every invocation of step by "marking" the activity as final in the end, which then could trigger compilation (and much better error handling).

class Create < Trailblazer::Operation(finalize: true)
  step :a
  step :b
end.finalize!

When using an extendable loader such as dry-system (or maybe even zeitwerk supports that?) you could add a "loaded" callback that calls activity_class.finalize! automatically.

@apotonick apotonick added the enhancement New feature or request label Nov 13, 2022
@apotonick
Copy link
Member Author

The other option I see would be

class Create < Trailblazer::Operation
  structure do
    step :a
    step :b
  end
end

I don't really like this, though.

@apotonick
Copy link
Member Author

We can save the finalize! if we use zeitwerk's on_load (thanks @solnic): https://github.com/fxn/zeitwerk#the-on_load-callback

@yogeshjain999
Copy link
Member

yogeshjain999 commented Nov 14, 2022

Great idea! step would become a lot faster with this!

Although, I think we should confirm if defining nested operations would still be supported with on_load

# create.rb
class Create < Trb::Op
  class Present < Trb::Op
  end

  step Subprocess(Present)
end

I suppose only on_load("Create") would be called here ? 🤔

@apotonick apotonick added this to the 1.3.0 milestone Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants