Closed Anilople closed 6 months ago
The recent changes in the apollo-client
module primarily focus on improving the initialization process to speed up the user's startup time. The changes include adding an initialize()
method to various classes and interfaces, modifying constructors to avoid initial synchronization calls, and updating tests to reflect these changes.
File Path | Change Summary |
---|---|
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/AbstractConfigRepository.java |
Added initialize() method to call sync() . |
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/ConfigRepository.java |
Added default initialize() method to the interface. |
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java |
Added call to m_configRepository.initialize() in initialize() method. |
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepository.java |
Commented out trySync() call in the constructor. |
apollo-client/src/main/java/com/ctrip/framework/apollo/internals/RemoteConfigRepository.java |
Commented out trySync() call in the constructor. |
apollo-client/src/test/java/com/ctrip/framework/apollo/internals/LocalFileConfigRepositoryTest.java |
Added assertion to check source type before and after initialization in testOnRepositoryChange . |
Objective (Issue #60) | Addressed | Explanation |
---|---|---|
Speed up user's startup time by reducing IO calls | β | |
Fast fail when encountering errors | β |
In the land of code where rabbits play, Initialization now speeds the way. Sync calls deferred, constructors light, Users' startup times take flight. With tests to check, and code so bright, Apollo's changes feel just right. πβ¨
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
What's the purpose of this PR
Speed up the user's startup time,
by decrease the number of http requests.
Which issue(s) this PR fixes:
Fixes https://github.com/apolloconfig/apollo-java/issues/60
Brief changelog
before change, it use 11494 ms to load 10 namespace when meet 404, before-change.log
after delete 2 http requests when context init, it use 1490 ms. after-change.log
i.e from 11494 ms to 1490 ms.
the code in https://github.com/apolloconfig/apollo-java/blob/bcc40531f32e74d0c639b5e5d2ab2995fd00c3d6/apollo-client/src/main/java/com/ctrip/framework/apollo/internals/DefaultConfig.java#L69 will ensure pull at least one time from remote when startup.
Follow this checklist to help us incorporate your contribution quickly and easily:
mvn clean test
to make sure this pull request doesn't break anything.CHANGES
log.Summary by CodeRabbit
New Features
Bug Fixes
Tests