jovezhao / nest Goto Github PK
View Code? Open in Web Editor NEW鸟窝
License: Apache License 2.0
鸟窝
License: Apache License 2.0
阅读源码后的个人理解:
工作单元提交之后,会将变更提交到缓存中,数据库、缓存双写。
在并发情况下,此处的逻辑是否有可能会产生一致性问题?
nest/nest-ddd/src/main/java/com/zhaofujun/nest/context/ContextUnitOfWork.java
Lines 108 to 114 in ab1ed3e
nest/nest-ddd/src/main/java/com/zhaofujun/nest/context/ContextUnitOfWork.java
Lines 131 to 147 in ab1ed3e
在多线程的里面load修改数据的情况下,stack的进栈和出栈会错乱,会导致事务无法提交,例如父线程的ServiceContext先进栈,子线程的ServiceContext后进栈,父线程方法执行完了之后,调用出栈方法,子线程的ServiceContext先出栈了,然后子线程去获取ServiceContext就会存在获取不到的情况了。
建议可用private static TransmittableThreadLocal<ConcurrentHashMap<String, Stack>> serviceContextThreadLocal = new TransmittableThreadLocal<>();;来替代原来用stack来存取上下文的情况,ConcurrentHashMap里面的key存放线程名,这样根据线程名来获取上下文可防止stack出现错乱的情况
目前的 LongIdentifier id 生成方法写死了固定时间与格式的雪花算法,将 Long ID 生成方法抽象以提高灵活性。
Lines 66 to 67 in 58ffd82
FAILURE: Build failed with an exception.
* Where:
Script '/home/sia/IdeaProjects/nest/publish.gradle' line: 66
* What went wrong:
A problem occurred evaluating script.
> Could not get unknown property 'NEXUS_USERNAME' for Credentials [username: null] of type org.gradle.internal.credentials.DefaultPasswordCredentials_Decorated.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 42ms
源码中new ArrayList<>(). 建议 commitEntity时, batch操作之前,先排除list empty 的情况。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.