forked from Netflix/conductor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduced SystemTaskRegistry in place of the registry in WorkflowSys…
…temTask.
- Loading branch information
Aravindan Ramkumar
committed
Apr 12, 2021
1 parent
fe7b7d0
commit 609c422
Showing
28 changed files
with
480 additions
and
354 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
53 changes: 53 additions & 0 deletions
53
core/src/main/java/com/netflix/conductor/core/execution/tasks/SystemTaskRegistry.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,53 @@ | ||
/* | ||
* Copyright 2021 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.tasks; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.Collection; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
/** | ||
* A container class that holds a mapping of system task types {@link com.netflix.conductor.common.metadata.tasks.TaskType} to | ||
* {@link WorkflowSystemTask} instances. | ||
*/ | ||
@Component | ||
public class SystemTaskRegistry { | ||
|
||
private final Map<String, WorkflowSystemTask> registry; | ||
|
||
/** | ||
* Spring creates a map of bean names to {@link WorkflowSystemTask} instances and injects it. | ||
* <p> | ||
* NOTE: It is important the {@link WorkflowSystemTask} instances are "qualified" with their respective | ||
* {@link com.netflix.conductor.common.metadata.tasks.TaskType}. | ||
*/ | ||
public SystemTaskRegistry(Map<String, WorkflowSystemTask> registry) { | ||
this.registry = registry; | ||
} | ||
|
||
public WorkflowSystemTask get(String taskType) { | ||
return Optional.ofNullable(registry.get(taskType)) | ||
.orElseThrow(() -> new IllegalStateException(taskType + "not found in " + getClass().getSimpleName())); | ||
} | ||
|
||
public boolean isSystemTask(String taskType) { | ||
return registry.containsKey(taskType); | ||
} | ||
|
||
public Collection<WorkflowSystemTask> all() { | ||
return registry.values(); | ||
} | ||
} |
Oops, something went wrong.