Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Add spring support for annotated workers #3492

Merged
merged 1 commit into from
Mar 13, 2023

Conversation

v1r3n
Copy link
Contributor

@v1r3n v1r3n commented Feb 15, 2023

Pull Request type

  • Bugfix
  • Feature
  • Refactoring (no functional changes, no api changes)
  • Build related changes (Please run ./gradlew generateLock saveLock to refresh dependencies)
  • WHOSUSING.md
  • Other (please describe):

NOTE: Please remember to run ./gradlew spotlessApply to fix any format violations.

Changes in this PR

  1. Make it possible to add @Component to the classes that has worker methods and they will get auto-initialized.
  2. Allow more control in the annotated workers so users can use callbackAfter for long running tasks
  3. New exception that allows user to indicate the task has failed and should not be retried
  4. Ability to control polling interval - useful for long running tasks
  5. TaskContext allows getting access to the task and task result for inspecting task level information

Describe the new behavior from this PR, and why it's needed
Issue #

Alternatives considered

Describe alternative implementation you have considered

@@ -0,0 +1,48 @@
/*
* Copyright 2020 Netflix, Inc.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2020 or 2023?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Thanks for pointing out.

@ConditionalOnMissingBean
@Bean
public AnnotatedWorkerExecutor annotatedWorkerExecutor(ClientProperties clientProperties) {

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to make sure that this bean is created later than other beans to avoid omissions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed this by doing the initialization using context initialization event.

1. Add annotation support for pollingInterval
2. Allow configuration using spring
3. Tests
@v1r3n v1r3n force-pushed the sdk_worker_enhancements branch from bd26688 to 5bdb4ac Compare February 20, 2023 05:26
@v1r3n v1r3n merged commit cc7495c into Netflix:main Mar 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants