Skip to content

Commit

Permalink
optimize: add saga io.seata compatible api (#6312)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptyin authored Jan 30, 2024
1 parent 16689ad commit 74785d2
Show file tree
Hide file tree
Showing 20 changed files with 2,613 additions and 4 deletions.
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6306](https://github.com/apache/incubator-seata/pull/6306)] replace some URL to org/apache/seata
- [[#6304](https://github.com/apache/incubator-seata/pull/6304)] disable Publish OSSRH workflow
- [[#6301](https://github.com/apache/incubator-seata/pull/6301)] upgrade console frontend dependencies and supported nodejs versions
- [[#6301](https://github.com/apache/incubator-seata/pull/6312)] add saga related io.seata compatible api
- [[#6313](https://github.com/apache/incubator-seata/pull/6313)] console display the version number

### security:
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
- [[#6306](https://github.com/apache/incubator-seata/pull/6306)] 替换一些URL 至 org/apache/seata
- [[#6304](https://github.com/apache/incubator-seata/pull/6304)] 禁用 OSSRH 发布工作流
- [[#6301](https://github.com/apache/incubator-seata/pull/6301)] 升级console前端依赖及支持的nodejs版本
- [[#6301](https://github.com/apache/incubator-seata/pull/6312)] 添加saga相关的io.seata兼容性API
- [[#6313](https://github.com/apache/incubator-seata/pull/6313)] console展示版本号

### security:
Expand Down
21 changes: 18 additions & 3 deletions compatible/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,33 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>io.seata</groupId>
<version>${revision}</version>
<version>2.1.0-SNAPSHOT</version>
<modelVersion>4.0.0</modelVersion>
<artifactId>seata-all</artifactId>
<packaging>jar</packaging>
<name>seata-all ${project.version}</name>
<description>compatible with io.seata API</description>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<groupId>org.apache.seata</groupId>
<artifactId>seata-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.seata</groupId>
<artifactId>seata-saga-engine</artifactId>
<version>2.1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.seata</groupId>
<artifactId>seata-saga-engine-store</artifactId>
<version>2.1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.seata.tmp.core.context;
package io.seata.core.context;

import java.util.Map;

Expand Down
44 changes: 44 additions & 0 deletions compatible/src/main/java/io/seata/saga/engine/AsyncCallback.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* 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;

import io.seata.saga.proctrl.ProcessContext;
import io.seata.saga.statelang.domain.StateMachineInstance;

/**
* Async Callback
*
*/
public interface AsyncCallback {

/**
* on finished
*
* @param context
* @param stateMachineInstance
*/
void onFinished(ProcessContext context, StateMachineInstance stateMachineInstance);

/**
* on error
*
* @param context
* @param stateMachineInstance
* @param exp
*/
void onError(ProcessContext context, StateMachineInstance stateMachineInstance, Exception exp);
}
170 changes: 170 additions & 0 deletions compatible/src/main/java/io/seata/saga/engine/StateMachineConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* 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;

import org.apache.seata.saga.engine.expression.ExpressionFactoryManager;
import org.apache.seata.saga.engine.expression.ExpressionResolver;
import org.apache.seata.saga.engine.invoker.ServiceInvokerManager;
import org.apache.seata.saga.engine.repo.StateLogRepository;
import org.apache.seata.saga.engine.repo.StateMachineRepository;
import org.apache.seata.saga.engine.sequence.SeqGenerator;
import org.apache.seata.saga.engine.store.StateLangStore;
import org.apache.seata.saga.engine.store.StateLogStore;
import org.apache.seata.saga.engine.strategy.StatusDecisionStrategy;
import org.apache.seata.saga.proctrl.eventing.impl.ProcessCtrlEventPublisher;
import org.springframework.context.ApplicationContext;

import javax.script.ScriptEngineManager;
import java.util.concurrent.ThreadPoolExecutor;

/**
* StateMachineConfig
*
*/
public interface StateMachineConfig {

/**
* Gets state log store.
*
* @return the StateLogRepository
*/
StateLogRepository getStateLogRepository();

/**
* Gets get state log store.
*
* @return the get StateLogStore
*/
StateLogStore getStateLogStore();

/**
* Gets get state language definition store.
*
* @return the get StateLangStore
*/
StateLangStore getStateLangStore();

/**
* Gets get expression factory manager.
*
* @return the get expression factory manager
*/
ExpressionFactoryManager getExpressionFactoryManager();

/**
* Gets get expression resolver
*
* @return the get expression resolver
*/
ExpressionResolver getExpressionResolver();

/**
* Gets get charset.
*
* @return the get charset
*/
String getCharset();

/**
* Gets get default tenant id.
*
* @return the default tenant id
*/
String getDefaultTenantId();

/**
* Gets get state machine repository.
*
* @return the get state machine repository
*/
StateMachineRepository getStateMachineRepository();

/**
* Gets get status decision strategy.
*
* @return the get status decision strategy
*/
StatusDecisionStrategy getStatusDecisionStrategy();

/**
* Gets get seq generator.
*
* @return the get seq generator
*/
SeqGenerator getSeqGenerator();

/**
* Gets get process ctrl event publisher.
*
* @return the get process ctrl event publisher
*/
ProcessCtrlEventPublisher getProcessCtrlEventPublisher();

/**
* Gets get async process ctrl event publisher.
*
* @return the get async process ctrl event publisher
*/
ProcessCtrlEventPublisher getAsyncProcessCtrlEventPublisher();

/**
* Gets get application context.
*
* @return the get application context
*/
ApplicationContext getApplicationContext();

/**
* Gets get thread pool executor.
*
* @return the get thread pool executor
*/
ThreadPoolExecutor getThreadPoolExecutor();

/**
* Is enable async boolean.
*
* @return the boolean
*/
boolean isEnableAsync();

/**
* get ServiceInvokerManager
*
* @return the service invoker manager info
*/
ServiceInvokerManager getServiceInvokerManager();

/**
* get trans operation timeout
* @return the transaction operate time out
*/
int getTransOperationTimeout();

/**
* get service invoke timeout
* @return the service invoke time out
*/
int getServiceInvokeTimeout();

/**
* get ScriptEngineManager
*
* @return the script engine manager info
*/
ScriptEngineManager getScriptEngineManager();
}
Loading

0 comments on commit 74785d2

Please sign in to comment.