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

Activity Stub Injection in Workflow Implementation #65

Open
rmanibus opened this issue Aug 20, 2024 · 0 comments
Open

Activity Stub Injection in Workflow Implementation #65

rmanibus opened this issue Aug 20, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@rmanibus
Copy link
Contributor

rmanibus commented Aug 20, 2024

Temporal is discouraging the use if Dependency Injection for Workflow class, because

Dependency Injection into Workflow Instances is a direct way to cause changes that are incompatible with the persisted histories

However, I believe there is some room to allow injection of Activity stubs (and all other type of temporal stubs).

This way we could move all the options in build time configuration and simplify the workflow implementation from this:

    private final FileProcessingActivities activities;

    public FileProcessingWorkflowImpl() {
        this.activities = Workflow.newActivityStub(
                FileProcessingActivities.class,
                ActivityOptions.newBuilder()
                        .setStartToCloseTimeout(Duration.ofHours(1))
                        .build());
    }

to this:

    private final FileProcessingActivities activities;

   @Inject
    public FileProcessingWorkflowImpl(FileProcessingActivities activities) {
        this.activities = activities
    }

or even:

    @Inject
    private FileProcessingActivities activities;

I don't think that we can leverage arc for this. I think the best solution would be to scan the constructor parameters / annotated fields using jandex and create the workflow instance accordingly.

@melloware melloware added the enhancement New feature or request label Aug 24, 2024
@melloware melloware changed the title Stub Injection in Workflow Implementation Activity Stub Injection in Workflow Implementation Aug 30, 2024
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