-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimize: add saga compatible subcomponent-level api (#6329)
- Loading branch information
Showing
10 changed files
with
311 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
25 changes: 25 additions & 0 deletions
25
compatible/src/main/java/io/seata/saga/engine/expression/Expression.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,25 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 io.seata.saga.engine.expression; | ||
|
||
/** | ||
* Expression | ||
* | ||
*/ | ||
public interface Expression extends org.apache.seata.saga.engine.expression.Expression { | ||
|
||
} |
24 changes: 24 additions & 0 deletions
24
compatible/src/main/java/io/seata/saga/engine/expression/ExpressionFactory.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,24 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 io.seata.saga.engine.expression; | ||
|
||
/** | ||
* Expression Factory | ||
* | ||
*/ | ||
public interface ExpressionFactory extends org.apache.seata.saga.engine.expression.ExpressionFactory { | ||
} |
64 changes: 64 additions & 0 deletions
64
compatible/src/main/java/io/seata/saga/engine/expression/ExpressionFactoryManager.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,64 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 io.seata.saga.engine.expression; | ||
|
||
import java.util.AbstractMap; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Expression factory manager | ||
*/ | ||
public class ExpressionFactoryManager { | ||
|
||
private final org.apache.seata.saga.engine.expression.ExpressionFactoryManager actual; | ||
|
||
public static final String DEFAULT_EXPRESSION_TYPE = "Default"; | ||
|
||
private ExpressionFactoryManager(org.apache.seata.saga.engine.expression.ExpressionFactoryManager actual) { | ||
this.actual = actual; | ||
} | ||
|
||
public ExpressionFactoryManager() { | ||
actual = new org.apache.seata.saga.engine.expression.ExpressionFactoryManager(); | ||
} | ||
|
||
|
||
public ExpressionFactory getExpressionFactory(String expressionType) { | ||
org.apache.seata.saga.engine.expression.ExpressionFactory expressionFactory = actual.getExpressionFactory(expressionType); | ||
return expressionFactory::createExpression; | ||
} | ||
|
||
public void setExpressionFactoryMap(Map<String, ExpressionFactory> expressionFactoryMap) { | ||
Map<String, org.apache.seata.saga.engine.expression.ExpressionFactory> actualExpressionFactoryMap = expressionFactoryMap.entrySet().stream() | ||
.map(e -> new AbstractMap.SimpleEntry<String, org.apache.seata.saga.engine.expression.ExpressionFactory>(e.getKey(), e.getValue())) | ||
.collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); | ||
actual.setExpressionFactoryMap(actualExpressionFactoryMap); | ||
} | ||
|
||
public void putExpressionFactory(String type, ExpressionFactory factory) { | ||
actual.putExpressionFactory(type, factory); | ||
} | ||
|
||
public org.apache.seata.saga.engine.expression.ExpressionFactoryManager unwrap() { | ||
return actual; | ||
} | ||
|
||
public static ExpressionFactoryManager wrap(org.apache.seata.saga.engine.expression.ExpressionFactoryManager actual) { | ||
return new ExpressionFactoryManager(actual); | ||
} | ||
} |
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
71 changes: 71 additions & 0 deletions
71
compatible/src/main/java/io/seata/saga/engine/repo/StateLogRepository.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,71 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You 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 io.seata.saga.engine.repo; | ||
|
||
import io.seata.saga.statelang.domain.StateInstance; | ||
import io.seata.saga.statelang.domain.StateMachineInstance; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* State Log Repository | ||
* | ||
*/ | ||
public interface StateLogRepository { | ||
|
||
/** | ||
* Get state machine instance | ||
* | ||
* @param stateMachineInstanceId the state machine instance id | ||
* @return the state machine instance | ||
*/ | ||
StateMachineInstance getStateMachineInstance(String stateMachineInstanceId); | ||
|
||
/** | ||
* Get state machine instance by businessKey | ||
* | ||
* @param businessKey the business key | ||
* @param tenantId the tenant id | ||
* @return the state machine instance | ||
*/ | ||
StateMachineInstance getStateMachineInstanceByBusinessKey(String businessKey, String tenantId); | ||
|
||
/** | ||
* Query the list of state machine instances by parent id | ||
* | ||
* @param parentId the state parent id | ||
* @return state machine instance list | ||
*/ | ||
List<StateMachineInstance> queryStateMachineInstanceByParentId(String parentId); | ||
|
||
/** | ||
* Get state instance | ||
* | ||
* @param stateInstanceId the state instance id | ||
* @param machineInstId the state machine instance id | ||
* @return the state instance | ||
*/ | ||
StateInstance getStateInstance(String stateInstanceId, String machineInstId); | ||
|
||
/** | ||
* Get a list of state instances by state machine instance id | ||
* | ||
* @param stateMachineInstanceId the state machine instance id | ||
* @return the state machine instance list | ||
*/ | ||
List<StateInstance> queryStateInstanceListByMachineInstanceId(String stateMachineInstanceId); | ||
} |
Oops, something went wrong.