forked from Netflix/conductor
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FM-751 Split OffsetEvaluationStrategy and implementations
- goal: cleaner goals, separated configuration and implementation aspects - we can directly inject ConductorProperties into implementations of strategies that are represented by Spring components - introduction of TaskOffsetEvaluationSelector that allows other component to load implementation of specific strategy
- Loading branch information
Showing
11 changed files
with
172 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...c/main/java/com/netflix/conductor/core/execution/offset/TaskOffsetEvaluationSelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2024 Netflix, Inc. | ||
* <p> | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* <p> | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* <p> | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
package com.netflix.conductor.core.execution.offset; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.function.Function; | ||
import java.util.stream.Collectors; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.lang.NonNull; | ||
import org.springframework.stereotype.Component; | ||
|
||
import com.netflix.conductor.core.config.OffsetEvaluationStrategy; | ||
|
||
@Component | ||
public final class TaskOffsetEvaluationSelector { | ||
|
||
private final Map<OffsetEvaluationStrategy, TaskOffsetEvaluation> evaluations; | ||
|
||
@Autowired | ||
public TaskOffsetEvaluationSelector(final List<TaskOffsetEvaluation> evaluations) { | ||
this.evaluations = | ||
evaluations.stream() | ||
.collect(Collectors.toMap(TaskOffsetEvaluation::type, Function.identity())); | ||
} | ||
|
||
/** | ||
* Get the implementation of the offset evaluation for the given strategy. | ||
* | ||
* @param strategy the strategy to get the implementation for | ||
* @return {@link TaskOffsetEvaluation} | ||
* @throws IllegalStateException if no implementation is found for the given strategy | ||
*/ | ||
@NonNull | ||
public TaskOffsetEvaluation taskOffsetEvaluation(final OffsetEvaluationStrategy strategy) { | ||
final var taskOffsetEvaluation = evaluations.get(strategy); | ||
if (taskOffsetEvaluation == null) { | ||
throw new IllegalStateException( | ||
"No TaskOffsetEvaluation found for strategy: " + strategy); | ||
} | ||
return taskOffsetEvaluation; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.