forked from spinnaker/orca
-
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.
refactor(api): Extract StageDefinitionBuilder and supporting classes (s…
…pinnaker#3490) * chore(core): Expose orca-api as api dependency * refactor(core): Rename Execution to PipelineExecution * refactor(plugins): Rename Stage to StageExecution * refactor(plugins): Rename Task to TaskExecution * refactor(plugins): Move SimpleStage extension point to new package * refactor(plugins): Extracting ExecutionType out of PipelineExecution * feat(plugins): Add StageExecution api * feat(plugins): Add TaskExecutino api * refactor(plugins): Move ExecutionStatus to orca-api * refactor(plugins): Move TaskResult to orca-api * refactor(plugins): Move SyntheticStageOwner to orca-api * refactor(plugins): Rename Pipeline, Stage, TaskExecution models to *Impl * refactor(plugins): Change signatures of TaskExecutionImpl to TaskExecution * refactor(plugins): Move Trigger to orca-api * refactor(plugins): Migrate codebase to use PipelineExecution and StageExecution interfaces * refactor(plugins): Move Task to orca-api * refactor(plugins): Move RetryableTask to orca-api * refactor(plugins): Move CancellableStage to orca-api * chore(plugins): Note about AuthenticatedStage refactor * refactor(plugins): Remove internals-only methods from StageDefinitionBuilder * refactor(plugins): Move StageDefinitionBuilder to orca-api * refactor(plugins): Move api interfaces and classes to new packages * docs(plugins): Adding dokka to orca-api * docs(plugins): Some api docs * feat(plugins): Make StageDefinitionBuilder an extension point * refactor(plugins): Fix failing tests from 1.5w rebase * fix(canary): Groovyism missing an import but compiling fine
- Loading branch information
1 parent
76ad4e1
commit ae2b804
Showing
997 changed files
with
8,626 additions
and
6,641 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#Wed Mar 04 00:10:14 PST 2020 | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME |
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,3 @@ | ||
# Module orca-api | ||
|
||
I need to say something about things here. |
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
27 changes: 27 additions & 0 deletions
27
orca-api/src/main/java/com/netflix/spinnaker/orca/api/annotations/Immutable.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,27 @@ | ||
/* | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.spinnaker.orca.api.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Signals that the annotated element is an immutable object. Write operations against this element | ||
* will fail. | ||
*/ | ||
@Target({ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER, ElementType.METHOD}) | ||
public @interface Immutable {} |
15 changes: 9 additions & 6 deletions
15
...flix/spinnaker/orca/CancellableStage.java → ...r/orca/api/pipeline/CancellableStage.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
11 changes: 8 additions & 3 deletions
11
...orca/OverridableTimeoutRetryableTask.java → ...line/OverridableTimeoutRetryableTask.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 |
---|---|---|
@@ -1,24 +1,29 @@ | ||
/* | ||
* Copyright 2017 Netflix, Inc. | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.spinnaker.orca; | ||
package com.netflix.spinnaker.orca.api.pipeline; | ||
|
||
import com.netflix.spinnaker.kork.annotations.Alpha; | ||
|
||
/** | ||
* A retryable task whose timeout is taken from the top level stage if that value has been | ||
* overridden. | ||
* | ||
* <p>These are typically wait/monitor stages | ||
* | ||
* <p>TODO(rz): What even is the point of this interface? | ||
*/ | ||
@Alpha | ||
public interface OverridableTimeoutRetryableTask extends RetryableTask {} |
16 changes: 10 additions & 6 deletions
16
...netflix/spinnaker/orca/RetryableTask.java → ...aker/orca/api/pipeline/RetryableTask.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 |
---|---|---|
@@ -1,41 +1,45 @@ | ||
/* | ||
* Copyright 2017 Netflix, Inc. | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.spinnaker.orca; | ||
package com.netflix.spinnaker.orca.api.pipeline; | ||
|
||
import com.netflix.spinnaker.orca.pipeline.model.Stage; | ||
import com.netflix.spinnaker.kork.annotations.Beta; | ||
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution; | ||
import java.time.Duration; | ||
|
||
/** | ||
* A retryable task defines its backoff period (the period between delays) and its timeout (the | ||
* total period of the task) | ||
*/ | ||
@Beta | ||
public interface RetryableTask extends Task { | ||
/** TODO(rz): Use Duration. */ | ||
long getBackoffPeriod(); | ||
|
||
/** TODO(rz): Use Duration. */ | ||
long getTimeout(); | ||
|
||
default long getDynamicTimeout(Stage stage) { | ||
default long getDynamicTimeout(StageExecution stage) { | ||
return getTimeout(); | ||
} | ||
|
||
default long getDynamicBackoffPeriod(Duration taskDuration) { | ||
return getBackoffPeriod(); | ||
} | ||
|
||
default long getDynamicBackoffPeriod(Stage stage, Duration taskDuration) { | ||
default long getDynamicBackoffPeriod(StageExecution stage, Duration taskDuration) { | ||
return getDynamicBackoffPeriod(taskDuration); | ||
} | ||
} |
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
80 changes: 80 additions & 0 deletions
80
orca-api/src/main/java/com/netflix/spinnaker/orca/api/pipeline/Task.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,80 @@ | ||
/* | ||
* Copyright 2020 Netflix, Inc. | ||
* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.spinnaker.orca.api.pipeline; | ||
|
||
import com.netflix.spinnaker.kork.annotations.Beta; | ||
import com.netflix.spinnaker.orca.api.pipeline.models.StageExecution; | ||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
import java.util.Arrays; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
import javax.annotation.Nonnull; | ||
import javax.annotation.Nullable; | ||
|
||
/** A discrete unit of work in a pipeline execution that does one thing and one thing only. */ | ||
@Beta | ||
public interface Task { | ||
/** | ||
* Execute the business logic of the task, using the provided stage execution state. | ||
* | ||
* @param stage The running stage execution stage | ||
* @return The result of this Task's execution | ||
*/ | ||
@Nonnull | ||
TaskResult execute(@Nonnull StageExecution stage); | ||
|
||
/** | ||
* Behavior to be called on Task timeout. | ||
* | ||
* <p>This method should be used if you need to perform any cleanup operations in response to the | ||
* task being aborted after taking too long to complete. | ||
* | ||
* @param stage The running state execution state | ||
* @return | ||
*/ | ||
default @Nullable TaskResult onTimeout(@Nonnull StageExecution stage) { | ||
return null; | ||
} | ||
|
||
/** | ||
* Behavior to be called on Task cancellation. | ||
* | ||
* <p>This method should be used if you need to perform cleanup in response to the task being | ||
* cancelled before it was able to complete. | ||
* | ||
* @param stage The running state execution state | ||
*/ | ||
default void onCancel(@Nonnull StageExecution stage) {} | ||
|
||
/** A collection of known aliases. */ | ||
default Collection<String> aliases() { | ||
if (getClass().isAnnotationPresent(Aliases.class)) { | ||
return Arrays.asList(getClass().getAnnotation(Aliases.class).value()); | ||
} | ||
|
||
return Collections.emptyList(); | ||
} | ||
|
||
/** Allows backwards compatibility of a task's "type", even through class renames / refactors. */ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
@interface Aliases { | ||
String[] value() default {}; | ||
} | ||
} |
Oops, something went wrong.