eventmesh
eventmesh copied to clipboard
[Enhancement] EventMeshServer subcomponent lifecycle management
Search before asking
- [X] I had searched in the issues and found no similar issues.
Enhancement Request
I have seen multiple properties of EventMeshServer, such as Acl or MetaStorage, which are actually wrappers for declaring the cycle state of specific services. There are several properties that indicate the current state, such as initialized, started, etc. There are also methods for state transition, such as # init. So, I wonder if it's possible to change these classes to LifeCircle form for management, At that time, there will be a superclass such as AbstractEventMeshInitializerLifeCircle, which implements management of properties such as initiate and calls to # init. Therefore, EventMeshServer only needs to maintain one
我感觉英文有点词不达意 我看到 EventMeshServer 的多个属性,如 Acl 或 MetaStorage 等,其实都是对于具体服务附加声明周期状态的包装,会有几个标志当前状态的属性,如 inited、started等,还有有状态转换的方法如 #init 等,那我想可以不可以把这些类都改成 LifeCircle 形式管理,到时候会有一个比如AbstractEventMeshInitalizerLifeCircle 之类的超类,实现了对于inited等属性等管理和对#init的调用,那么 EventMeshServer 只需要维护一个 LifeCircleList 就可以管理这些对象了
Describe the solution you'd like
`
public abstract class AbstractDemoLifeCircle {
private final AtomicBoolean inited = new AtomicBoolean(false);
private final AtomicBoolean started = new AtomicBoolean(false);
private final AtomicBoolean shutdown = new AtomicBoolean(false);
public void init() throws Exception {
if (!inited.compareAndSet(false, true)) {
return;
}
componentInit();
}
abstract void componentInit();
public void start() throws Exception {
if (!started.compareAndSet(false, true)) {
return;
}
componentStart();
}
abstract void componentStart();
public void shutdown() throws AclException {
inited.compareAndSet(true, false);
started.compareAndSet(true, false);
if (!shutdown.compareAndSet(false, true)) {
return;
}
componentStop();
}
abstract void componentStop();
}
`
`
public class Acl extends AbstractDemoLifeCircle {}
`
`
public class EventMeshServer { ... private List<LifeCircle> components; ... public void init() throws Exception { components.forEach(component -> component .init()); }
}
`
As for the special handling of EventMeshBootstrap, it is completely possible to wait for init before executing the original logic 至于 EventMeshBootstrap 这种特殊处理,完全可以等init之后再执行原逻辑
Are you willing to submit PR?
- [X] Yes I am willing to submit a PR!
Code of Conduct
- [ ] I agree to follow this project's Code of Conduct *
Welcome to the Apache EventMesh community!! We are glad that you are contributing by opening this issue. :D
Please make sure to include all the relevant context. We will be here shortly.
If you are interested in contributing to our project, please let us know! You can check out our contributing guide on contributing to EventMesh.
Want to get closer to the community?
| WeChat Assistant | WeChat Public Account | Slack |
|---|---|---|
![]() |
![]() |
Join Slack Chat |
Mailing Lists:
| Name | Description | Subscribe | Unsubscribe | Archive |
|---|---|---|---|---|
| Users | User support and questions mailing list | Subscribe | Unsubscribe | Mail Archives |
| Development | Development related discussions | Subscribe | Unsubscribe | Mail Archives |
| Commits | All commits to repositories | Subscribe | Unsubscribe | Mail Archives |
| Issues | Issues or PRs comments and reviews | Subscribe | Unsubscribe | Mail Archives |
The code block seems to be broken.
@Pil0tXia im build a demo pr later
It has been 90 days since the last activity on this issue. Apache EventMesh values the voices of the community. Please don't hesitate to share your latest insights on this matter at any time, as the community is more than willing to engage in discussions regarding the development and optimization directions of this feature.
If you feel that your issue has been resolved, please feel free to close it. Should you have any additional information to share, you are welcome to reopen this issue.

