-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
18 changed files
with
368 additions
and
14 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
92 changes: 92 additions & 0 deletions
92
.../main/java/io/temporal/internal/statemachines/WorkflowPropertiesModifiedStateMachine.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,92 @@ | ||
/* | ||
* Copyright (C) 2022 Temporal Technologies, Inc. All Rights Reserved. | ||
* | ||
* Copyright (C) 2012-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Modifications copyright (C) 2017 Uber Technologies, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this material 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 io.temporal.internal.statemachines; | ||
|
||
import io.temporal.api.command.v1.Command; | ||
import io.temporal.api.command.v1.ModifyWorkflowPropertiesCommandAttributes; | ||
import io.temporal.api.enums.v1.CommandType; | ||
import io.temporal.api.enums.v1.EventType; | ||
import io.temporal.workflow.Functions; | ||
|
||
final class WorkflowPropertiesModifiedStateMachine | ||
extends EntityStateMachineInitialCommand< | ||
WorkflowPropertiesModifiedStateMachine.State, | ||
WorkflowPropertiesModifiedStateMachine.ExplicitEvent, | ||
WorkflowPropertiesModifiedStateMachine> { | ||
|
||
private ModifyWorkflowPropertiesCommandAttributes modifiedPropertiesAttributes; | ||
|
||
public static void newInstance( | ||
ModifyWorkflowPropertiesCommandAttributes modifiedPropertiesAttributes, | ||
Functions.Proc1<CancellableCommand> commandSink, | ||
Functions.Proc1<StateMachine> stateMachineSink) { | ||
new WorkflowPropertiesModifiedStateMachine( | ||
modifiedPropertiesAttributes, commandSink, stateMachineSink); | ||
} | ||
|
||
private WorkflowPropertiesModifiedStateMachine( | ||
ModifyWorkflowPropertiesCommandAttributes modifiedPropertiesAttributes, | ||
Functions.Proc1<CancellableCommand> commandSink, | ||
Functions.Proc1<StateMachine> stateMachineSink) { | ||
super(STATE_MACHINE_DEFINITION, commandSink, stateMachineSink); | ||
this.modifiedPropertiesAttributes = modifiedPropertiesAttributes; | ||
explicitEvent(ExplicitEvent.SCHEDULE); | ||
} | ||
|
||
enum ExplicitEvent { | ||
SCHEDULE | ||
} | ||
|
||
enum State { | ||
CREATED, | ||
MODIFY_COMMAND_CREATED, | ||
MODIFY_COMMAND_RECORDED, | ||
} | ||
|
||
public static final StateMachineDefinition< | ||
State, ExplicitEvent, WorkflowPropertiesModifiedStateMachine> | ||
STATE_MACHINE_DEFINITION = | ||
StateMachineDefinition | ||
.<State, ExplicitEvent, WorkflowPropertiesModifiedStateMachine>newInstance( | ||
"WorkflowPropertiesModified", State.CREATED, State.MODIFY_COMMAND_RECORDED) | ||
.add( | ||
State.CREATED, | ||
ExplicitEvent.SCHEDULE, | ||
State.MODIFY_COMMAND_CREATED, | ||
WorkflowPropertiesModifiedStateMachine::createModifyCommand) | ||
.add( | ||
State.MODIFY_COMMAND_CREATED, | ||
CommandType.COMMAND_TYPE_MODIFY_WORKFLOW_PROPERTIES, | ||
State.MODIFY_COMMAND_CREATED) | ||
.add( | ||
State.MODIFY_COMMAND_CREATED, | ||
EventType.EVENT_TYPE_WORKFLOW_PROPERTIES_MODIFIED, | ||
State.MODIFY_COMMAND_RECORDED); | ||
|
||
private void createModifyCommand() { | ||
addCommand( | ||
Command.newBuilder() | ||
.setCommandType(CommandType.COMMAND_TYPE_MODIFY_WORKFLOW_PROPERTIES) | ||
.setModifyWorkflowPropertiesCommandAttributes(modifiedPropertiesAttributes) | ||
.build()); | ||
modifiedPropertiesAttributes = null; | ||
} | ||
} |
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
Oops, something went wrong.