feature #IAY66T 缓存初始化配置

This commit is contained in:
DaleLee
2024-11-09 20:36:04 +08:00
parent 917c98cc48
commit 7a63f7cec9
9 changed files with 126 additions and 2 deletions

View File

@@ -20,7 +20,7 @@ import com.yomahub.liteflow.enums.ParseModeEnum;
import com.yomahub.liteflow.exception.*;
import com.yomahub.liteflow.flow.FlowBus;
import com.yomahub.liteflow.flow.LiteflowResponse;
import com.yomahub.liteflow.flow.cache.RuleCacheLifeCycle;
import com.yomahub.liteflow.lifecycle.impl.RuleCacheLifeCycle;
import com.yomahub.liteflow.flow.element.Chain;
import com.yomahub.liteflow.flow.element.Node;
import com.yomahub.liteflow.flow.element.Rollbackable;

View File

@@ -1,4 +1,4 @@
package com.yomahub.liteflow.flow.cache;
package com.yomahub.liteflow.lifecycle.impl;
import cn.hutool.core.util.ObjectUtil;
import com.github.benmanes.caffeine.cache.Cache;

View File

@@ -0,0 +1,26 @@
package com.yomahub.liteflow.test.ruleCache;
import com.yomahub.liteflow.core.FlowExecutor;
import com.yomahub.liteflow.test.BaseTest;
import com.yomahub.liteflow.test.rollback.RollbackSpringbootTest;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.test.context.TestPropertySource;
import javax.annotation.Resource;
@TestPropertySource(value = "classpath:/ruleCache/application.properties")
@SpringBootTest(classes = RuleCacheSpringbootTest.class)
@EnableAutoConfiguration
@ComponentScan({ "com.yomahub.liteflow.test.ruleCache.cmp" })
public class RuleCacheSpringbootTest extends BaseTest {
@Resource
private FlowExecutor flowExecutor;
@Test
public void testRuleCache() throws Exception{
}
}

View File

@@ -0,0 +1,20 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.ruleCache.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("a")
public class ACmp extends NodeComponent {
@Override
public void process() {
System.out.println("ACmp executed!");
}
}

View File

@@ -0,0 +1,21 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.ruleCache.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("b")
public class BCmp extends NodeComponent {
@Override
public void process() {
System.out.println("BCmp executed!");
}
}

View File

@@ -0,0 +1,20 @@
/**
* <p>Title: liteflow</p>
* <p>Description: 轻量级的组件式流程框架</p>
* @author Bryan.Zhang
* @email weenyc31@163.com
* @Date 2020/4/1
*/
package com.yomahub.liteflow.test.ruleCache.cmp;
import com.yomahub.liteflow.core.NodeComponent;
import org.springframework.stereotype.Component;
@Component("c")
public class CCmp extends NodeComponent {
@Override
public void process() {
System.out.println("CCmp executed!");
}
}

View File

@@ -0,0 +1,12 @@
package com.yomahub.liteflow.test.ruleCache.cmp;
import com.yomahub.liteflow.core.NodeBooleanComponent;
import org.springframework.stereotype.Component;
@Component("x")
public class XCmp extends NodeBooleanComponent {
@Override
public boolean processBoolean() throws Exception {
return true;
}
}

View File

@@ -0,0 +1,2 @@
liteflow.rule-source=ruleCache/flow.el.xml
liteflow.rule-cache-capacity=3

View File

@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<chain name="chain1">
THEN(a, b);
</chain>
<chain name="chain2">
THEN(a, c);
</chain>
<chain name="chain3">
THEN(c, b);
</chain>
<chain name="chain4">
THEN(IF(x, a), b);
</chain>
<chain name="chain5">
THEN(IF(x, a), c);
</chain>
</flow>