Showing preview only (1,281K chars total). Download the full file or copy to clipboard to get everything.
Repository: nacos-group/nacos-sdk-cpp
Branch: master
Commit: 2b4104d25247
Files: 239
Total size: 1.2 MB
Directory structure:
gitextract_q11n9gsq/
├── .gitignore
├── LICENSE
├── README.md
├── README_zh_CN.md
├── examples/
│ ├── IntegratingIntoYourProject.cpp
│ ├── generate_examples.sh
│ ├── getAllInstances.cpp
│ ├── getConfig.cpp
│ ├── listenToKeys.cpp
│ ├── registerInstances.cpp
│ ├── setConfig.cpp
│ └── subscribeServices.cpp
├── include/
│ ├── Compatibility.h
│ ├── Nacos.h
│ ├── NacosExceptions.h
│ ├── NacosString.h
│ ├── Properties.h
│ ├── ResourceGuard.h
│ ├── config/
│ │ └── ConfigService.h
│ ├── constant/
│ │ ├── ConfigConstant.h
│ │ ├── NamingConstant.h
│ │ ├── PropertyKeyConst.h
│ │ └── UtilAndComs.h
│ ├── factory/
│ │ ├── INacosServiceFactory.h
│ │ └── NacosFactoryFactory.h
│ ├── listen/
│ │ └── Listener.h
│ ├── naming/
│ │ ├── ChangeAdvice.h
│ │ ├── Cluster.h
│ │ ├── Instance.h
│ │ ├── ListView.h
│ │ ├── NamingMaintainService.h
│ │ ├── NamingService.h
│ │ ├── ServiceInfo.h
│ │ ├── ServiceInfo2.h
│ │ ├── selectors/
│ │ │ ├── HealthInstanceSelector.h
│ │ │ ├── RandomByWeightSelector.h
│ │ │ ├── RandomSelector.h
│ │ │ └── Selector.h
│ │ └── subscribe/
│ │ └── EventListener.h
│ ├── server/
│ │ └── ServerSelector.h
│ └── thread/
│ └── AtomicInt.h
├── nacos-cpp-cli.properties
├── src/
│ ├── NacosExceptions.cpp
│ ├── NacosString.cpp
│ ├── config/
│ │ ├── AppConfigManager.cpp
│ │ ├── AppConfigManager.h
│ │ ├── ConcurrentDiskUtil.cpp
│ │ ├── ConcurrentDiskUtil.h
│ │ ├── ConfigProxy.cpp
│ │ ├── ConfigProxy.h
│ │ ├── IOUtils.cpp
│ │ ├── IOUtils.h
│ │ ├── JVMUtil.h
│ │ ├── LocalSnapshotManager.cpp
│ │ ├── LocalSnapshotManager.h
│ │ ├── NacosConfigService.cpp
│ │ ├── NacosConfigService.h
│ │ ├── SnapShotSwitch.cpp
│ │ └── SnapShotSwitch.h
│ ├── constant/
│ │ ├── ConfigConstant.cpp
│ │ ├── NamingConstant.cpp
│ │ ├── PropertyKeyConst.cpp
│ │ └── UtilAndComs.cpp
│ ├── crypto/
│ │ ├── MACProvider.cpp
│ │ ├── MACProvider.h
│ │ ├── SignatureTool.h
│ │ ├── base64/
│ │ │ └── base64.h
│ │ ├── hmac_sha1/
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── hmac/
│ │ │ │ ├── hmac.h
│ │ │ │ └── hmac_sha1.cpp
│ │ │ └── sha/
│ │ │ ├── sha.h
│ │ │ └── sha1.cpp
│ │ └── md5/
│ │ ├── md5.cpp
│ │ └── md5.h
│ ├── debug/
│ │ └── DebugAssertion.h
│ ├── factory/
│ │ ├── NacosFactoryFactory.cpp
│ │ ├── NacosServiceFactory.cpp
│ │ ├── NacosServiceFactory.h
│ │ ├── ObjectConfigData.cpp
│ │ └── ObjectConfigData.h
│ ├── http/
│ │ ├── HTTPCli.cpp
│ │ ├── HTTPCli.h
│ │ ├── HttpDelegate.h
│ │ ├── HttpStatus.h
│ │ ├── IHttpCli.h
│ │ └── delegate/
│ │ ├── NacosAuthHttpDelegate.cpp
│ │ ├── NacosAuthHttpDelegate.h
│ │ ├── NoOpHttpDelegate.cpp
│ │ └── NoOpHttpDelegate.h
│ ├── init/
│ │ ├── Init.cpp
│ │ └── Init.h
│ ├── json/
│ │ ├── JSON.cpp
│ │ ├── JSON.h
│ │ └── rapidjson/
│ │ ├── allocators.h
│ │ ├── cursorstreamwrapper.h
│ │ ├── document.h
│ │ ├── encodedstream.h
│ │ ├── encodings.h
│ │ ├── error/
│ │ │ ├── en.h
│ │ │ └── error.h
│ │ ├── filereadstream.h
│ │ ├── filewritestream.h
│ │ ├── fwd.h
│ │ ├── internal/
│ │ │ ├── biginteger.h
│ │ │ ├── diyfp.h
│ │ │ ├── dtoa.h
│ │ │ ├── ieee754.h
│ │ │ ├── itoa.h
│ │ │ ├── meta.h
│ │ │ ├── pow10.h
│ │ │ ├── regex.h
│ │ │ ├── stack.h
│ │ │ ├── strfunc.h
│ │ │ ├── strtod.h
│ │ │ └── swap.h
│ │ ├── istreamwrapper.h
│ │ ├── memorybuffer.h
│ │ ├── memorystream.h
│ │ ├── msinttypes/
│ │ │ ├── inttypes.h
│ │ │ └── stdint.h
│ │ ├── ostreamwrapper.h
│ │ ├── pointer.h
│ │ ├── prettywriter.h
│ │ ├── rapidjson.h
│ │ ├── reader.h
│ │ ├── schema.h
│ │ ├── stream.h
│ │ ├── stringbuffer.h
│ │ └── writer.h
│ ├── listen/
│ │ ├── ClientWorker.cpp
│ │ ├── ClientWorker.h
│ │ ├── ListeningData.h
│ │ └── OperateItem.h
│ ├── log/
│ │ ├── Logger.cpp
│ │ └── Logger.h
│ ├── naming/
│ │ ├── Cluster.cpp
│ │ ├── Instance.cpp
│ │ ├── NacosNamingMaintainService.cpp
│ │ ├── NacosNamingMaintainService.h
│ │ ├── NacosNamingService.cpp
│ │ ├── NacosNamingService.h
│ │ ├── NamingProxy.cpp
│ │ ├── NamingProxy.h
│ │ ├── ServiceInfo.cpp
│ │ ├── beat/
│ │ │ ├── BeatInfo.cpp
│ │ │ ├── BeatInfo.h
│ │ │ ├── BeatReactor.cpp
│ │ │ ├── BeatReactor.h
│ │ │ ├── BeatTask.cpp
│ │ │ └── BeatTask.h
│ │ ├── cache/
│ │ │ ├── ChangeAdvice.cpp
│ │ │ ├── NamingCache.cpp
│ │ │ └── NamingCache.h
│ │ ├── selectors/
│ │ │ ├── HealthInstanceSelector.cpp
│ │ │ ├── RandomByWeightSelector.cpp
│ │ │ └── RandomSelector.cpp
│ │ └── subscribe/
│ │ ├── EventDispatcher.cpp
│ │ ├── EventDispatcher.h
│ │ ├── EventListener.cpp
│ │ ├── HostReactor.cpp
│ │ ├── HostReactor.h
│ │ ├── SubscriptionPoller.cpp
│ │ ├── SubscriptionPoller.h
│ │ ├── UdpNamingServiceListener.cpp
│ │ └── UdpNamingServiceListener.h
│ ├── security/
│ │ ├── SecurityManager.cpp
│ │ └── SecurityManager.h
│ ├── server/
│ │ ├── NacosServerInfo.h
│ │ ├── ServerListManager.cpp
│ │ └── ServerListManager.h
│ ├── thread/
│ │ ├── BlockingQueue.h
│ │ ├── DelayedThreadPool.cpp
│ │ ├── DelayedThreadPool.h
│ │ ├── Mutex.h
│ │ ├── RWLock.h
│ │ ├── Task.h
│ │ ├── Thread.cpp
│ │ ├── Thread.h
│ │ ├── ThreadLocal.h
│ │ ├── ThreadPool.cpp
│ │ ├── ThreadPool.h
│ │ ├── Tid.cpp
│ │ └── Tid.h
│ └── utils/
│ ├── ConfigParserUtils.cpp
│ ├── ConfigParserUtils.h
│ ├── DirUtils.cpp
│ ├── DirUtils.h
│ ├── Env.h
│ ├── GroupKey.h
│ ├── NamingUtils.h
│ ├── NetUtils.cpp
│ ├── NetUtils.h
│ ├── ParamUtils.h
│ ├── RandomUtils.cpp
│ ├── RandomUtils.h
│ ├── SequenceProvider.h
│ ├── TimeUtils.cpp
│ ├── TimeUtils.h
│ ├── UuidUtils.cpp
│ ├── UuidUtils.h
│ ├── url.cpp
│ └── url.h
└── test/
├── allinone.cpp
└── testcase/
├── AssertString.cpp
├── DebugTest.cpp
├── testAppConfigManager.cpp
├── testCache.cpp
├── testDelayedThreadPool.cpp
├── testDeleteConfig.cpp
├── testDeleteListenedKeys.cpp
├── testEndpointWithNamingSvc.cpp
├── testGetAllInstances.cpp
├── testGetConfig.cpp
├── testGetServiceNames.cpp
├── testHttpRequest.cpp
├── testIOUtils.cpp
├── testInstanceSelector.cpp
├── testJson2BizObjects.cpp
├── testListenWorker.cpp
├── testListeningKeys.cpp
├── testListeningKeysWithHttpPrefix.cpp
├── testMAC.cpp
├── testMD5.cpp
├── testMaintainInstances.cpp
├── testMaintainServices.cpp
├── testNamingService.cpp
├── testNamingSubscribe.cpp
├── testNetUtils.cpp
├── testPublishConfig.cpp
├── testPublishConfigWithHttpPrefix.cpp
├── testRapidJson.cpp
├── testSequenceProvider.cpp
├── testServerListManager.cpp
├── testStringExplode.cpp
├── testThreadLocal.cpp
├── testThreadSmoke.cpp
├── testURL.cpp
└── testUUID.cpp
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
# Prerequisites
*.d
# Compiled Object files
*.slo
*.lo
*.o
*.obj
# Precompiled Headers
*.gch
*.pch
# Compiled Dynamic libraries
*.so
*.dylib
*.dll
# Fortran module files
*.mod
*.smod
# Compiled Static libraries
*.lai
*.la
*.a
*.lib
# Executables
*.exe
*.out
*.app
# temp
tmp/
# CMakeFiles
CMakeFiles/
CMakeLists.txt
CMakeCache.txt
cmake_install.cmake
install_manifest.txt
Makefile
# idea project
.idea
cmake-build-debug
*.dat
.vscode/
================================================
FILE: LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed 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.
================================================
FILE: README.md
================================================
<img src="https://github.com/alibaba/nacos/blob/develop/doc/Nacos_Logo.png" width="50%" height="50%" />
[中文版本说明请点这里](https://github.com/nacos-group/nacos-sdk-cpp/blob/master/README_zh_CN.md)
# Nacos-sdk-cpp
Nacos-sdk-cpp for c++ client allows users to access Nacos service, it supports service discovery and dynamic configuration.
[](https://gitter.im/alibaba/nacos?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](https://www.apache.org/licenses/LICENSE-2.0.html)
# Quick Examples
## Setup project
Download the source and run the following command in bash:
```
cd nacos-sdk-cpp
cmake .
make
```
a libnacos-cli.so and a nacos-cli.out will be generated
run `./nacos-cli.out` to perform test on the library
run `make install` to install the libnacos-cli to your system library path
**Note:** You need to run a nacos server on your local machine listening on port 8848 to go through the whole test
One of the testcases will test endpoint functionality, so **you also need** to run a simple http server on port 80 which provides the following content:
`127.0.0.1:8848`
**on path /nacos/endpoint0**
**All these examples could be found in nacos-sdk-cpp/examples/**
## Integrate the library into your project
Here is an example showing how to integrate the library(.so) into your project:
IntegratingIntoYourProject.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//Server address
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
NacosString ss = "";
try {
ss = n->getConfig("k", NULLSTR, 1000);
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << ss << endl;
return 0;
}
```
`g++ -I/usr/local/include/nacos/ IntegratingIntoYourProject.cpp -lnacos-cli -o integrated.out`
Start a nacos on your localmachine listening on port 8848, and run `./integrated.out`
Then you'll see:
`SuccessfullyIntegrated`
## If you are using a static lib(.a):
Assume that the file you are compiling resides in the same directory as the .a library, please use the following command:
`g++ -I/usr/local/include/nacos/ IntegratingIntoYourProject.cpp -lcurl -lz -L. -lnacos-cli-static -o integrated.out`
-lcurl -lz Specifies the curl and lz library used by libnacos
-L. -lnacos-cli-static links the static libnacos library resides in the same directory as IntegratingIntoYourProject.cpp
## Configuration
### Get Config
getConfig.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//Server address
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
NacosString ss = "";
try {
ss = n->getConfig("k", NULLSTR, 1000);
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << ss << endl;
return 0;
}
```
### Publish Config
setConfig.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//server address
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
bool bSucc = false;
NacosString ss = "";
try {
bSucc = n->publishConfig("Cfg_key", NULLSTR, "Cfg_val");
int retry = 0;
ss = n->getConfig("Cfg_key", NULLSTR, 1000);
while (!(ss == "Cfg_val") && retry++ < 10) {
ss = n->getConfig("Cfg_key", NULLSTR, 1000);
}
if (!(ss == "Cfg_val")) {
throw NacosException(0, "getConfig() failed.");
}
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << "Publishing Key:Cfg_key with value:Cfg_val result:" << bSucc << endl;
return 0;
}
```
### Listen to key change & Cancel listening
listenToKeys.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
class MyListener : public Listener {
private:
int num;
public:
MyListener(int num) {
this->num = num;
}
void receiveConfigInfo(const NacosString &configInfo) {
cout << "===================================" << endl;
cout << "Watcher" << num << endl;
cout << "Watched Key UPDATED:" << configInfo << endl;
cout << "===================================" << endl;
}
};
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
MyListener *theListener = new MyListener(1);//You don't need to free it, since it will be deleted by the function removeListener
n->addListener("dqid", NULLSTR, theListener);//All changes on the key dqid will be received by MyListener
cout << "Input a character to continue" << endl;
getchar();
cout << "remove listener" << endl;
n->removeListener("dqid", NULLSTR, theListener);//Cancel listening
getchar();
return 0;
}
```
## Naming
### Register Instance & Unregister Instance
registerInstances.cpp:
```C++
#include <iostream>
#include <unistd.h>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties configProps;
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
NacosServiceFactory *factory = new NacosServiceFactory(configProps);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
NamingService *namingSvc = factory->CreateNamingService();
ResourceGuard <NamingService> _serviceFactory(namingSvc);
Instance instance;
instance.clusterName = "DefaultCluster";
instance.ip = "127.0.0.1";
instance.port = 2333;
instance.instanceId = "1";
instance.ephemeral = true;
//Registers 5 services named TestNamingService1...5
try {
for (int i = 0; i < 5; i++) {
NacosString serviceName = "TestNamingService" + NacosStringOps::valueOf(i);
instance.port = 2000 + i;
namingSvc->registerInstance(serviceName, instance);
}
}
catch (NacosException &e) {
cout << "encounter exception while registering service instance, raison:" << e.what() << endl;
return -1;
}
sleep(30);
try {
for (int i = 0; i < 5; i++) {
NacosString serviceName = "TestNamingService" + NacosStringOps::valueOf(i);
namingSvc->deregisterInstance(serviceName, "127.0.0.1", 2000 + i);
sleep(1);
}
}
catch (NacosException &e) {
cout << "encounter exception while registering service instance, raison:" << e.what() << endl;
return -1;
}
sleep(30);
return 0;
}
```
### Subscribe & Unsubscribe
subscribeServices.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
class MyServiceListener : public EventListener {
private:
int num;
public:
MyServiceListener(int num) {
this->num = num;
}
void receiveNamingInfo(const ServiceInfo &serviceInfo){
cout << "===================================" << endl;
cout << "Watcher: " << num << endl;
cout << "Watched service UPDATED: " << serviceInfo.toInstanceString() << endl;
cout << "===================================" << endl;
}
};
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";
//Interval for poller to check the status of subscribed services(unit:Ms), 30000 by default
//Here we set it to 5000 to see the output more quick
props[PropertyKeyConst::SUBSCRIPTION_POLL_INTERVAL] = "5000";
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
NamingService *n = factory->CreateNamingService();
ResourceGuard <NamingService> _serviceFactory(n);
n->subscribe("ss", new MyServiceListener(1));
cout << "Press any key to register services" << endl;
getchar();
n->registerInstance("ss", "127.0.0.1", 33);
n->registerInstance("ss", "127.0.0.1", 34);
cout << "Press any key to deregister services" << endl;
getchar();
n->deregisterInstance("ss", "127.0.0.1", 33);
n->deregisterInstance("ss", "127.0.0.1", 34);
cout << "All instances Unregistered, press any key to finish testing" << endl;
getchar();
return 0;
}
```
### Get all instances of a service
getAllInstances.cpp:
```C++
#include <iostream>
#include <list>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties configProps;
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
NacosServiceFactory *factory = new NacosServiceFactory(configProps);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
NamingService *namingSvc = factory->CreateNamingService();
ResourceGuard <NamingService> _guardService(namingSvc);
list <Instance> instances = namingSvc->getAllInstances("TestNamingService1");
cout << "getAllInstances from server:" << endl;
for (list<Instance>::iterator it = instances.begin();
it != instances.end(); it++) {
cout << "Instance:" << it->toString() << endl;
}
return 0;
}
```
### Enabling Authentication
If your Nacos server is secured with password, you can add the following snippet to any of the examples above to enable authentication:
```C++
using namespace nacos;
......
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
configProps[PropertyKeyConst::AUTH_USERNAME] = "username";
configProps[PropertyKeyConst::AUTH_PASSWORD] = "password";
NacosServiceFactory *factory = new NacosServiceFactory(configProps);
ConfigService *n = factory->CreateConfigService();
NamingService *namingSvc = factory->CreateNamingService();
......
```
### Enabling SPAS Authentication
```C++
using namespace nacos;
......
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
configProps[PropertyKeyConst::ACCESS_KEY] = "accessKey";
configProps[PropertyKeyConst::SECRET_KEY] = "secretKey";
NacosServiceFactory *factory = new NacosServiceFactory(configProps);
ConfigService *n = factory->CreateConfigService();
NamingService *namingSvc = factory->CreateNamingService();
......
```
# Supported System/Compilers
| OS/Environment | Compilers | Tested version |
| ---- | ---- | ---- |
|MacOS Darwin 19.6.0 x86_64|Clang|Apple clang version 12.0.0 (clang-1200.0.26.2)|
|Windows 10 WSL|GCC|version 4.8.4|
|Windows 10 CYGWIN_NT-10.0 x86_64|GCC|version 10.2.0 (GCC)|
|Ubuntu1~16.04.12|GCC|version 5.4.0|
|CentOS|GCC||
|Windows|Visual C++|To be done|
# About Nacos
Nacos (official site: [http://nacos.io](http://nacos.io)) is an easy-to-use platform designed for dynamic service discovery and configuration and service management. It helps you to build cloud native applications and microservices platform easily.
Service is a first-class citizen in Nacos. Nacos supports almost all type of services, for example: [Dubbo/gRPC service](https://nacos.io/en-us/docs/use-nacos-with-dubbo.html), [Spring Cloud RESTFul service](https://nacos.io/en-us/docs/use-nacos-with-springcloud.html) and [Kubernetes service](https://nacos.io/en-us/docs/use-nacos-with-kubernetes.html).
================================================
FILE: README_zh_CN.md
================================================
<img src="https://github.com/alibaba/nacos/blob/develop/doc/Nacos_Logo.png" width="50%" height="50%" />
# Nacos-sdk-cpp
Nacos-sdk-cpp是nacos客戶端的C++版本,它支持服务发现和动态配置
[](https://gitter.im/alibaba/nacos?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [](https://www.apache.org/licenses/LICENSE-2.0.html)
# 快速开始
## 设置工程
下载工程源代码并且执行下述命令:
```
cd nacos-sdk-cpp
cmake .
make
```
将会产生一个libnacos-cli.so 和一个 nacos-cli.out
运行 `./nacos-cli.out` 以执行客户端的所有testcase
运行 `make install` 将libnacos-cli安装到lib目录
**注意:** 你需要在本机运行一个nacos server,监听8848端口以完成所有测试
其中有个测试将会测试端点(endpoint)功能,**所以你还需要**在本机运行一个http服务器,在路径/endpoints/endpoint0提供下述内容:
`127.0.0.1:8848`
**这些例子你都能在nacos-sdk-cpp/examples/找到**
## 将libnacos-cli集成到你的工程
下面的例子说明了如何将库文件(.so) 集成到你的工程:
IntegratingIntoYourProject.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//Server address
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
NacosString ss = "";
try {
ss = n->getConfig("k", NULLSTR, 1000);
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << ss << endl;
return 0;
}
```
`g++ -I/usr/local/include/nacos/ IntegratingIntoYourProject.cpp -lnacos-cli -o integrated.out`
在本机的8848端口启动一个nacos server, 并且运行 `./integrated.out`
你将会看到:
`SuccessfullyIntegrated`
## 如果你使用静态库(.a)链接
假设.a文件和待编译文件在同一目录, 请执行下述命令:
`g++ -I/usr/local/include/nacos/ IntegratingIntoYourProject.cpp -lcurl -lz -L. -lnacos-cli-static -o integrated.out`
使用-lcurl -lz指定nacos客户端使用的curl和lz库
使用-L. -lnacos-cli-static引用当前目录下的libnacos-cli-static.a
## 配置
### 获取配置
getConfig.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//Server address
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
NacosString ss = "";
try {
ss = n->getConfig("k", NULLSTR, 1000);
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << ss << endl;
return 0;
}
```
### 发布配置
setConfig.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//server address
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
bool bSucc = false;
NacosString ss = "";
try {
bSucc = n->publishConfig("Cfg_key", NULLSTR, "Cfg_val");
int retry = 0;
ss = n->getConfig("Cfg_key", NULLSTR, 1000);
while (!(ss == "Cfg_val") && retry++ < 10) {
ss = n->getConfig("Cfg_key", NULLSTR, 1000);
}
if (!(ss == "Cfg_val")) {
throw NacosException(0, "getConfig() failed.");
}
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << "Publishing Key:Cfg_key with value:Cfg_val result:" << bSucc << endl;
return 0;
}
```
### 监听配置变化和取消监听
listenToKeys.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
class MyListener : public Listener {
private:
int num;
public:
MyListener(int num) {
this->num = num;
}
void receiveConfigInfo(const NacosString &configInfo) {
cout << "===================================" << endl;
cout << "Watcher" << num << endl;
cout << "Watched Key UPDATED:" << configInfo << endl;
cout << "===================================" << endl;
}
};
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
MyListener *theListener = new MyListener(1);//You don't need to free it, since it will be deleted by the function removeListener
n->addListener("dqid", NULLSTR, theListener);//All changes on the key dqid will be received by MyListener
cout << "Input a character to continue" << endl;
getchar();
cout << "remove listener" << endl;
n->removeListener("dqid", NULLSTR, theListener);//Cancel listening
getchar();
return 0;
}
```
## 命名服务
### 注册和反注册实例
registerInstances.cpp:
```C++
#include <iostream>
#include <unistd.h>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties configProps;
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
NacosServiceFactory *factory = new NacosServiceFactory(configProps);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
NamingService *namingSvc = factory->CreateNamingService();
ResourceGuard <NamingService> _serviceFactory(namingSvc);
Instance instance;
instance.clusterName = "DefaultCluster";
instance.ip = "127.0.0.1";
instance.port = 2333;
instance.instanceId = "1";
instance.ephemeral = true;
//Registers 5 services named TestNamingService1...5
try {
for (int i = 0; i < 5; i++) {
NacosString serviceName = "TestNamingService" + NacosStringOps::valueOf(i);
instance.port = 2000 + i;
namingSvc->registerInstance(serviceName, instance);
}
}
catch (NacosException &e) {
cout << "encounter exception while registering service instance, raison:" << e.what() << endl;
return -1;
}
sleep(30);
try {
for (int i = 0; i < 5; i++) {
NacosString serviceName = "TestNamingService" + NacosStringOps::valueOf(i);
namingSvc->deregisterInstance(serviceName, "127.0.0.1", 2000 + i);
sleep(1);
}
}
catch (NacosException &e) {
cout << "encounter exception while registering service instance, raison:" << e.what() << endl;
return -1;
}
sleep(30);
return 0;
}
```
### 订阅和取消订阅服务
subscribeServices.cpp:
```C++
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
class MyServiceListener : public EventListener {
private:
int num;
public:
MyServiceListener(int num) {
this->num = num;
}
void receiveNamingInfo(const ServiceInfo &serviceInfo){
cout << "===================================" << endl;
cout << "Watcher: " << num << endl;
cout << "Watched service UPDATED: " << serviceInfo.toInstanceString() << endl;
cout << "===================================" << endl;
}
};
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";
//Interval for poller to check the status of subscribed services(unit:Ms), 30000 by default
//Here we set it to 5000 to see the output more quick
props[PropertyKeyConst::SUBSCRIPTION_POLL_INTERVAL] = "5000";
NacosServiceFactory *factory = new NacosServiceFactory(props);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
NamingService *n = factory->CreateNamingService();
ResourceGuard <NamingService> _serviceFactory(n);
n->subscribe("ss", new MyServiceListener(1));
cout << "Press any key to register services" << endl;
getchar();
n->registerInstance("ss", "127.0.0.1", 33);
n->registerInstance("ss", "127.0.0.1", 34);
cout << "Press any key to deregister services" << endl;
getchar();
n->deregisterInstance("ss", "127.0.0.1", 33);
n->deregisterInstance("ss", "127.0.0.1", 34);
cout << "All instances Unregistered, press any key to finish testing" << endl;
getchar();
return 0;
}
```
### 获取某个服务的全部实例
getAllInstances.cpp:
```C++
#include <iostream>
#include <list>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties configProps;
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
NacosServiceFactory *factory = new NacosServiceFactory(configProps);
ResourceGuard <NacosServiceFactory> _guardFactory(factory);
NamingService *namingSvc = factory->CreateNamingService();
ResourceGuard <NamingService> _guardService(namingSvc);
list <Instance> instances = namingSvc->getAllInstances("TestNamingService1");
cout << "getAllInstances from server:" << endl;
for (list<Instance>::iterator it = instances.begin();
it != instances.end(); it++) {
cout << "Instance:" << it->toString() << endl;
}
return 0;
}
```
### 启用认证
如果你的服务器启设置了密码,在上述任意一个例子当中加入下述配置,即可启用用户名密码认证:
```C++
using namespace nacos;
......
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
configProps[PropertyKeyConst::AUTH_USERNAME] = "username";
configProps[PropertyKeyConst::AUTH_PASSWORD] = "password";
NacosServiceFactory *factory = new NacosServiceFactory(configProps);
ConfigService *n = factory->CreateConfigService();
NamingService *namingSvc = factory->CreateNamingService();
......
```
### 启动SPAS鉴权
```C++
using namespace nacos;
......
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
configProps[PropertyKeyConst::ACCESS_KEY] = "accessKey";
configProps[PropertyKeyConst::SECRET_KEY] = "secretKey";
NacosServiceFactory *factory = new NacosServiceFactory(configProps);
ConfigService *n = factory->CreateConfigService();
NamingService *namingSvc = factory->CreateNamingService();
......
```
# 支持的系统/编译器
| 操作系统/环境 | 编译器 | 测试版本 |
| ---- | ---- | ---- |
|MacOS Darwin 19.6.0 x86_64|Clang|Apple clang version 12.0.0 (clang-1200.0.26.2)|
|Windows 10 WSL|GCC|version 4.8.4|
|Windows 10 CYGWIN_NT-10.0 x86_64|GCC|version 10.2.0 (GCC)|
|Ubuntu1~16.04.12|GCC|version 5.4.0|
|CentOS|GCC||
|Windows|Visual C++|计划中|
# 关于Nacos
Nacos (官方网站: [http://nacos.io](http://nacos.io)) 是一个易用的动态服务发现、配置管理以及服务管理平台。它将助力您轻松建立云上原生应用和微服务。
在Nacos中,服务是一级公民. Nacos 支持几乎所有种类的服务,例如:
[Dubbo/gRPC service](https://nacos.io/en-us/docs/use-nacos-with-dubbo.html)
[Spring Cloud RESTFul service](https://nacos.io/en-us/docs/use-nacos-with-springcloud.html)
[Kubernetes service](https://nacos.io/en-us/docs/use-nacos-with-kubernetes.html).
================================================
FILE: examples/IntegratingIntoYourProject.cpp
================================================
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//Server address
INacosServiceFactory *factory = NacosFactoryFactory::getNacosFactory(props);
ResourceGuard <INacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
NacosString ss = "";
try {
ss = n->getConfig("k", NULLSTR, 1000);
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << ss << endl;
return 0;
}
================================================
FILE: examples/generate_examples.sh
================================================
#!/bin/bash
g++ -I/usr/local/include/nacos/ IntegratingIntoYourProject.cpp -lnacos-cli -o IntegratingIntoYourProject.out
g++ -I/usr/local/include/nacos/ getAllInstances.cpp -lnacos-cli -o getAllInstances.out
g++ -I/usr/local/include/nacos/ getConfig.cpp -lnacos-cli -o getConfig.out
g++ -I/usr/local/include/nacos/ listenToKeys.cpp -lnacos-cli -o listenToKeys.out
g++ -I/usr/local/include/nacos/ registerInstances.cpp -lnacos-cli -o registerInstances.out
g++ -I/usr/local/include/nacos/ setConfig.cpp -lnacos-cli -o setConfig.out
g++ -I/usr/local/include/nacos/ subscribeServices.cpp -lnacos-cli -o subscribeServices.out
================================================
FILE: examples/getAllInstances.cpp
================================================
#include <iostream>
#include <list>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties configProps;
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
INacosServiceFactory *factory = NacosFactoryFactory::getNacosFactory(configProps);
ResourceGuard <INacosServiceFactory> _guardFactory(factory);
NamingService *namingSvc = factory->CreateNamingService();
ResourceGuard <NamingService> _guardService(namingSvc);
list <Instance> instances = namingSvc->getAllInstances("TestNamingService1");
cout << "getAllInstances from server:" << endl;
for (list<Instance>::iterator it = instances.begin();
it != instances.end(); it++) {
cout << "Instance:" << it->toString() << endl;
}
return 0;
}
================================================
FILE: examples/getConfig.cpp
================================================
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//Server address
INacosServiceFactory *factory = NacosFactoryFactory::getNacosFactory(props);
ResourceGuard <INacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
NacosString ss = "";
try {
ss = n->getConfig("k", NULLSTR, 1000);
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << ss << endl;
return 0;
}
================================================
FILE: examples/listenToKeys.cpp
================================================
#include <iostream>
#include "Nacos.h"
#include <stdio.h>
using namespace std;
using namespace nacos;
class MyListener : public Listener {
private:
int num;
public:
MyListener(int num) {
this->num = num;
}
void receiveConfigInfo(const NacosString &configInfo) {
cout << "===================================" << endl;
cout << "Watcher" << num << endl;
cout << "Watched Key UPDATED:" << configInfo << endl;
cout << "===================================" << endl;
}
};
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";
INacosServiceFactory *factory = NacosFactoryFactory::getNacosFactory(props);
ResourceGuard <INacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
MyListener *theListener = new MyListener(1);//You don't need to free it, since it will be deleted by the function removeListener
n->addListener("dqid", NULLSTR, theListener);//All changes on the key dqid will be received by MyListener
cout << "Input a character to continue" << endl;
getchar();
cout << "remove listener" << endl;
n->removeListener("dqid", NULLSTR, theListener);//Cancel listening
getchar();
return 0;
}
================================================
FILE: examples/registerInstances.cpp
================================================
#include <iostream>
#include <unistd.h>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties configProps;
configProps[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1";
INacosServiceFactory *factory = NacosFactoryFactory::getNacosFactory(configProps);
ResourceGuard <INacosServiceFactory> _guardFactory(factory);
NamingService *namingSvc = factory->CreateNamingService();
ResourceGuard <NamingService> _serviceFactory(namingSvc);
Instance instance;
instance.clusterName = "DefaultCluster";
instance.ip = "127.0.0.1";
instance.port = 2333;
instance.instanceId = "1";
instance.ephemeral = true;
//Registers 5 services named TestNamingService1...5
try {
for (int i = 0; i < 5; i++) {
NacosString serviceName = "TestNamingService" + NacosStringOps::valueOf(i);
instance.port = 2000 + i;
namingSvc->registerInstance(serviceName, instance);
}
}
catch (NacosException &e) {
cout << "encounter exception while registering service instance, raison:" << e.what() << endl;
return -1;
}
sleep(30);
try {
for (int i = 0; i < 5; i++) {
NacosString serviceName = "TestNamingService" + NacosStringOps::valueOf(i);
namingSvc->deregisterInstance(serviceName, "127.0.0.1", 2000 + i);
sleep(1);
}
}
catch (NacosException &e) {
cout << "encounter exception while registering service instance, raison:" << e.what() << endl;
return -1;
}
sleep(30);
return 0;
}
================================================
FILE: examples/setConfig.cpp
================================================
#include <iostream>
#include "Nacos.h"
using namespace std;
using namespace nacos;
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";//server address
INacosServiceFactory *factory = NacosFactoryFactory::getNacosFactory(props);
ResourceGuard <INacosServiceFactory> _guardFactory(factory);
ConfigService *n = factory->CreateConfigService();
ResourceGuard <ConfigService> _serviceFactory(n);
bool bSucc = false;
NacosString ss = "";
try {
bSucc = n->publishConfig("Cfg_key", NULLSTR, "Cfg_val");
int retry = 0;
ss = n->getConfig("Cfg_key", NULLSTR, 1000);
while (!(ss == "Cfg_val") && retry++ < 10) {
ss = n->getConfig("Cfg_key", NULLSTR, 1000);
}
if (!(ss == "Cfg_val")) {
throw NacosException(0, "getConfig() failed.");
}
}
catch (NacosException &e) {
cout <<
"Request failed with curl code:" << e.errorcode() << endl <<
"Reason:" << e.what() << endl;
return -1;
}
cout << "Publishing Key:Cfg_key with value:Cfg_val result:" << bSucc << endl;
return 0;
}
================================================
FILE: examples/subscribeServices.cpp
================================================
#include <iostream>
#include "Nacos.h"
#include <stdio.h>
using namespace std;
using namespace nacos;
class MyServiceListener : public EventListener {
private:
int num;
public:
MyServiceListener(int num) {
this->num = num;
}
void receiveNamingInfo(const ServiceInfo &serviceInfo){
cout << "===================================" << endl;
cout << "Watcher: " << num << endl;
cout << "Watched service UPDATED: " << serviceInfo.toInstanceString() << endl;
cout << "===================================" << endl;
}
};
int main() {
Properties props;
props[PropertyKeyConst::SERVER_ADDR] = "127.0.0.1:8848";
//Interval for poller to check the status of subscribed services(unit:Ms), 30000 by default
//Here we set it to 5000 to see the output more quick
props[PropertyKeyConst::SUBSCRIPTION_POLL_INTERVAL] = "5000";
INacosServiceFactory *factory = NacosFactoryFactory::getNacosFactory(props);
ResourceGuard <INacosServiceFactory> _guardFactory(factory);
NamingService *n = factory->CreateNamingService();
ResourceGuard <NamingService> _serviceFactory(n);
n->subscribe("ss", new MyServiceListener(1));
cout << "Press any key to register services" << endl;
getchar();
n->registerInstance("ss", "127.0.0.1", 33);
n->registerInstance("ss", "127.0.0.1", 34);
cout << "Press any key to deregister services" << endl;
getchar();
n->deregisterInstance("ss", "127.0.0.1", 33);
n->deregisterInstance("ss", "127.0.0.1", 34);
cout << "All instances Unregistered, press any key to finish testing" << endl;
getchar();
return 0;
}
================================================
FILE: include/Compatibility.h
================================================
//
// Created by liuhanyu on 2021/4/7.
// Compatibility header
#ifndef NACOS_SDK_CPP_COMPATIBILITY_H
#define NACOS_SDK_CPP_COMPATIBILITY_H
#if __cplusplus >= 201402L
//C++ 17 compatibility
#define NACOS_THROW(...)
#define NACOS_NOTHROW() noexcept
#else
#define NACOS_THROW throw
#define NACOS_NOTHROW throw
#endif
#endif //NACOS_SDK_CPP_COMPATIBILITY_H
================================================
FILE: include/Nacos.h
================================================
/*
* Copyright 1999-2020 Alibaba Group Holding Ltd.
*
* Licensed 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.
*/
#ifndef _NACOS_H_
#define _NACOS_H_
#include "factory/INacosServiceFactory.h"
#include "factory/NacosFactoryFactory.h"
#include "constant/PropertyKeyConst.h"
#include "ResourceGuard.h"
#endif
================================================
FILE: include/NacosExceptions.h
================================================
#ifndef __NACOS_EXCEPTIONS_H_
#define __NACOS_EXCEPTIONS_H_
#include <exception>
#include "NacosString.h"
#include "Compatibility.h"
namespace nacos{
class NacosException : public std::exception {
protected:
int _errcode;
NacosString _errmsg;
public:
NacosException(int errorcode, const char *errormsg) NACOS_NOTHROW();
NacosException(int errorcode, const NacosString &errormsg) NACOS_NOTHROW();
~NacosException() NACOS_NOTHROW() {};
const char *what() const NACOS_NOTHROW() { return _errmsg.c_str(); };
const int errorcode() const NACOS_NOTHROW() { return _errcode; };
static const int CLIENT_INVALID_PARAM = -400;
/**
* over client threshold(超过server端的限流阈值)
*/
static const int CLIENT_OVER_THRESHOLD = -503;
/**
* server error code
* 400 403 throw exception to user
* 500 502 503 change ip and retry
*/
/**
* invalid param(参数错误)
*/
static const int INVALID_PARAM = 400;
/**
* no right(鉴权失败)
*/
static const int NO_RIGHT = 403;
static const int HTTP_NOT_FOUND = 404;
/**
* conflict(写并发冲突)
*/
static const int CONFLICT = 409;
/**
* server error(server异常,如超时)
*/
static const int SERVER_ERROR = 500;
/**
* bad gateway(路由异常,如nginx后面的Server挂掉)
*/
static const int BAD_GATEWAY = 502;
/**
* over threshold(超过server端的限流阈值)
*/
static const int OVER_THRESHOLD = 503;
/**
* Error while parsing the JSON string
*/
static const int INVALID_JSON_FORMAT = 100001;
/**
* One or more JSON field is missing
*/
static const int LACK_JSON_FIELD = 100002;
static const int MALFORMED_CONFIG_FILE = 1001;
static const int FILE_NOT_FOUND = 1002;
static const int INVALID_FACTORY_CONFIG = 1003;
static const int ALL_SERVERS_TRIED_AND_FAILED = 1004;
static const int NO_SERVER_AVAILABLE = 1005;
static const int INVALID_LOGIN_CREDENTIAL = 1006;
static const int UNABLE_TO_OPEN_FILE = 1007;
static const int UNABLE_TO_GET_HOST_IP = 1008;
static const int UNABLE_TO_CREATE_SOCKET = 1009;
static const int INVALID_CONFIG_PARAM = 1010;
static const int UNABLE_TO_GET_HOST_NAME = 1011;
};
class NetworkException : public std::exception {
private:
int _curlerrcode;
NacosString _errmsg;
public:
NetworkException(int errorcode, const char *errormsg) NACOS_NOTHROW(): _curlerrcode(errorcode), _errmsg(errormsg) {};
NetworkException(int errorcode, const NacosString &errormsg) NACOS_NOTHROW(): _curlerrcode(errorcode), _errmsg(errormsg) {};
~NetworkException() NACOS_NOTHROW() {};
const char *what() const NACOS_NOTHROW() { return _errmsg.c_str(); };
const int errorcode() const NACOS_NOTHROW() { return _curlerrcode; };
};
class IOException : public NacosException {
public:
IOException(int errorcode, const char *errormsg) NACOS_NOTHROW() : NacosException(errorcode, errormsg) {};
IOException(int errorcode, const NacosString &errormsg) NACOS_NOTHROW() : NacosException(errorcode, errormsg) {};
~IOException() NACOS_NOTHROW() {};
};
class MalformedConfigException : public NacosException {
public:
MalformedConfigException(const NacosString &file, const NacosString &detailedMsg) : NacosException(NacosException::MALFORMED_CONFIG_FILE,
"Malformed Config file:" + file + " reason:" + detailedMsg) {};
};
class InvalidFactoryConfigException : public NacosException {
public:
InvalidFactoryConfigException() : NacosException(NacosException::INVALID_FACTORY_CONFIG,
"Either config file or property should be configed.") {};
};
}//namespace nacos
#endif
================================================
FILE: include/NacosString.h
================================================
#ifndef __NACOS_STRING_H_
#define __NACOS_STRING_H_
#include <string>
#include <sstream>
#define NacosString std::string
#define NULLSTR NacosStringOps::nullstr
#define isNull NacosStringOps::isNullStr
namespace nacos{
class NacosStringOps {
public:
static const NacosString nullstr;
static bool isNullStr(const NacosString &str);
template<typename T>
static NacosString valueOf(T val);
static const NacosString STR_TRUE;
static const NacosString STR_FALSE;
};
template<typename T>
NacosString NacosStringOps::valueOf(T val) {
std::ostringstream os;
if (os << val) {
return NacosString(os.str().c_str());
}
return NULLSTR;
}
template<>
NacosString NacosStringOps::valueOf<bool>(bool val);
}//namespace nacos
#endif
================================================
FILE: include/Properties.h
================================================
#ifndef __PROPERTIES_H_
#define __PROPERTIES_H_
#include <map>
#include "NacosString.h"
namespace nacos{
class Properties : public std::map<NacosString, NacosString> {
public:
NacosString toString() const {
NacosString content = "";
for (std::map<NacosString, NacosString>::const_iterator it = begin(); it != end(); it++) {
content += (it->first + "=" + it->second + "\n");
}
return content;
}
bool contains(const NacosString &key) const {
if (count(key) > 0) {
return true;
}
return false;
}
};
}//namespace nacos
#endif
================================================
FILE: include/ResourceGuard.h
================================================
//
// Created by liuhanyu on 2020/9/6.
//
#ifndef NACOS_SDK_CPP_RESOURCEGUARD_H
#define NACOS_SDK_CPP_RESOURCEGUARD_H
namespace nacos{
template<typename T>
class ResourceGuard {
private:
T *_obj;//The object being watched
ResourceGuard();
public:
ResourceGuard(T *obj) { _obj = obj; };
~ResourceGuard() {
if (_obj != NULL) {
delete _obj;
_obj = NULL;
}
};
};
}//namespace nacos
#endif //NACOS_SDK_CPP_RESOURCEGUARD_H
================================================
FILE: include/config/ConfigService.h
================================================
#ifndef __CFG_SVC_H_
#define __CFG_SVC_H_
#include "NacosExceptions.h"
#include "NacosString.h"
#include "listen/Listener.h"
#include "Compatibility.h"
namespace nacos{
class ConfigService {
public:
/**
* Get config
*
* @param dataId dataId
* @param group group
* @param timeoutMs read timeout
* @return config value
* @throws NacosException NacosException
*/
virtual NacosString
getConfig(const NacosString &dataId, const NacosString &group, long timeoutMs) NACOS_THROW(NacosException) = 0;
/**
* Add a listener to the configuration, after the server modified the
* configuration, the client will use the incoming listener callback.
* Recommended asynchronous processing, the application can implement the
* getExecutor method in the ManagerListener, provide a thread pool of
* execution. If provided, use the main thread callback, May block other
* configurations or be blocked by other configurations.
*
* @param dataId dataId
* @param group group
* @param listener listener
* @throws NacosException NacosException
*/
virtual void
addListener(const NacosString &dataId, const NacosString &group, Listener *listener) NACOS_THROW(NacosException) = 0;
/**
* Publish config.
*
* @param dataId dataId
* @param group group
* @param content content
* @return Whether publish
* @throws NacosException NacosException
*/
virtual bool publishConfig(const NacosString &dataId, const NacosString &group,
const NacosString &content) NACOS_THROW(NacosException) = 0;
/**
* Remove config
*
* @param dataId dataId
* @param group group
* @return whether remove
* @throws NacosException NacosException
*/
virtual bool removeConfig(const NacosString &dataId, const NacosString &group) NACOS_THROW(NacosException) = 0;
/**
* Remove listener
*
* @param listener listener
*/
virtual void removeListener(const NacosString &dataId, const NacosString &group, Listener *listener) = 0;
/**
* Get server status
*
* @return whether health
*/
//virtual NacosString getServerStatus() = 0;
virtual ~ConfigService() {};
};
}//namespace nacos
#endif
================================================
FILE: include/constant/ConfigConstant.h
================================================
#ifndef __CONFIG_CONSTANTS_H_
#define __CONFIG_CONSTANTS_H_
#include "NacosString.h"
/**
* Constant
*
* @author Nacos
*/
namespace nacos{
//Constants for config service
class ConfigConstant {
public:
const static NacosString DEFAULT_GROUP;
const static NacosString DEFAULT_CONTEXT_PATH;
const static NacosString PROTOCOL_VERSION;
const static NacosString GET_SERVERS_PATH;
const static NacosString DATAID;
const static NacosString PROBE_MODIFY_REQUEST;
const static NacosString PROBE_MODIFY_RESPONSE;
const static NacosString BASE_PATH;
const static NacosString CONFIG_CONTROLLER_PATH;
/**
* second
*/
const static int POLLING_INTERVAL_TIME;
const static NacosString ENCODE;
const static int FLOW_CONTROL_THRESHOLD;
const static NacosString LINE_SEPARATOR;
const static NacosString WORD_SEPARATOR;
const static NacosString NAMING_INSTANCE_ID_SPLITTER;
const static NacosString DEFAULT_CLUSTER_NAME;
const static NacosString SERVICE_INFO_SPLITER;
const static NacosString FILE_SEPARATOR;
const static NacosString CONFIG_NEXT_LINE;
const static NacosString CONFIG_KV_SEPARATOR;
const static NacosString DEFAULT_CONFIG_FILE;
};
}//namespace nacos
#endif
================================================
FILE: include/constant/NamingConstant.h
================================================
#ifndef __NAMING_CONSTANT_H_
#define __NAMING_CONSTANT_H_
#include "NacosString.h"
namespace nacos{
class NamingConstant {
public:
static const NacosString SERVICE_NAME;
static const NacosString CLUSTER_NAME;
static const NacosString UDP_PORT;
static const NacosString CLUSTERS;
static const NacosString CLIENT_IP;
static const NacosString HEALTHY_ONLY;
static const NacosString HEALTHY;
static const NacosString NAMESPACE_ID;
static const NacosString GROUP_NAME;
static const NacosString SPLITER;
static const NacosString EMPTY;
static const NacosString ALL_IPS;
static const NacosString BEAT;
static const NacosString PAGE_SIZE;
static const NacosString PAGE_NO;
};
}//namespace nacos
#endif
================================================
FILE: include/constant/PropertyKeyConst.h
================================================
#ifndef __PROP_KEY_CONST_H_
#define __PROP_KEY_CONST_H_
#include "NacosString.h"
namespace nacos{
class PropertyKeyConst {
public:
static const NacosString IS_USE_ENDPOINT_PARSING_RULE;
static const NacosString ENDPOINT;
static const NacosString ENDPOINT_PORT;
static const NacosString NAMESPACE;
static const NacosString ENDPOINT_QUERY_PARAMS;
static const NacosString ACCESS_KEY;
static const NacosString SECRET_KEY;
static const NacosString APP_NAME;
static const NacosString RAM_ROLE_NAME;
static const NacosString SERVER_ADDR;
static const NacosString CONTEXT_PATH;
static const NacosString ENDPOINT_CONTEXT_PATH;
static const NacosString CLUSTER_NAME;
static const NacosString ENCODE;
static const NacosString NAMING_LOAD_CACHE_AT_START;
static const NacosString NAMING_CLIENT_BEAT_THREAD_COUNT;
static const NacosString NAMING_POLLING_THREAD_COUNT;
static const NacosString SRVLISTMGR_REFRESH_INTERVAL;
static const NacosString SERVER_REQ_TIMEOUT;
static const NacosString SUBSCRIPTION_POLL_INTERVAL;
static const NacosString CONFIG_LONGPULLLING_TIMEOUT;
static const NacosString HB_FAIL_WAIT_TIME;
static const NacosString NACOS_SNAPSHOT_PATH;
static const NacosString LOG_PATH;
static const NacosString LOG_ROTATE_SIZE;
static const NacosString LOG_LEVEL;
static const NacosString CLIENT_NAME;
static const NacosString AUTH_USERNAME;
static const NacosString AUTH_PASSWORD;
static const NacosString LOCAL_IP;
static const NacosString UDP_RECEIVER_PORT;
static const int NACOS_DEFAULT_PORT = 8848;
static const NacosString INSTANCE_ID_SEQ_FILE;
static const NacosString INSTANCE_ID_PREFIX;
/*public static class SystemEnv {
static const NacosString ALIBABA_ALIWARE_ENDPOINT_PORT = "ALIBABA_ALIWARE_ENDPOINT_PORT";
static const NacosString ALIBABA_ALIWARE_NAMESPACE = "ALIBABA_ALIWARE_NAMESPACE";
static const NacosString ALIBABA_ALIWARE_ENDPOINT_URL = "ALIBABA_ALIWARE_ENDPOINT_URL";
}*/
};
}//namespace nacos
#endif
================================================
FILE: include/constant/UtilAndComs.h
================================================
#ifndef __UTIL_N_COMS_H_
#define __UTIL_N_COMS_H_
#include "NacosString.h"
namespace nacos{
class UtilAndComs {
public:
static NacosString VERSION;
static NacosString ENCODING;
static NacosString NACOS_URL_BASE;
static NacosString NACOS_URL_INSTANCE;
static int REQUEST_DOMAIN_RETRY_COUNT;
static NacosString SERVER_ADDR_IP_SPLITER;
static int DEFAULT_CLIENT_BEAT_THREAD_COUNT;//TODO:Calc this according to nr_processors of the host
static int DEFAULT_POLLING_THREAD_COUNT;//TODO:Calc this according to nr_processors of the host
static void Init();
};
}//namespace nacos
#endif
================================================
FILE: include/factory/INacosServiceFactory.h
================================================
//
// Created by liuhanyu on 2020/8/30.
//
#ifndef NACOS_SDK_CPP_INACOSSERVICEFACTORY_H
#define NACOS_SDK_CPP_INACOSSERVICEFACTORY_H
#include "naming/NamingService.h"
#include "naming/NamingMaintainService.h"
#include "config/ConfigService.h"
#include "Properties.h"
namespace nacos{
class INacosServiceFactory {
public:
virtual void setConfig(const NacosString &_configFile) = 0;
virtual void setProps(Properties &_props) = 0;
virtual NamingService *CreateNamingService() = 0;
virtual ConfigService *CreateConfigService() = 0;
virtual NamingMaintainService *CreateNamingMaintainService() = 0;
virtual ~INacosServiceFactory() {};
};
}//namespace nacos
#endif //NACOS_SDK_CPP_INACOSSERVICEFACTORY_H
================================================
FILE: include/factory/NacosFactoryFactory.h
================================================
#ifndef NACOS_FACTORY_FACTORY_H
#define NACOS_FACTORY_FACTORY_H
#include "factory/INacosServiceFactory.h"
namespace nacos {
class NacosFactoryFactory {
public:
static INacosServiceFactory *getNacosFactory(const NacosString &_configFile);
static INacosServiceFactory *getNacosFactory(Properties &_props);
};
}
#endif
================================================
FILE: include/listen/Listener.h
================================================
#ifndef __LISTENER_H_
#define __LISTENER_H_
#include "NacosString.h"
#include "thread/AtomicInt.h"
namespace nacos{
class Listener {
private:
NacosString listenerName;
AtomicInt<int> refCount;
public:
Listener() {
this->listenerName = "theListener";
};
int incRef() { return refCount.inc(); };
int decRef() { return refCount.dec(); };
int refCnt() const { return refCount.get(); };
void setListenerName(const NacosString &name) { this->listenerName = name; };
NacosString getListenerName() const { return listenerName; };
virtual void receiveConfigInfo(const NacosString &configInfo) = 0;
virtual ~Listener() {};
};
}//namespace nacos
#endif
================================================
FILE: include/naming/ChangeAdvice.h
================================================
#ifndef __CHG_ADVICE_H_
#define __CHG_ADVICE_H_
#include "NacosString.h"
#include "naming/ServiceInfo.h"
//The wrapper class for service change information
namespace nacos{
class ChangeAdvice {
public:
bool added;//indicates Instance is added
bool removed;//indicates Instance is removed
bool modified;//indicates Instance is modified
//std::list<Instance> addedInstances;
//std::list<Instance> removedInstances;
//std::list<Instance> modifiedInstances;
//ServiceInfo oldServiceInfo;
ServiceInfo newServiceInfo;
NacosString key;
public:
ChangeAdvice();
~ChangeAdvice();
static void compareChange(ServiceInfo &oldInfo, ServiceInfo &newInfo, ChangeAdvice &changeAdvice);
NacosString toString();
};
}//namespace nacos
#endif
================================================
FILE: include/naming/Cluster.h
================================================
#ifndef __CLUSTER_H_
#define __CLUSTER_H_
#include <map>
#include "NacosString.h"
namespace nacos{
class HealthChecker {
private:
NacosString type;
public:
NacosString getType() const { return type; };
void setType(const NacosString &_type) { type = _type; };
};
class Cluster {
private:
NacosString name;
HealthChecker healthChecker;
std::map<NacosString, NacosString> metadata;
public:
NacosString getName() const;
void setName(const NacosString &name);
HealthChecker getHealthChecker() const;
void setHealthChecker(const HealthChecker &healthChecker);
std::map<NacosString, NacosString> getMetadata() const;
void setMetadata(const std::map<NacosString, NacosString> &metadata);
};
}//namespace nacos
#endif
================================================
FILE: include/naming/Instance.h
================================================
#ifndef __INSTANCE_H_
#define __INSTANCE_H_
#include <map>
#include "NacosString.h"
namespace nacos{
//a service instance
class Instance {
public:
Instance & operator = (const Instance &rhs);
bool operator == (const Instance &rhs) const;
bool operator != (const Instance &rhs) const;
Instance();
/**
* unique id of this instance.
*/
NacosString instanceId;
/**
* instance ip
*/
NacosString ip;
/**
* instance port
*/
int port;
/**
* instance weight
*/
double weight;
/**
* instance health status
*/
bool healthy;
/**
* If instance is enabled to accept request
*/
bool enabled;
/**
* If instance is ephemeral
*
* @since 1.0.0
*/
bool ephemeral;
/**
* cluster information of instance
*/
NacosString clusterName;
/**
* Service information of instance
*/
NacosString serviceName;
NacosString groupName;
NacosString namespaceId;
/**
* user extended attributes
*/
std::map <NacosString, NacosString> metadata;
NacosString toString() const;
NacosString toInetAddr();
};
}//namespace nacos
#endif
================================================
FILE: include/naming/ListView.h
================================================
#ifndef __NACOS_LIST_VUE_H_
#define __NACOS_LIST_VUE_H_
#include <list>
#include "NacosString.h"
namespace nacos{
template <typename T>
class ListView{
private:
int count;
std::list<T> data;
public:
ListView() { count = 0; };
int getCount() const { return count; };
std::list<T> getData() const { return data; };
void setCount(int _count) { count = _count; };
void setData(const std::list<T> &_data) { data = _data; };
};
}//namespace nacos
#endif
================================================
FILE: include/naming/NamingMaintainService.h
================================================
#ifndef __NAM_MAINTN_SVC_H_
#define __NAM_MAINTN_SVC_H_
#include <list>
#include "naming/Instance.h"
#include "naming/ServiceInfo2.h"
#include "NacosString.h"
#include "NacosExceptions.h"
#include "ListView.h"
#include "Compatibility.h"
namespace nacos{
class NamingMaintainService {
public:
virtual bool updateInstance(const NacosString &serviceName, const NacosString & groupName, const Instance &instance) NACOS_THROW(NacosException) = 0;
virtual ServiceInfo2 queryService(const NacosString &serviceName, const NacosString &groupName) NACOS_THROW(NacosException) = 0;
virtual bool createService(const ServiceInfo2 &service, naming::Selector *selector) NACOS_THROW(NacosException) = 0;
virtual bool deleteService(const NacosString &serviceName, const NacosString &groupName) NACOS_THROW(NacosException) = 0;
virtual bool updateService(const ServiceInfo2 &service, naming::Selector *selector) NACOS_THROW(NacosException) = 0;
virtual ~NamingMaintainService() {};
};
}//namespace nacos
#endif
================================================
FILE: include/naming/NamingService.h
================================================
#ifndef __NAM_SVC_H_
#define __NAM_SVC_H_
#include <list>
#include "naming/Instance.h"
#include "naming/selectors/Selector.h"
#include "naming/subscribe/EventListener.h"
#include "NacosString.h"
#include "NacosExceptions.h"
#include "ListView.h"
#include "Compatibility.h"
namespace nacos{
class NamingService {
public:
/**
* register a instance to service
*
* @param serviceName name of service
* @param ip instance ip
* @param port instance port
* @throw (NacosException) = 0
*/
virtual void
registerInstance(const NacosString &serviceName, const NacosString &ip, int port) NACOS_THROW(NacosException) = 0;
/**
* register a instance to service
*
* @param serviceName name of service
* @param groupName group of service
* @param ip instance ip
* @param port instance port
* @throw (NacosException) = 0
*/
virtual void registerInstance(const NacosString &serviceName, const NacosString &groupName, const NacosString &ip,
int port) NACOS_THROW(NacosException) = 0;
/**
* register a instance to service with specified cluster name
*
* @param serviceName name of service
* @param ip instance ip
* @param port instance port
* @param clusterName instance cluster name
* @throw (NacosException) = 0
*/
virtual void registerInstance(const NacosString &serviceName, const NacosString &ip, int port,
const NacosString &clusterName) NACOS_THROW(NacosException) = 0;
/**
* register a instance to service with specified cluster name
*
* @param serviceName name of service
* @param groupName group of service
* @param ip instance ip
* @param port instance port
* @param clusterName instance cluster name
* @throw (NacosException) = 0
*/
virtual void
registerInstance(const NacosString &serviceName, const NacosString &groupName, const NacosString &ip, int port,
const NacosString &clusterName) NACOS_THROW(NacosException) = 0;
/**
* register a instance to service with specified instance properties
*
* @param serviceName name of service
* @param instance instance to register
* @throw (NacosException) = 0
*/
virtual void registerInstance(const NacosString &serviceName, Instance &instance) NACOS_THROW(NacosException) = 0;
/**
* register a instance to service with specified instance properties
*
* @param serviceName name of service
* @param groupName group of service
* @param instance instance to register
* @throw (NacosException) = 0
*/
virtual void registerInstance(const NacosString &serviceName, const NacosString &groupName,
Instance &instance) NACOS_THROW(NacosException) = 0;
/**
* deregister instance from a service
*
* @param serviceName name of service
* @param ip instance ip
* @param port instance port
* @throw (NacosException) = 0
*/
virtual void
deregisterInstance(const NacosString &serviceName, const NacosString &ip, int port) NACOS_THROW(NacosException) = 0;
/**
* deregister instance from a service
*
* @param serviceName name of service
* @param groupName group of service
* @param ip instance ip
* @param port instance port
* @throw (NacosException) = 0
*/
virtual void deregisterInstance(const NacosString &serviceName, const NacosString &groupName, const NacosString &ip,
int port) NACOS_THROW(NacosException) = 0;
/**
* deregister instance with specified cluster name from a service
*
* @param serviceName name of service
* @param ip instance ip
* @param port instance port
* @param clusterName instance cluster name
* @throw (NacosException) = 0
*/
virtual void deregisterInstance(const NacosString &serviceName, const NacosString &ip, int port,
const NacosString &clusterName) NACOS_THROW(NacosException) = 0;
/**
* deregister instance with specified cluster name from a service
*
* @param serviceName name of service
* @param groupName group of service
* @param ip instance ip
* @param port instance port
* @param clusterName instance cluster name
* @throw (NacosException) = 0
*/
virtual void
deregisterInstance(const NacosString &serviceName, const NacosString &groupName, const NacosString &ip, int port,
const NacosString &clusterName) NACOS_THROW(NacosException) = 0;
/**
* deregister instance with full instance information
*
* @param serviceName name of service
* @param groupName group of service
* @param instance instance information
* @throw (NacosException) = 0
*/
virtual void deregisterInstance(const NacosString &serviceName, const NacosString &groupName,
Instance &instance) NACOS_THROW(NacosException) = 0;
/**
* get all instances of a service
*
* @param serviceName name of service
* @return A list of instance
* @throw (NacosException) = 0
*/
virtual std::list <Instance> getAllInstances(const NacosString &serviceName) NACOS_THROW(NacosException) = 0;
/**
* get all instances of a service
*
* @param serviceName name of service
* @param groupName group of service
* @return A list of instance
* @throw (NacosException) = 0
*/
virtual std::list <Instance>
getAllInstances(const NacosString &serviceName, const NacosString &groupName) NACOS_THROW(NacosException) = 0;
/**
* Get all instances within specified clusters of a service
*
* @param serviceName name of service
* @param clusters list of cluster
* @return A list of qualified instance
* @throw (NacosException) = 0
*/
virtual std::list <Instance>
getAllInstances(const NacosString &serviceName, const std::list <NacosString> &clusters) NACOS_THROW(NacosException) = 0;
/**
* Get all instances within specified clusters of a service
*
* @param serviceName name of service
* @param groupName group of service
* @param clusters list of cluster
* @return A list of qualified instance
* @throw (NacosException) = 0
*/
virtual std::list <Instance> getAllInstances(const NacosString &serviceName, const NacosString &groupName,
const std::list <NacosString> &clusters) NACOS_THROW(NacosException) = 0;
/**
* Get instances with the predicate specified
*
* @param serviceName name of service
* @param groupName group of service
* @param clusters list of cluster
* @param predicate predicate to filter instances
* @return A list of qualified instance
* @throw (NacosException) = 0
*/
virtual std::list<Instance> getInstanceWithPredicate(const NacosString &serviceName, const NacosString &groupName,
const std::list <NacosString> &clusters,
nacos::naming::selectors::Selector<Instance> *predicate) NACOS_THROW(NacosException) = 0;
/**
* Get instances with the predicate specified
*
* @param serviceName name of service
* @param clusters list of cluster
* @param predicate predicate to filter instances
* @return A list of qualified instance
* @throw (NacosException) = 0
*/
virtual std::list<Instance> getInstanceWithPredicate(const NacosString &serviceName,
const std::list <NacosString> &clusters,
nacos::naming::selectors::Selector<Instance> *predicate) NACOS_THROW(NacosException) = 0;
/**
* Get instances with the predicate specified
*
* @param serviceName name of service
* @param groupName group of service
* @param predicate predicate to filter instances
* @return A list of qualified instance
* @throw (NacosException) = 0
*/
virtual std::list<Instance> getInstanceWithPredicate(const NacosString &serviceName, const NacosString &groupName,
nacos::naming::selectors::Selector<Instance> *predicate) NACOS_THROW(NacosException) = 0;
/**
* Get instances with the predicate specified
*
* @param serviceName name of service
* @param predicate predicate to filter instances
* @return A list of qualified instance
* @throw (NacosException) = 0
*/
virtual std::list<Instance> getInstanceWithPredicate(const NacosString &serviceName, nacos::naming::selectors::Selector<Instance> *predicate) NACOS_THROW(NacosException) = 0;
/**
* Get qualified instances of service
*
* @param serviceName name of service
* @param healthy a flag to indicate returning healthy or unhealthy instances
* @return A qualified list of instance
* @throw (NacosException) = 0
*/
//virtual std::list<Instance> selectInstances(const NacosString &serviceName, bool healthy) throw (NacosException) = 0;
/**
* Get qualified instances of service
*
* @param serviceName name of service
* @param groupName group of service
* @param healthy a flag to indicate returning healthy or unhealthy instances
* @return A qualified list of instance
* @throw (NacosException) = 0
*/
//virtual std::list<Instance> selectInstances(const NacosString &serviceName, const NacosString &groupName, bool healthy) throw (NacosException) = 0;
/**
* Get qualified instances of service
*
* @param serviceName name of service
* @param healthy a flag to indicate returning healthy or unhealthy instances
* @param subscribe if subscribe the service
* @return A qualified list of instance
* @throw (NacosException) = 0
*/
//virtual std::list<Instance> selectInstances(const NacosString &serviceName, bool healthy, bool subscribe) throw (NacosException) = 0;
/**
* Get qualified instances of service
*
* @param serviceName name of service
* @param groupName group of service
* @param healthy a flag to indicate returning healthy or unhealthy instances
* @param subscribe if subscribe the service
* @return A qualified list of instance
* @throw (NacosException) = 0
*/
//virtual std::list<Instance> selectInstances(const NacosString &serviceName, const NacosString &groupName, bool healthy, bool subscribe) throw (NacosException) = 0;
/**
* Get qualified instances within specified clusters of service
*
* @param serviceName name of service
* @param clusters list of cluster
* @param healthy a flag to indicate returning healthy or unhealthy instances
* @return A qualified list of instance
* @throw (NacosException) = 0
*/
//virtual std::list<Instance> selectInstances(const NacosString &serviceName, std::list<NacosString> clusters, bool healthy) throw (NacosException) = 0;
/**
* Get qualified instances within specified clusters of service
*
* @param serviceName name of service
* @param groupName group of service
* @param clusters list of cluster
* @param healthy a flag to indicate returning healthy or unhealthy instances
* @return A qualified list of instance
* @throw (NacosException) = 0
*/
//virtual std::list<Instance> selectInstances(const NacosString &serviceName, const NacosString &groupName, std::list<NacosString> clusters, bool healthy) throw (NacosException) = 0;
/**
* Get qualified instances within specified clusters of service
*
* @param serviceName name of service
* @param clusters list of cluster
* @param healthy a flag to indicate returning healthy or unhealthy instances
* @param subscribe if subscribe the service
* @return A qualified list of instance
* @throw (NacosException) = 0
*/
//virtual std::list<Instance> selectInstances(const NacosString &serviceName, std::list<NacosString> clusters, bool healthy, bool subscribe) throw (NacosException) = 0;
/**
* Get qualified instances within specified clusters of service
*
* @param serviceName name of service
* @param groupName group of service
* @param clusters list of cluster
* @param healthy a flag to indicate returning healthy or unhealthy instances
* @param subscribe if subscribe the service
* @return A qualified list of instance
* @throw (NacosException) = 0
*/
//virtual std::list<Instance> selectInstances(const NacosString &serviceName, const NacosString &groupName, std::list<NacosString> clusters, bool healthy, bool subscribe) throw (NacosException) = 0;
/**
* Select one healthy instance of service using predefined load balance strategy
*
* @param serviceName name of service
* @return qualified instance
* @throw (NacosException) = 0
*/
//virtual Instance selectOneHealthyInstance(const NacosString &serviceName) throw (NacosException) = 0;
/**
* Select one healthy instance of service using predefined load balance strategy
*
* @param serviceName name of service
* @param groupName group of service
* @return qualified instance
* @throw (NacosException) = 0
*/
//virtual Instance selectOneHealthyInstance(const NacosString &serviceName, const NacosString &groupName) throw (NacosException) = 0;
/**
* select one healthy instance of service using predefined load balance strategy
*
* @param serviceName name of service
* @param subscribe if subscribe the service
* @return qualified instance
* @throw (NacosException) = 0
*/
//virtual Instance selectOneHealthyInstance(const NacosString &serviceName, bool subscribe) throw (NacosException) = 0;
/**
* select one healthy instance of service using predefined load balance strategy
*
* @param serviceName name of service
* @param groupName group of service
* @param subscribe if subscribe the service
* @return qualified instance
* @throw (NacosException) = 0
*/
//virtual Instance selectOneHealthyInstance(const NacosString &serviceName, const NacosString &groupName, bool subscribe) throw (NacosException) = 0;
/**
* Select one healthy instance of service using predefined load balance strategy
*
* @param serviceName name of service
* @param clusters a list of clusters should the instance belongs to
* @return qualified instance
* @throw (NacosException) = 0
*/
//virtual Instance selectOneHealthyInstance(const NacosString &serviceName, std::list<NacosString> clusters) throw (NacosException) = 0;
/**
* Select one healthy instance of service using predefined load balance strategy
*
* @param serviceName name of service
* @param groupName group of service
* @param clusters a list of clusters should the instance belongs to
* @return qualified instance
* @throw (NacosException) = 0
*/
//virtual Instance selectOneHealthyInstance(const NacosString &serviceName, const NacosString &groupName, std::list<NacosString> clusters) throw (NacosException) = 0;
/**
* Select one healthy instance of service using predefined load balance strategy
*
* @param serviceName name of service
* @param clusters a list of clusters should the instance belongs to
* @param subscribe if subscribe the service
* @return qualified instance
* @throw (NacosException) = 0
*/
//virtual Instance selectOneHealthyInstance(const NacosString &serviceName, std::list<NacosString> clusters, bool subscribe) throw (NacosException) = 0;
/**
* Select one healthy instance of service using predefined load balance strategy
*
* @param serviceName name of service
* @param groupName group of service
* @param clusters a list of clusters should the instance belongs to
* @param subscribe if subscribe the service
* @return qualified instance
* @throw (NacosException) = 0
*/
//virtual Instance selectOneHealthyInstance(const NacosString &serviceName, const NacosString &groupName, std::list<NacosString> clusters, bool subscribe) throw (NacosException) = 0;
/**
* Subscribe service to receive events of instances alteration
*
* @param serviceName name of service
* @param listener event listener
* @throw (NacosException) = 0
*/
virtual void subscribe(const NacosString &serviceName, EventListener *listener) NACOS_THROW (NacosException) = 0;
/**
* Subscribe service to receive events of instances alteration
*
* @param serviceName name of service
* @param groupName group of service
* @param listener event listener
* @throw (NacosException) = 0
*/
virtual void subscribe(const NacosString &serviceName, const NacosString &groupName, EventListener *listener) NACOS_THROW (NacosException) = 0;
/**
* Subscribe service to receive events of instances alteration
*
* @param serviceName name of service
* @param clusters list of cluster
* @param listener event listener
* @throw (NacosException) = 0
*/
virtual void subscribe(const NacosString &serviceName, const std::list<NacosString> &clusters, EventListener *listener) NACOS_THROW (NacosException) = 0;
/**
* Subscribe service to receive events of instances alteration
*
* @param serviceName name of service
* @param groupName group of service
* @param clusters list of cluster
* @param listener event listener
* @throw (NacosException) = 0
*/
virtual void subscribe(const NacosString &serviceName, const NacosString &groupName, const std::list<NacosString> &clusters, EventListener *listener) NACOS_THROW (NacosException) = 0;
/**
* Unsubscribe event listener of service
*
* @param serviceName name of service
* @param listener event listener
* @throw (NacosException) = 0
*/
virtual void unsubscribe(const NacosString &serviceName, EventListener *listener) NACOS_THROW (NacosException) = 0;
/**
* unsubscribe event listener of service
*
* @param serviceName name of service
* @param groupName group of service
* @param listener event listener
* @throw (NacosException) = 0
*/
virtual void unsubscribe(const NacosString &serviceName, const NacosString &groupName, EventListener *listener) NACOS_THROW (NacosException) = 0;
/**
* Unsubscribe event listener of service
*
* @param serviceName name of service
* @param clusters list of cluster
* @param listener event listener
* @throw (NacosException) = 0
*/
virtual void unsubscribe(const NacosString &serviceName, const std::list<NacosString> &clusters, EventListener *listener) NACOS_THROW (NacosException) = 0;
/**
* Unsubscribe event listener of service
*
* @param serviceName name of service
* @param groupName group of service
* @param clusters list of cluster
* @param listener event listener
* @throw (NacosException) = 0
*/
virtual void unsubscribe(const NacosString &serviceName, const NacosString &groupName, const std::list<NacosString> &clusters, EventListener *listener) NACOS_THROW (NacosException) = 0;
/**
* Get all service names from server
*
* @param pageNo page index
* @param pageSize page size
* @return list of service names
* @throw (NacosException) = 0
*/
virtual ListView<NacosString> getServiceList(int pageNo, int pageSize) NACOS_THROW (NacosException) = 0;
/**
* Get all service names from server
*
* @param pageNo page index
* @param pageSize page size
* @param groupName group name
* @return list of service names
* @throw (NacosException) = 0
*/
virtual ListView<NacosString> getServiceList(int pageNo, int pageSize, const NacosString &groupName) NACOS_THROW (NacosException) = 0;
/**
* Get all service names from server with selector
*
* @param pageNo page index
* @param pageSize page size
* @param selector selector to filter the resource
* @return list of service names
* @throw (NacosException) = 0
* @since 0.7.0
*/
//virtual ListView<NacosString> getServicesOfServer(int pageNo, int pageSize, AbstractSelector selector) throw (NacosException) = 0;
/**
* Get all service names from server with selector
*
* @param pageNo page index
* @param pageSize page size
* @param groupName group name
* @param selector selector to filter the resource
* @return list of service names
* @throw (NacosException) = 0
*/
//virtual ListView<NacosString> getServicesOfServer(int pageNo, int pageSize, const NacosString &groupName, AbstractSelector selector) throw (NacosException) = 0;
/**
* Get all subscribed services of current client
*
* @return subscribed services
* @throw (NacosException) = 0
*/
//virtual std::list<ServiceInfo> getSubscribeServices() throw (NacosException) = 0;
/**
* get server health status
*
* @return is server healthy
*/
//virtual NacosString getServerStatus() = 0;
virtual ~NamingService() {};
};
}//namespace nacos
#endif
================================================
FILE: include/naming/ServiceInfo.h
================================================
#ifndef __SVC_INFO_H_
#define __SVC_INFO_H_
#include <list>
#include "NacosString.h"
#include "naming/Instance.h"
namespace nacos{
class ServiceInfo {
private:
//@JSONField(serialize = false)
NacosString _jsonFromServer;
NacosString _name;
NacosString _groupName;
NacosString _clusters;
long _cacheMillis;
//@JSONField(name = "hosts")
std::list <Instance> _hosts;
long _lastRefTime;
NacosString _checksum;
volatile bool _allIPs;
public:
ServiceInfo();
bool isAllIPs() const;
void setAllIPs(bool allIPs);
explicit ServiceInfo(const NacosString &key);
ServiceInfo(const NacosString &name, const NacosString &clusters);
int ipCount();
bool expired() const;
void setHosts(std::list <Instance> &hosts);
bool isValid();
NacosString getName();
void setName(const NacosString &name);
NacosString getGroupName();
void setGroupName(const NacosString &groupName);
void setLastRefTime(long lastRefTime);
long getLastRefTime();
NacosString getClusters();
void setClusters(const NacosString &clusters);
long getCacheMillis();
void setCacheMillis(long cacheMillis);
std::list <Instance> getHosts();
std::list <Instance> *getHostsNocopy();
bool validate() const;
//@JSONField(serialize = false)
NacosString getJsonFromServer() const;
void setJsonFromServer(const NacosString &jsonFromServer);
//@JSONField(serialize = false)
NacosString getKey() const;
//@JSONField(serialize = false)
NacosString getKeyEncoded() const;
//@JSONField(serialize = false)
static void fromKey(ServiceInfo &serviceInfo, const NacosString &key);
//@JSONField(serialize = false)
static NacosString getKey(const NacosString &name, const NacosString &clusters);
//@Override
NacosString toString() const;
//!!BE CAREFUL!!
//This function is very expensive!! call it with care!
NacosString toInstanceString() const;
NacosString getChecksum() const;
void setChecksum(const NacosString &checksum);
};
}//namespace nacos
#endif
================================================
FILE: include/naming/ServiceInfo2.h
================================================
#ifndef __SVC_INFO_2_H_
#define __SVC_INFO_2_H_
#include <list>
#include "NacosString.h"
#include "naming/Cluster.h"
namespace nacos{ namespace naming {
class Selector {
private:
NacosString type;
public:
NacosString getType() const { return type; };
void setType(const NacosString &_type) { type = _type; };
virtual NacosString getSelectorString() = 0;
};
} /*naming*/
//Actually this should be exactly the same as ServiceInfo but I designed this for compatibility
//If you check the API reference in detail you'll find that:
//the ServiceInfo returned by /nacos/v1/ns/service differs from the one returned by /nacos/v1/ns/instance/list
//for more details, please refer :
//https://nacos.io/zh-cn/docs/open-api.html#2.4 (Query instances)
//https://nacos.io/zh-cn/docs/open-api.html#2.11 (Query service list)
class ServiceInfo2 {
private:
bool nullObj;
bool namespaceIdIsSet;
NacosString namespaceId;
bool groupNameIsSet;
NacosString groupName;
bool nameIsSet;
NacosString name;
bool selectorIsSet;
NacosString selector;
bool protectThresholdIsSet;
double protectThreshold;
bool clustersIsSet;
std::list<Cluster> clusters;
bool metadataIsSet;
std::map<NacosString, NacosString> metadata;
public:
static ServiceInfo2 nullServiceInfo2;
ServiceInfo2() {
nullObj = true;
namespaceIdIsSet = false;
groupNameIsSet = false;
nameIsSet = false;
selectorIsSet = false;
protectThresholdIsSet = false;
clustersIsSet = false;
metadataIsSet = false;
}
void setNull(bool _isNull) { nullObj = _isNull; };
bool isNullObject() const { return nullObj; };
const NacosString &getNamespaceId() const {
return namespaceId;
}
void setNamespaceId(const NacosString &namespaceId) {
namespaceIdIsSet = true;
ServiceInfo2::namespaceId = namespaceId;
}
const NacosString &getGroupName() const {
return groupName;
}
void setGroupName(const NacosString &groupName) {
groupNameIsSet = true;
ServiceInfo2::groupName = groupName;
}
const NacosString &getName() const {
return name;
}
void setName(const NacosString &name) {
nameIsSet = true;
ServiceInfo2::name = name;
}
const NacosString &getSelector() const {
return selector;
}
void setSelector(const NacosString &aSelector) {
selectorIsSet = true;
selector = aSelector;
}
int getProtectThreshold() const {
return protectThreshold;
}
void setProtectThreshold(double protectThreshold) {
protectThresholdIsSet = true;
ServiceInfo2::protectThreshold = protectThreshold;
}
const std::list<Cluster> &getClusters() const {
return clusters;
}
void setClusters(const std::list<Cluster> &clusters) {
clustersIsSet = true;
ServiceInfo2::clusters = clusters;
}
const std::map<std::string, std::string> &getMetadata() const {
return metadata;
}
void setMetadata(const std::map<std::string, std::string> &metadata) {
metadataIsSet = true;
ServiceInfo2::metadata = metadata;
}
bool isNamespaceIdSet() const {
return namespaceIdIsSet;
}
bool isGroupNameSet() const {
return groupNameIsSet;
}
bool isNameSet() const {
return nameIsSet;
}
bool isSelectorSet() const {
return selectorIsSet;
}
bool isProtectThresholdSet() const {
return protectThresholdIsSet;
}
bool isClustersSet() const {
return clustersIsSet;
}
bool isMetadataSet() const {
return metadataIsSet;
}
};
}/*namespace nacos*/
#endif
================================================
FILE: include/naming/selectors/HealthInstanceSelector.h
================================================
#ifndef __HEALTH_INST_SELECTOR_H_
#define __HEALTH_INST_SELECTOR_H_
#include <list>
#include "naming/selectors/Selector.h"
namespace nacos { namespace naming { namespace selectors {
class HealthInstanceSelector : public Selector<Instance>{
private:
public:
std::list<Instance> select(const std::list<Instance> &instancesToSelect);
};
} /*selectors*/ } /*naming*/ }/*nacos*/
#endif
================================================
FILE: include/naming/selectors/RandomByWeightSelector.h
================================================
#ifndef __WEIGHTED_RND_SELECTOR_H_
#define __WEIGHTED_RND_SELECTOR_H_
#include <list>
#include "naming/selectors/Selector.h"
#define BASIC_WEIGHT 65536
namespace nacos { namespace naming { namespace selectors {
class RandomByWeightSelector : public Selector<Instance>{
private:
public:
std::list<Instance> select(const std::list<Instance> &instancesToSelect);
};
} /*selectors*/ } /*naming*/ }/*nacos*/
#endif
================================================
FILE: include/naming/selectors/RandomSelector.h
================================================
#ifndef __RND_SELECTOR_H_
#define __RND_SELECTOR_H_
#include <list>
#include "naming/selectors/Selector.h"
namespace nacos { namespace naming { namespace selectors {
class RandomSelector : public Selector<Instance>{
private:
public:
std::list<Instance> select(const std::list<Instance> &instancesToSelect);
};
} /*selectors*/ } /*naming*/ }/*nacos*/
#endif
================================================
FILE: include/naming/selectors/Selector.h
================================================
#ifndef __SELECTOR_H_
#define __SELECTOR_H_
#include <list>
#include "naming/Instance.h"
namespace nacos { namespace naming { namespace selectors {
//Selector interface definition
//All Selectors shall be THREAD-SAFE!
template<typename T>
class Selector {
private:
public:
virtual std::list<T> select(const std::list<T> &itemsToSelect) = 0;
virtual ~Selector() {};
};
} /*selectors*/ } /*naming*/ }/*nacos*/
#endif
================================================
FILE: include/naming/subscribe/EventListener.h
================================================
//
// Created by liuhanyu on 2020/9/24.
//
#ifndef NACOS_SDK_CPP_EVENTLISTENER_H
#define NACOS_SDK_CPP_EVENTLISTENER_H
#include "NacosString.h"
#include "thread/AtomicInt.h"
#include "naming/ChangeAdvice.h"
namespace nacos{
class EventListener {
private:
NacosString listenerName;
AtomicInt<int> refCount;
public:
EventListener() {
this->listenerName = "theListener";
};
int incRef() { return refCount.inc(); };
int decRef() { return refCount.dec(); };
int refCnt() const { return refCount.get(); };
void setListenerName(const NacosString &name) { this->listenerName = name; };
NacosString getListenerName() const { return listenerName; };
virtual void receiveNamingInfo(const ServiceInfo &changeAdvice) = 0;
virtual ~EventListener();
};
}//namespace nacos
#endif //NACOS_SDK_CPP_EVENTLISTENER_H
================================================
FILE: include/server/ServerSelector.h
================================================
#ifndef NACOS_SDK_CPP_SERVERSELECTOR_H
#define NACOS_SDK_CPP_SERVERSELECTOR_H
#include "NacosServerInfo.h"
#include <list>
/*
* ServerSelector
* Author: Liu, Hanyu
* Selector interface, to select one server from the select list
* User can implement different selecting strategies (e.g.: Weighed, Random, Least used) by implementing select() method
*/
namespace nacos{
class ServerSelector {
public:
virtual NacosServerInfo select(std::list <NacosServerInfo> &serverList) = 0;
virtual ~ServerSelector() {};
};
}//namespace nacos
#endif //NACOS_SDK_CPP_SERVERSELECTOR_H
================================================
FILE: include/thread/AtomicInt.h
================================================
#ifndef __ATOMIC_INT_H_
#define __ATOMIC_INT_H_
namespace nacos{
template<typename T>
class AtomicInt {
private:
volatile T _curval;
public:
AtomicInt(T curval = 0) : _curval(curval) {};
void set(T val) { _curval = val; };
T inc(T incval = 1) {
T oldValue = getAndInc(incval);
return incval + oldValue;
};
T getAndInc(T incval = 1) {
T oldValue = __sync_fetch_and_add(&_curval, incval);
return oldValue;
}
T dec(int decval = 1) {
return inc(-decval);
};
T get() const { return _curval; };
};
}//namespace nacos
#endif
================================================
FILE: nacos-cpp-cli.properties
================================================
#!!please NOTE that the file format for this properties should be UNIX!!
#specify nacos server address here(separated by ,)
#serverAddr=
#log path, default is ~/nacos/logs/
#nacos.log.path=
#rotate size (number [+ unit], unit can be k/K m/M g/G. the size is regarded as byte if there is no unit)
#nacos.log.rotateSize=100m
#log level, default is ERROR
#nacos.log.level=ERROR
#client IP, the client will automatically detect NIC and find the best IP
#but if that doesn't work, you can override it here manually
#nacos.client.ip=
#if the server is secured with password, you may specify it here
#nacos.auth.username=
#nacos.auth.password=
#specify this if you are using an endpoint
#endpoint=
#endpointPort=
#specify context path for nacos server ("nacos" by default)
#nacos.server.contextpath=
#advanced settings
#port for udp listener (to receive service change information for subscribed services)
#nacos.udp.port=
#poller interval (10000 ms by default) to refresh subscribed service information from server
#naming.poller.interval=
#accessKey/secretKey for SPAS
#accessKey=
#secretKey=
================================================
FILE: src/NacosExceptions.cpp
================================================
#include "NacosExceptions.h"
namespace nacos{
NacosException::NacosException(int errorcode, const char *errormsg) NACOS_NOTHROW() {
_errcode = errorcode;
_errmsg = errormsg;
}
NacosException::NacosException(int errorcode, const NacosString &errormsg) NACOS_NOTHROW() {
_errcode = errorcode;
_errmsg = errormsg;
}
}//namespace nacos
================================================
FILE: src/NacosString.cpp
================================================
#include <math.h>
#include <stdio.h>
#include <sstream>
#include "NacosString.h"
namespace nacos{
const NacosString NacosStringOps::nullstr = "";
const NacosString NacosStringOps::STR_TRUE = "true";
const NacosString NacosStringOps::STR_FALSE = "false";
//Returns true if str refers to nullstr
bool NacosStringOps::isNullStr(const NacosString &str) {
return (&str == &nullstr) || (str == "");
}
template<>
NacosString NacosStringOps::valueOf<bool>(bool val) {
if (val) { return STR_TRUE; }
else { return STR_FALSE; }
}
}//namespace nacos
================================================
FILE: src/config/AppConfigManager.cpp
================================================
#include "src/utils/ParamUtils.h"
#include "AppConfigManager.h"
#include "NacosString.h"
#include "Properties.h"
#include "src/utils/NetUtils.h"
#include "constant/PropertyKeyConst.h"
#include "NacosExceptions.h"
#include "src/utils/DirUtils.h"
#include <vector>
#include <stdlib.h>
#include "src/log/Logger.h"
#include "src/utils/ConfigParserUtils.h"
#include "src/utils/Env.h"
using namespace std;
namespace nacos{
bool AppConfigManager::nacosAuthEnabled() {
if (contains(PropertyKeyConst::AUTH_USERNAME) && contains(PropertyKeyConst::AUTH_PASSWORD)) {
return true;
} else {
return false;
}
}
void AppConfigManager::checkReloadable() NACOS_THROW(NacosException) {
if (!reloadable) {
throw NacosException(0, "This object is initialized as a non-reloadable one");
}
}
size_t AppConfigManager::loadConfig() NACOS_THROW(NacosException) {
checkReloadable();
initDefaults();
Properties parsedConfig = ConfigParserUtils::parseConfigFile(configFile);
applyConfig(parsedConfig);
log_debug("[AppConfigManager]-loadConfig:loaded config file:%s\n", appConfig.toString().c_str());
return appConfig.size();
}
size_t AppConfigManager::loadConfig(const NacosString &_configFile) NACOS_THROW(NacosException) {
checkReloadable();
configFile = _configFile;
loadConfig();
return appConfig.size();
}
void AppConfigManager::clearConfig() {
appConfig.clear();
}
const NacosString& AppConfigManager::get(const NacosString &key) {
if (appConfig.count(key) == 0) {
return NULLSTR;
}
if (key.compare(PropertyKeyConst::NAMESPACE) == 0
&& appConfig[PropertyKeyConst::NAMESPACE].compare("Public") == 0)
{
return NULLSTR;
}
Properties::iterator iter = appConfig.find(key);
if (iter == appConfig.end()) {
return NULLSTR;
}
return iter->second;
}
void AppConfigManager::set(const NacosString &key, const NacosString &value) {
//Special case handle
if (key.compare(PropertyKeyConst::SERVER_REQ_TIMEOUT) == 0) {
_serverReqTimeout = atoi(value.c_str());
} else if (key.compare(PropertyKeyConst::CONTEXT_PATH) == 0) {
_contextPath = value;
}
appConfig[key] = value;
}
bool AppConfigManager::contains(const std::string &key) const {
return appConfig.contains(key);
}
AppConfigManager::AppConfigManager(Properties &props) {
reloadable = false;
initDefaults();
applyConfig(props);
}
AppConfigManager::AppConfigManager(const NacosString &_configFile) {
reloadable = true;
configFile = _configFile;
}
NacosString getAppNameFromEnv() {
const char* env = getEnv("APP_NAME");
if (env != NULL && std::char_traits<char>::length(env) > 0) {
return NacosString(env);
}
return NacosStringOps::nullstr;
}
void AppConfigManager::initDefaults() {
appConfig.clear();
//appConfig[PropertyKeyConst::NAMESPACE] = "public";
set(PropertyKeyConst::SRVLISTMGR_REFRESH_INTERVAL, "30000");
set(PropertyKeyConst::SERVER_REQ_TIMEOUT, "3000");
set(PropertyKeyConst::CONTEXT_PATH, ConfigConstant::DEFAULT_CONTEXT_PATH);
set(PropertyKeyConst::SUBSCRIPTION_POLL_INTERVAL, "10000");//10 secs by default
set(PropertyKeyConst::CONFIG_LONGPULLLING_TIMEOUT, "30000");//ms
set(PropertyKeyConst::HB_FAIL_WAIT_TIME, "20000");//ms
set(PropertyKeyConst::CLIENT_NAME, "default");
set(PropertyKeyConst::LOCAL_IP, NetUtils::getHostIp());
set(PropertyKeyConst::UDP_RECEIVER_PORT, "30620");
NacosString appName = getAppNameFromEnv();
if (!NacosStringOps::isNullStr(appName)) {
set(PropertyKeyConst::APP_NAME, appName);
}
NacosString homedir = DirUtils::getHome();
set(PropertyKeyConst::INSTANCE_ID_PREFIX, NetUtils::getHostName());
set(PropertyKeyConst::INSTANCE_ID_SEQ_FILE, homedir + ConfigConstant::FILE_SEPARATOR + "nacos" + ConfigConstant::FILE_SEPARATOR + "instance_seq.dat");
set(PropertyKeyConst::NACOS_SNAPSHOT_PATH, homedir + ConfigConstant::FILE_SEPARATOR + "nacos" + ConfigConstant::FILE_SEPARATOR + "snapshot");
log_info("[AppConfigManager]-initDefaults:DEFAULT_SNAPSHOT_PATH:%s\n", appConfig[PropertyKeyConst::NACOS_SNAPSHOT_PATH].c_str());
}
void AppConfigManager::applyConfig(Properties &rhs) {
for (map<NacosString, NacosString>::iterator it = rhs.begin();
it != rhs.end(); it++) {
set(it->first, it->second);
}
}
}//namespace nacos
================================================
FILE: src/config/AppConfigManager.h
================================================
#ifndef __APP_CFG_MGR_H_
#define __APP_CFG_MGR_H_
#include "NacosExceptions.h"
#include "NacosString.h"
#include "Properties.h"
#include "Compatibility.h"
namespace nacos{
class AppConfigManager {
private:
bool reloadable;
Properties appConfig;
NacosString configFile;
//Cached contextpath
NacosString _contextPath;
volatile long _serverReqTimeout;
AppConfigManager();
void checkReloadable() NACOS_THROW(NacosException);
void initDefaults();
void applyConfig(Properties &rhs);
public:
bool nacosAuthEnabled();
long getServeReqTimeout() const { return _serverReqTimeout; };
bool isReloadable() const { return reloadable; };
AppConfigManager(Properties &props);
AppConfigManager(const NacosString &configFile);
size_t loadConfig(const NacosString &configFile) NACOS_THROW(NacosException);
size_t loadConfig() NACOS_THROW(NacosException);
void clearConfig();
const NacosString &get(const NacosString &key);
bool contains(const NacosString &key) const;
const Properties& getAllConfig() { return appConfig; };
const NacosString & getContextPath() const { return _contextPath; };
void set(const NacosString &key, const NacosString &value);
};
}//namespace nacos
#endif
================================================
FILE: src/config/ConcurrentDiskUtil.cpp
================================================
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include "ConcurrentDiskUtil.h"
#include "IOUtils.h"
/**
* get file content
*
* @param file file
* @param charsetName charsetName
* @return content
* @throws IOException IOException
*/
namespace nacos{
NacosString
ConcurrentDiskUtil::getFileContent(const NacosString &file, const NacosString &charsetName) NACOS_THROW(IOException) {
if (IOUtils::checkNotExistOrNotFile(file)) {
//TODO:add errorcode
throw IOException(NacosException::FILE_NOT_FOUND,
"checkNotExistOrNotFile failed, unable to access the file, maybe it doesn't exist.");
}
size_t toRead = IOUtils::getFileSize(file);
FILE *fp = fopen(file.c_str(), "rb");
if (fp == NULL) {
char errbuf[100];
snprintf(errbuf, sizeof(errbuf), "Failed to open file for read, errno: %d", errno);
//TODO:add errorcode
throw IOException(NacosException::UNABLE_TO_OPEN_FILE, errbuf);
}
flock(fileno(fp), LOCK_SH);
char buf[toRead + 1];
fread(buf, toRead, 1, fp);
buf[toRead] = '\0';
flock(fileno(fp), LOCK_UN);
fclose(fp);
return NacosString(buf);
}
/**
* write file content
*
* @param file file
* @param content content
* @param charsetName charsetName
* @return whether write ok
* @throws IOException IOException
*/
bool ConcurrentDiskUtil::writeFileContent
(
const NacosString &path,
const NacosString &content,
const NacosString &charsetName
) NACOS_THROW(IOException) {
FILE *fp = fopen(path.c_str(), "wb");
if (fp == NULL) {
char errbuf[100];
snprintf(errbuf, sizeof(errbuf), "Failed to open file for write, errno: %d", errno);
//TODO:add errorcode
throw IOException(NacosException::UNABLE_TO_OPEN_FILE, errbuf);
}
flock(fileno(fp), LOCK_SH);
fwrite(content.c_str(), content.size(), 1, fp);
flock(fileno(fp), LOCK_UN);
fclose(fp);
return true;
}
}//namespace nacos
================================================
FILE: src/config/ConcurrentDiskUtil.h
================================================
#ifndef __CONC_DISK_UTIL_H_
#define __CONC_DISK_UTIL_H_
#include "NacosString.h"
#include "NacosExceptions.h"
#include "Compatibility.h"
namespace nacos{
class ConcurrentDiskUtil {
public:
/**
* get file content
*
* @param file file
* @param charsetName charsetName
* @return content
* @throws IOException IOException
*/
static NacosString getFileContent(const NacosString &file, const NacosString &charsetName) NACOS_THROW(IOException);
/**
* write file content
*
* @param file file
* @param content content
* @param charsetName charsetName
* @return whether write ok
* @throws IOException IOException
*/
static bool writeFileContent(const NacosString &path, const NacosString &content,
const NacosString &charsetName) NACOS_THROW(IOException);
};
}//namespace nacos
#endif
================================================
FILE: src/config/ConfigProxy.cpp
================================================
//
// Created by liuhanyu on 2021/7/6.
//
#include "ConfigProxy.h"
#include "src/http/HttpDelegate.h"
#include "src/utils/ParamUtils.h"
#include "src/utils/TimeUtils.h"
#include "src/config/AppConfigManager.h"
#include "constant/PropertyKeyConst.h"
#include "src/crypto/SignatureTool.h"
namespace nacos {
NacosString ConfigProxy::getDataToSign(const std::list <NacosString> ¶mValues, const NacosString &nowTimeMs) {
const NacosString & group = ParamUtils::findByKey(paramValues, "group");
const NacosString & tenant = ParamUtils::findByKey(paramValues, "tenant");
NacosString dataToSign = "";
if (!NacosStringOps::isNullStr(tenant)) {
dataToSign = tenant + "+";
}
if (!NacosStringOps::isNullStr(group)) {
dataToSign += group;
}
if (!NacosStringOps::isNullStr(dataToSign)) {
dataToSign += "+" + nowTimeMs;
} else {
dataToSign = nowTimeMs;
}
return dataToSign;
}
HttpResult ConfigProxy::reqAPI
(
int method,
const NacosString &path,
std::list <NacosString> &headers,
std::list <NacosString> ¶mValues,
const NacosString &encoding,
long readTimeoutMs
) NACOS_THROW(NetworkException) {
HttpDelegate *_httpDelegate = _objectConfigData->_httpDelegate;
//TODO: refactor to a common procedure
const NacosString& secretKey = _objectConfigData->_appConfigManager->get(PropertyKeyConst::SECRET_KEY);
const NacosString& accessKey = _objectConfigData->_appConfigManager->get(PropertyKeyConst::ACCESS_KEY);
const NacosString& appName = _objectConfigData->_appConfigManager->get(PropertyKeyConst::APP_NAME);
//If SPAS security credentials are set, SPAS is enabled
if (!ParamUtils::isBlank(secretKey) && !ParamUtils::isBlank(accessKey)) {
NacosString nowTimeMs = NacosStringOps::valueOf(TimeUtils::getCurrentTimeInMs());
NacosString dataToSign = getDataToSign(paramValues, nowTimeMs);
NacosString signature = SignatureTool::SignWithHMAC_SHA1(dataToSign, secretKey);
ParamUtils::addKV(headers, "Spas-Signature", signature);
ParamUtils::addKV(headers, "Timestamp", nowTimeMs);
ParamUtils::addKV(headers, "Spas-AccessKey", accessKey);
}
if (!NacosStringOps::isNullStr(appName)) {
ParamUtils::addKV(headers, "Client-AppName", appName);
}
switch (method) {
case IHttpCli::GET:
return _httpDelegate->httpGet(path, headers, paramValues, encoding, readTimeoutMs);
case IHttpCli::POST:
return _httpDelegate->httpPost(path, headers, paramValues, encoding, readTimeoutMs);
case IHttpCli::PUT:
return _httpDelegate->httpPut(path, headers, paramValues, encoding, readTimeoutMs);
case IHttpCli::DELETE:
return _httpDelegate->httpDelete(path, headers, paramValues, encoding, readTimeoutMs);
default://should never happen
abort();
}
}
}
================================================
FILE: src/config/ConfigProxy.h
================================================
//
// Created by liuhanyu on 2021/7/6.
//
#ifndef NACOS_SDK_CPP_CONFIGPROXY_H
#define NACOS_SDK_CPP_CONFIGPROXY_H
#include "src/factory/ObjectConfigData.h"
#include "src/http/IHttpCli.h"
namespace nacos {
class ConfigProxy {
private:
ObjectConfigData *_objectConfigData;
NacosString getDataToSign(const std::list <NacosString> ¶mValues, const NacosString &nowTimeMs);
public:
ConfigProxy(ObjectConfigData *objectConfigData) : _objectConfigData(objectConfigData) {};
HttpResult reqAPI(int method, const NacosString &path, std::list <NacosString> &headers, std::list <NacosString> ¶mValues,
const NacosString &encoding, long readTimeoutMs) NACOS_THROW(NetworkException);
};
}
#endif //NACOS_SDK_CPP_CONFIGPROXY_H
================================================
FILE: src/config/IOUtils.cpp
================================================
#include "IOUtils.h"
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <limits.h>
#include <list>
#include <unistd.h>
#include "src/log/Logger.h"
namespace nacos{
size_t IOUtils::getFileSize(const NacosString &file) {
struct stat statbuf;
if (stat(file.c_str(), &statbuf) == -1) {
return 0;
}
return statbuf.st_size;
}
NacosString IOUtils::readStringFromFile(const NacosString &file, const NacosString &encoding) NACOS_THROW(IOException) {
size_t toRead = getFileSize(file);
FILE *fp = fopen(file.c_str(), "rb");
if (fp == NULL) {
throw IOException(NacosException::FILE_NOT_FOUND, "File not found:" + file);
}
char buf[toRead + 1];
fread(buf, toRead, 1, fp);
buf[toRead] = '\0';
fclose(fp);
return NacosString(buf);
}
void IOUtils::writeStringToFile(const NacosString &file, const NacosString &data,
const NacosString &encoding) NACOS_THROW(IOException) {
FILE *fp = fopen(file.c_str(), "wb");
fwrite(data.c_str(), data.size(), 1, fp);
fclose(fp);
}
//Returns true if:
//a. the file doesn't exist
//b. the file is not a regular file
bool IOUtils::checkNotExistOrNotFile(const NacosString &pathname) {
struct stat thestat = {0};
int res = stat(pathname.c_str(), &thestat);
if (res != 0) {
if (errno == ENOENT) {
//a. the file doesn't exist
return true;
} else {
//Maybe something's wrong with the permission
//Anyway, we have no access to this file
return true;
}
}
if (!S_ISREG(thestat.st_mode)) {
//b. the file is not a regular file
return true;
} else {
//This IS a regular file
return false;
}
}
//Returns true if:
//a. the file doesn't exist
//b. the file is not a directory
bool IOUtils::checkNotExistOrNotDir(const NacosString &pathname) {
struct stat thestat = {0};
int res = stat(pathname.c_str(), &thestat);
if (res != 0) {
if (errno == ENOENT) {
//a. the file doesn't exist
return true;
} else {
//Maybe something's wrong with the permission
//Anyway, we have no access to this file
return true;
}
}
if (!S_ISDIR(thestat.st_mode)) {
//b. the file is not a directory
return true;
} else {
//This IS a directory
return false;
}
}
//TODO:To provide compability across different platforms
NacosString IOUtils::getParentFile(const NacosString &thefile) {
size_t parentFilePos = thefile.rfind('/');
//Invalid Directory/Filename, returning empty
if (parentFilePos == std::string::npos || parentFilePos == 0) {
return NULLSTR;
}
NacosString parentFile = thefile.substr(0, parentFilePos);
return parentFile;
}
//Upon success, return true
//Upon failure, return false
bool IOUtils::recursivelyRemove(const NacosString &file) {
struct stat thestat;
if (stat(file.c_str(), &thestat) == -1 && errno != ENOENT) {
//Something's wrong, and it's not "FileNotExist", we should record this and exit
log_error("Failed to stat() file, errno: %d\n", errno);
return false;
}
if (S_ISDIR(thestat.st_mode)) {
DIR *curdir = opendir(file.c_str());
struct dirent *direntp = readdir(curdir);
while (direntp != NULL) {
if (!strcmp(direntp->d_name, ".") || !strcmp(direntp->d_name, "..")) {
//skip this dir and parent
direntp = readdir(curdir);
continue;
}
struct stat subfilestat;
NacosString subfilepath = file + "/" + direntp->d_name;
if (stat(subfilepath.c_str(), &subfilestat) == -1 && errno != ENOENT) {
log_error("Failed to stat() file, errno: %d\n", errno);
closedir(curdir);
return false;
}
if (S_ISREG(subfilestat.st_mode)) {
remove(subfilepath.c_str());
} else if (S_ISDIR(subfilestat.st_mode)) {
recursivelyRemove(subfilepath);
}
//get to the next entry
direntp = readdir(curdir);
}
closedir(curdir);
remove(file.c_str());
} else if (S_ISREG(thestat.st_mode)) {
remove(file.c_str());
}
return true;
}
bool IOUtils::cleanDirectory(const NacosString &file) {
struct stat thestat;
if (stat(file.c_str(), &thestat) == -1 && errno != ENOENT) {
//Something's wrong, and it's not "FileNotExist", we should record this and exit
log_error("Failed to stat() file, errno: %d\n", errno);
return false;
}
if (!S_ISDIR(thestat.st_mode)) {
log_error("Call cleanDirectory() on non-directory entity: %s\n", file.c_str());
return false;
}
DIR *curdir = opendir(file.c_str());
struct dirent *direntp = readdir(curdir);
while (direntp != NULL) {
if (!strcmp(direntp->d_name, ".") || !strcmp(direntp->d_name, "..")) {
//skip this dir and parent
direntp = readdir(curdir);
continue;
}
NacosString subfilepath = file + "/" + direntp->d_name;
recursivelyRemove(subfilepath);
//get to the next entry
direntp = readdir(curdir);
}
closedir(curdir);
return true;
}
void IOUtils::recursivelyCreate(const NacosString &file) {
NacosString parentFile = getParentFile(file);
if (!isNull(parentFile)) {
recursivelyCreate(parentFile);
}
if (checkNotExistOrNotDir(file)) {
mkdir(file.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
}
}
std::list <NacosString> IOUtils::listFiles(const NacosString &path) {
struct stat thestat;
std::list <NacosString> filelist;
if (stat(path.c_str(), &thestat) == -1 && errno != ENOENT) {
//Something's wrong, and it's not "FileNotExist", we should record this and exit
log_error("Failed to stat() file, errno: %d\n", errno);
return filelist;
}
if (!S_ISDIR(thestat.st_mode)) {
log_error("Call listFiles() on non-directory entity: %s\n", path.c_str());
return filelist;
}
DIR *curdir = opendir(path.c_str());
struct dirent *direntp = readdir(curdir);
while (direntp != NULL) {
if (!strcmp(direntp->d_name, ".") || !strcmp(direntp->d_name, "..")) {
//skip this dir and parent
direntp = readdir(curdir);
continue;
}
NacosString curitem = direntp->d_name;
filelist.push_back(curitem);
//get to the next entry
direntp = readdir(curdir);
}
closedir(curdir);
return filelist;
}
}//namespace nacos
================================================
FILE: src/config/IOUtils.h
================================================
#ifndef __IO_UTILS_H_
#define __IO_UTILS_H_
#include <list>
#include "NacosString.h"
#include "NacosExceptions.h"
#include "Compatibility.h"
namespace nacos{
class IOUtils {
private:
public:
static size_t getFileSize(const NacosString &file);
static NacosString readStringFromFile(const NacosString &file, const NacosString &encoding) NACOS_THROW(IOException);
static void
writeStringToFile(const NacosString &file, const NacosString &data, const NacosString &encoding) NACOS_THROW(IOException);
//Returns true if:
//a. the file doesn't exist
//b. the file is not a regular file
static bool checkNotExistOrNotFile(const NacosString &pathname);
//Returns true if:
//a. the file doesn't exist
//b. the file is not a directory
static bool checkNotExistOrNotDir(const NacosString &pathname);
//TODO:To provide compability across different platforms
static NacosString getParentFile(const NacosString &thefile);
//Upon success, return true
//Upon failure, return false
static bool recursivelyRemove(const NacosString &file);
static bool cleanDirectory(const NacosString &file);
static void recursivelyCreate(const NacosString &file);
static std::list <NacosString> listFiles(const NacosString &path);
};
}//namespace nacos
#endif
================================================
FILE: src/config/JVMUtil.h
================================================
#ifndef __JVMUTIL_H_
#define __JVMUTIL_H_
namespace nacos{
class JVMUtil {
public:
/**
* whether is multi instance
*
* @return whether multi
*/
static bool isMultiInstance() {
return _isMultiInstance;
};
private:
static bool _isMultiInstance;
/*static {
NacosString multiDeploy = System.getProperty("isMultiInstance", "false");
if (TRUE.equals(multiDeploy)) {
isMultiInstance = true;
}
LOGGER.info("isMultiInstance:{}", isMultiInstance);
}*/
};
}//namespace nacos
#endif
================================================
FILE: src/config/LocalSnapshotManager.cpp
================================================
#include "LocalSnapshotManager.h"
#include <stdio.h>
#include <list>
#include <unistd.h>
#include <sys/types.h>
#include <errno.h>
#include "NacosExceptions.h"
#include "NacosString.h"
#include "src/utils/ParamUtils.h"
#include "src/utils/DirUtils.h"
#include "SnapShotSwitch.h"
#include "JVMUtil.h"
#include "ConcurrentDiskUtil.h"
#include "IOUtils.h"
#include "constant/ConfigConstant.h"
#include "constant/PropertyKeyConst.h"
#include "src/log/Logger.h"
namespace nacos{
NacosString LocalSnapshotManager::getFailover(const NacosString &serverName, const NacosString &dataId,
const NacosString &group, const NacosString &tenant) {
NacosString localPath = getFailoverFile(serverName, dataId, group, tenant);
if (IOUtils::checkNotExistOrNotFile(localPath)) {
log_debug("[LocalSnapshotManager]-getFailover:[servername=%s] failover file %s doesn't exist\n",
serverName.c_str(), localPath.c_str());
return NULLSTR;
}
try {
return readFile(localPath);
} catch (IOException &ioe) {
log_error("[LocalSnapshotManager]-getFailover:[servername=%s] get failover error, file: %s, exception:%s\n", serverName.c_str(), localPath.c_str(), ioe.what());
return NULLSTR;
}
};
/**
* 获取本地缓存文件内容。NULL表示没有本地文件或抛出异常。
*/
NacosString LocalSnapshotManager::getSnapshot
(
const NacosString &name,
const NacosString &dataId,
const NacosString &group,
const NacosString &tenant
) {
if (!SnapShotSwitch::getIsSnapShot()) {
return NULLSTR;
}
NacosString file = getSnapshotFile(name, dataId, group, tenant);
if (IOUtils::checkNotExistOrNotFile(file)) {
return NULLSTR;
}
try {
return readFile(file);
} catch (IOException &ioe) {
log_error("[LocalSnapshotManager]-getSnapshot:[servername=%s]+get snapshot error, file:%s what:%s\n", name.c_str(), file.c_str(), ioe.what());
return NULLSTR;
}
};
NacosString LocalSnapshotManager::readFile(const NacosString &file) NACOS_THROW(IOException) {
if (IOUtils::checkNotExistOrNotFile(file)) {
return NULLSTR;
}
if (JVMUtil::isMultiInstance()) {
return ConcurrentDiskUtil::getFileContent(file, ConfigConstant::ENCODE);
} else {
return IOUtils::readStringFromFile(file, ConfigConstant::ENCODE);
}
};
void
LocalSnapshotManager::saveSnapshot(const NacosString &envName, const NacosString &dataId, const NacosString &group,
const NacosString &tenant, const NacosString &config) {
if (!SnapShotSwitch::getIsSnapShot()) {
return;
}
NacosString file = getSnapshotFile(envName, dataId, group, tenant);
if (isNull(config)) {
int remove_result = remove(file.c_str());
if (remove_result)//error happens when removing the file
{
//usually we get this error because we are deleting a non-existent file
log_debug("[LocalSnapshotManager]-saveSnapshot:[servername=%s] delete snapshot error, remove() returns %d, errno = %d\n",
envName.c_str(), remove_result, errno);
}
} else {
NacosString parentFile = IOUtils::getParentFile(file);
if (IOUtils::checkNotExistOrNotDir(parentFile)) {
IOUtils::recursivelyCreate(parentFile);
//LOGGER.error("[{}] save snapshot error", envName);
}
if (JVMUtil::isMultiInstance()) {
ConcurrentDiskUtil::writeFileContent(file, config, ConfigConstant::ENCODE);
} else {
IOUtils::writeStringToFile(file, config, ConfigConstant::ENCODE);
}
//LOGGER.error("[" + envName + "] save snapshot error, " + file, ioe);
}
};
/**
* 清除snapshot目录下所有缓存文件。
*/
void LocalSnapshotManager::cleanAllSnapshot() {
std::list <NacosString> rootFile = IOUtils::listFiles(LOCAL_SNAPSHOT_PATH);
for (std::list<NacosString>::iterator it = rootFile.begin(); it != rootFile.end(); it++) {
//endsWith("_nacos")
if (it->length() >= 6 && (it->rfind("_nacos") == it->length() - 6)) {
IOUtils::cleanDirectory(LOCAL_SNAPSHOT_PATH + "/" + *it);
}
}
//LOGGER.error("clean all snapshot error, " + ioe.toString(), ioe);
};
void LocalSnapshotManager::cleanEnvSnapshot(const NacosString &envName) {
NacosString tmp = LOCAL_SNAPSHOT_PATH + "/" + envName + "_nacos";
tmp += "/snapshot";
//I think we should remove -tenant also, so for one envname, cache for all tenants within the environment will be purged
NacosString tmp_tenant = tmp + "-tenant";
IOUtils::cleanDirectory(tmp);
IOUtils::cleanDirectory(tmp_tenant);
log_info("[LocalSnapshotManager]-cleanEnvSnapshot:success delete %s-snapshot: %s\n", envName.c_str(), tmp.c_str());
};
NacosString LocalSnapshotManager::getFailoverFile(const NacosString &serverName, const NacosString &dataId,
const NacosString &group, const NacosString &tenant) {
NacosString Failoverfile = LOCAL_SNAPSHOT_PATH + "/" + serverName + "_nacos";
Failoverfile += "/data";
if (ParamUtils::isBlank(tenant)) {
Failoverfile += "/config-data";
} else {
Failoverfile += "/config-data-tenant/";
Failoverfile += tenant;
}
if (NacosStringOps::isNullStr(group)) {
Failoverfile += "/" + ConfigConstant::DEFAULT_GROUP + "/" + dataId;
} else {
Failoverfile += "/" + group + "/" + dataId;
}
return Failoverfile;
};
NacosString LocalSnapshotManager::getSnapshotFile(const NacosString &envName, const NacosString &dataId,
const NacosString &group, const NacosString &tenant) {
NacosString filename = LOCAL_SNAPSHOT_PATH + "/" + envName + "_nacos";
if (isNull(tenant)) {
filename += "/snapshot";
} else {
filename += "/snapshot-tenant/" + tenant;
}
if (NacosStringOps::isNullStr(group)) {
filename += "/" + ConfigConstant::DEFAULT_GROUP + "/" + dataId;
} else {
filename += "/" + group + "/" + dataId;
}
return filename;
};
LocalSnapshotManager::LocalSnapshotManager(AppConfigManager *appConfigManager) {
this->_appCfgMgr = appConfigManager;
LOCAL_SNAPSHOT_PATH = _appCfgMgr->get(PropertyKeyConst::NACOS_SNAPSHOT_PATH);
LOCAL_FAILOVER_PATH = _appCfgMgr->get(PropertyKeyConst::NACOS_SNAPSHOT_PATH);
log_debug("LocalConfigInfoProcessor::LocalConfigInfoProcessor() LOCAL_SNAPSHOT_PATH = %s\n", LocalSnapshotManager::LOCAL_SNAPSHOT_PATH.c_str());
}
}//namespace nacos
================================================
FILE: src/config/LocalSnapshotManager.h
================================================
#ifndef __LOCAL_SNAPSHOT_MGR_H_
#define __LOCAL_SNAPSHOT_MGR_H_
#include "NacosString.h"
#include "NacosExceptions.h"
#include "src/config/AppConfigManager.h"
#include "Compatibility.h"
/**
* Snapshot/Failover manager
*
* @author Nacos
*/
namespace nacos{
class LocalSnapshotManager {
private:
AppConfigManager *_appCfgMgr;
NacosString LOCAL_SNAPSHOT_PATH;
NacosString LOCAL_FAILOVER_PATH;
public:
LocalSnapshotManager(AppConfigManager *appConfigManager);
NacosString getFailover(const NacosString &serverName, const NacosString &dataId, const NacosString &group,
const NacosString &tenant);
/**
* Accuire local cache content, returns NULLSTR when the file does not exist or an exception is thrown
* 获取本地缓存文件内容。NULL表示没有本地文件或抛出异常。
*/
NacosString getSnapshot(const NacosString &name, const NacosString &dataId, const NacosString &group,
const NacosString &tenant);
NacosString readFile(const NacosString &file) NACOS_THROW(IOException);
void saveSnapshot(const NacosString &envName, const NacosString &dataId, const NacosString &group,
const NacosString &tenant, const NacosString &config);
/**
* Purge all cached files in snapshot directory
* 清除snapshot目录下所有缓存文件。
*/
void cleanAllSnapshot();
void cleanEnvSnapshot(const NacosString &envName);
NacosString
getFailoverFile(const NacosString &serverName, const NacosString &dataId, const NacosString &group,
const NacosString &tenant);
NacosString getSnapshotFile(const NacosString &envName, const NacosString &dataId, const NacosString &group,
const NacosString &tenant);
};
}//namespace nacos
#endif
================================================
FILE: src/config/NacosConfigService.cpp
================================================
#include "NacosConfigService.h"
#include "src/security/SecurityManager.h"
#include "src/log/Logger.h"
#include "ConfigProxy.h"
#include "src/utils/ParamUtils.h"
using namespace std;
namespace nacos{
NacosConfigService::NacosConfigService(ObjectConfigData *objectConfigData) NACOS_THROW(NacosException) {
_objectConfigData = objectConfigData;
if (_objectConfigData->_appConfigManager->nacosAuthEnabled()) {
_objectConfigData->_securityManager->login();
_objectConfigData->_securityManager->start();
}
}
NacosConfigService::~NacosConfigService() {
log_debug("[NacosConfigService]:~NacosConfigService()\n");
delete _objectConfigData;
}
NacosString NacosConfigService::getConfig
(
const NacosString &dataId,
const NacosString &group,
long timeoutMs
) NACOS_THROW(NacosException) {
return getConfigInner(getNamespace(), dataId, group, timeoutMs);
}
bool NacosConfigService::publishConfig
(
const NacosString &dataId,
const NacosString &group,
const NacosString &content
) NACOS_THROW(NacosException) {
return publishConfigInner(getNamespace(), dataId, group, NULLSTR, NULLSTR, NULLSTR, content);
}
bool NacosConfigService::removeConfig
(
const NacosString &dataId,
const NacosString &group
) NACOS_THROW(NacosException) {
return removeConfigInner(getNamespace(), dataId, group, NULLSTR);
}
NacosString NacosConfigService::getConfigInner
(
const NacosString &tenant,
const NacosString &dataId,
const NacosString &group,
long timeoutMs
) NACOS_THROW(NacosException) {
NacosString result = NULLSTR;
AppConfigManager *_appConfigManager = _objectConfigData->_appConfigManager;
LocalSnapshotManager *_localSnapshotManager = _objectConfigData->_localSnapshotManager;
NacosString clientName = _appConfigManager->get(PropertyKeyConst::CLIENT_NAME);
result = _localSnapshotManager->getFailover(clientName.c_str(), dataId, group, tenant);
if (!NacosStringOps::isNullStr(result)) {
log_warn("[NacosConfigService]-getConfig:[clientName=%s] get failover ok, dataId=%s, group=%s, tenant=%s, config=%s",
clientName.c_str(),
dataId.c_str(),
group.c_str(),
tenant.c_str(),
result.c_str());
return result;
}
try {
result = _objectConfigData->_clientWorker->getServerConfig(tenant, dataId, group, timeoutMs);
} catch (NacosException &e) {
if (e.errorcode() == NacosException::NO_RIGHT) {
log_error("Invalid credential, e: %d = %s\n", e.errorcode(), e.what());
}
const NacosString &clientName = _appConfigManager->get(PropertyKeyConst::CLIENT_NAME);
result = _localSnapshotManager->getSnapshot(clientName, dataId, group, tenant);
if (e.errorcode() == NacosException::NO_RIGHT && NacosStringOps::isNullStr(result)) {
//permission denied and no failback, let user decide what to do
throw e;
}
}
return result;
}
bool NacosConfigService::removeConfigInner
(
const NacosString &tenant,
const NacosString &dataId,
const NacosString &group,
const NacosString &tag
) NACOS_THROW(NacosException) {
std::list <NacosString> headers;
std::list <NacosString> paramValues;
//Get the request url
NacosString path = _objectConfigData->_appConfigManager->getContextPath() + ConfigConstant::CONFIG_CONTROLLER_PATH;
HttpResult res;
paramValues.push_back("dataId");
paramValues.push_back(dataId);
NacosString parmGroupid = ParamUtils::null2defaultGroup(group);
paramValues.push_back("group");
paramValues.push_back(parmGroupid);
if (!isNull(tenant)) {
paramValues.push_back("tenant");
paramValues.push_back(tenant);
}
NacosString serverAddr = _objectConfigData->_serverListManager->getCurrentServerAddr();
NacosString url = serverAddr + "/" + path;
log_debug("[NacosConfigService]-removeConfigInner: Assembled URL:%s\n", url.c_str());
ConfigProxy *_configProxy = _objectConfigData->_configProxy;
try {
res = _configProxy->reqAPI(IHttpCli::DELETE, url, headers, paramValues, _objectConfigData->encoding, POST_TIMEOUT);
}
catch (NetworkException &e) {
log_warn("[NacosConfigService]-removeConfigInner: error, %s, %s, %s, msg: %s\n", dataId.c_str(), group.c_str(), tenant.c_str(), e.what());
return false;
}
//If the server returns true, then this call succeeds
if (res.content.compare("true") == 0) {
return true;
} else {
return false;
}
}
bool NacosConfigService::publishConfigInner
(
const NacosString &tenant,
const NacosString &dataId,
const NacosString &group,
const NacosString &tag,
const NacosString &appName,
const NacosString &betaIps,
const NacosString &content
) NACOS_THROW(NacosException) {
//TODO:More stringent check, need to improve checkParam() function
ParamUtils::checkParam(dataId, group, content);
std::list <NacosString> headers;
std::list <NacosString> paramValues;
NacosString parmGroupid;
//Get the request url
NacosString path = _objectConfigData->_appConfigManager->getContextPath() + ConfigConstant::CONFIG_CONTROLLER_PATH;
HttpResult res;
parmGroupid = ParamUtils::null2defaultGroup(group);
ParamUtils::addKV(paramValues, "group", parmGroupid);
ParamUtils::addKV(paramValues, "dataId", dataId);
ParamUtils::addKV(paramValues, "content", content);
if (!isNull(tenant)) {
ParamUtils::addKV(paramValues, "tenant", tenant);
}
if (!isNull(appName)) {
ParamUtils::addKV(paramValues, "appName", appName);
}
if (!isNull(tag)) {
ParamUtils::addKV(paramValues, "tag", tag);
}
if (!isNull(betaIps)) {
ParamUtils::addKV(paramValues, "betaIps", betaIps);
}
NacosString serverAddr = _objectConfigData->_serverListManager->getCurrentServerAddr();
NacosString url = serverAddr + "/" + path;
log_debug("[NacosConfigService]-publishConfigInner:httpPost Assembled URL:%s\n", url.c_str());
ConfigProxy *_configProxy = _objectConfigData->_configProxy;
try {
res = _configProxy->reqAPI(IHttpCli::POST, url, headers, paramValues, _objectConfigData->encoding, POST_TIMEOUT);
}
catch (NetworkException &e) {
//
log_warn("[NacosConfigService]-publishConfigInner: exception, dataId=%s, group=%s, msg=%s\n", dataId.c_str(), group.c_str(),
tenant.c_str(), e.what());
return false;
}
//If the server returns true, then this call succeeds
if (res.content.compare("true") == 0) {
return true;
} else {
return false;
}
}
void NacosConfigService::addListener
(
const NacosString &dataId,
const NacosString &group,
Listener *listener
) NACOS_THROW(NacosException) {
NacosString parmgroup = ConfigConstant::DEFAULT_GROUP;
if (!isNull(group)) {
parmgroup = group;
}
//TODO:give a constant to this hard-coded number
NacosString cfgcontent;
try {
cfgcontent = getConfig(dataId, group, 3000);
} catch (NacosException &e) {
cfgcontent = "";
}
_objectConfigData->_clientWorker->addListener(dataId, parmgroup, getNamespace(), cfgcontent, listener);
_objectConfigData->_clientWorker->startListening();
}
void NacosConfigService::removeListener
(
const NacosString &dataId,
const NacosString &group,
Listener *listener
) {
NacosString parmgroup = ConfigConstant::DEFAULT_GROUP;
if (!isNull(group)) {
parmgroup = group;
}
log_debug("[NacosConfigService]-removeListener: calling client worker\n");
_objectConfigData->_clientWorker->removeListener(dataId, parmgroup, getNamespace(), listener);
}
}//namespace nacos
================================================
FILE: src/config/NacosConfigService.h
================================================
#ifndef __NACOS_CFG_SVC_H_
#define __NACOS_CFG_SVC_H_
#include "config/ConfigService.h"
#include "src/http/HttpDelegate.h"
#include "src/listen/ClientWorker.h"
#include "NacosString.h"
#include "src/server/ServerListManager.h"
#include "Properties.h"
#include "src/factory/ObjectConfigData.h"
#include "Compatibility.h"
namespace nacos{
class NacosConfigService : public ConfigService {
private:
ObjectConfigData *_objectConfigData;
//Private Methods
NacosConfigService();
NacosString getConfigInner(const NacosString &tenant, const NacosString &dataId, const NacosString &group,
long timeoutMs) NACOS_THROW(NacosException);
bool removeConfigInner(const NacosString &tenant, const NacosString &dataId, const NacosString &group,
const NacosString &tag) NACOS_THROW(NacosException);
bool publishConfigInner(const NacosString &tenant, const NacosString &dataId, const NacosString &group,
const NacosString &tag, const NacosString &appName, const NacosString &betaIps,
const NacosString &content) NACOS_THROW(NacosException);
//NacosString monitorChange(std::map<NacosString, NacosString> &keysAndContents, long timeoutMs) throw (NacosException);
//static NacosString monitorListToString(std::map<NacosString, NacosString> &keysAndContents);
NacosString getNamespace() const { return _objectConfigData->_appConfigManager->get(PropertyKeyConst::NAMESPACE); };
public:
const static long POST_TIMEOUT = 3000L;
//Public Methods
NacosString getConfig(const NacosString &dataId, const NacosString &group, long timeoutMs) NACOS_THROW(NacosException);
bool publishConfig(const NacosString &dataId, const NacosString &group,
const NacosString &content) NACOS_THROW(NacosException);
bool removeConfig(const NacosString &dataId, const NacosString &group) NACOS_THROW(NacosException);
void addListener(const NacosString &dataId, const NacosString &group, Listener *listener) NACOS_THROW(NacosException);
void removeListener(const NacosString &dataId, const NacosString &group, Listener *listener);
HttpDelegate *getHttpDelegate() const { return _objectConfigData->_httpDelegate; };
IHttpCli *getHttpCli() const { return _objectConfigData->_httpCli; };
ServerListManager *getServerListManager() const { return _objectConfigData->_serverListManager; };
ClientWorker *getClientWorker() const { return _objectConfigData->_clientWorker; };
AppConfigManager *getAppConfigManager() const { return _objectConfigData->_appConfigManager; };
void setHttpDelegate(HttpDelegate *httpDelegate) { _objectConfigData->_httpDelegate = httpDelegate; };
void setHttpCli(IHttpCli *httpCli) { _objectConfigData->_httpCli = httpCli; };
void setServerListManager(ServerListManager *svrListMgr) { _objectConfigData->_serverListManager = svrListMgr; };
void setClientWorker(ClientWorker *clientWorker) { _objectConfigData->_clientWorker = clientWorker; };
void setAppConfigManager(AppConfigManager *appConfigManager) { _objectConfigData->_appConfigManager = appConfigManager; };
//ctors/dtor
NacosConfigService(ObjectConfigData *objectConfigData) NACOS_THROW(NacosException);
virtual ~NacosConfigService();
};
}//namespace nacos
#endif
================================================
FILE: src/config/SnapShotSwitch.cpp
================================================
#include "LocalSnapshotManager.h"
#include "SnapShotSwitch.h"
namespace nacos{
bool SnapShotSwitch::getIsSnapShot() {
return isSnapShot;
};
void SnapShotSwitch::setIsSnapShot(bool isSnapShot) {
SnapShotSwitch::isSnapShot = isSnapShot;
//LocalConfigInfoProcessor::cleanAllSnapshot();
};
}//namespace nacos
================================================
FILE: src/config/SnapShotSwitch.h
================================================
#ifndef __SS_SWITCH_H_
#define __SS_SWITCH_H_
namespace nacos{
class SnapShotSwitch {
private:
/**
* whether use local cache
*/
static bool isSnapShot;
public:
static bool getIsSnapShot();
static void setIsSnapShot(bool isSnapShot);
};
}//namespace nacos
#endif
================================================
FILE: src/constant/ConfigConstant.cpp
================================================
#include "constant/ConfigConstant.h"
/**
* Constant
*
* @author Nacos
*/
namespace nacos{
const NacosString ConfigConstant::DEFAULT_GROUP = "DEFAULT_GROUP";
const NacosString ConfigConstant::DEFAULT_CONTEXT_PATH = "nacos";
const NacosString ConfigConstant::PROTOCOL_VERSION = "v1";
const NacosString ConfigConstant::GET_SERVERS_PATH = "ns/operator/servers";
const NacosString ConfigConstant::DATAID = "dataId";
const NacosString ConfigConstant::PROBE_MODIFY_REQUEST = "Listening-Configs";
const NacosString ConfigConstant::PROBE_MODIFY_RESPONSE = "Probe-Modify-Response";
const NacosString ConfigConstant::BASE_PATH = "/v1/cs";
const NacosString ConfigConstant::CONFIG_CONTROLLER_PATH = BASE_PATH + "/configs";
/**
* second
*/
const int ConfigConstant::POLLING_INTERVAL_TIME = 15;
const NacosString ConfigConstant::ENCODE = "UTF-8";
const int ConfigConstant::FLOW_CONTROL_THRESHOLD = 20;
const NacosString ConfigConstant::LINE_SEPARATOR = "\x1";
const NacosString ConfigConstant::WORD_SEPARATOR = "\x2";
const NacosString ConfigConstant::NAMING_INSTANCE_ID_SPLITTER = "#";
const NacosString ConfigConstant::DEFAULT_CLUSTER_NAME = "DEFAULT";
const NacosString ConfigConstant::SERVICE_INFO_SPLITER = "@@";
const NacosString ConfigConstant::FILE_SEPARATOR = "/";
const NacosString ConfigConstant::CONFIG_NEXT_LINE = "\n";
const NacosString ConfigConstant::CONFIG_KV_SEPARATOR = "=";
const NacosString ConfigConstant::DEFAULT_CONFIG_FILE = "nacos-cpp-cli.properties";
}//namespace nacos
================================================
FILE: src/constant/NamingConstant.cpp
================================================
#include "constant/NamingConstant.h"
namespace nacos{
const NacosString NamingConstant::SERVICE_NAME = "serviceName";
const NacosString NamingConstant::CLUSTER_NAME = "clusterName";
const NacosString NamingConstant::UDP_PORT = "udpPort";
const NacosString NamingConstant::CLUSTERS = "clusters";
const NacosString NamingConstant::CLIENT_IP = "clientIP";
const NacosString NamingConstant::HEALTHY_ONLY = "healthyOnly";
const NacosString NamingConstant::HEALTHY = "healthy";
const NacosString NamingConstant::NAMESPACE_ID = "namespaceId";
const NacosString NamingConstant::GROUP_NAME = "groupName";
const NacosString NamingConstant::SPLITER = "@@";
const NacosString NamingConstant::EMPTY = "";
const NacosString NamingConstant::ALL_IPS = "000--00-ALL_IPS--00--000";
const NacosString NamingConstant::BEAT = "beat";
const NacosString NamingConstant::PAGE_SIZE = "pageSize";
const NacosString NamingConstant::PAGE_NO = "pageNo";
}//namespace nacos
================================================
FILE: src/constant/PropertyKeyConst.cpp
================================================
#include "constant/PropertyKeyConst.h"
namespace nacos{
const NacosString PropertyKeyConst::IS_USE_ENDPOINT_PARSING_RULE = "isUseEndpointParsingRule";
const NacosString PropertyKeyConst::ENDPOINT = "endpoint";
const NacosString PropertyKeyConst::ENDPOINT_PORT = "endpointPort";
const NacosString PropertyKeyConst::NAMESPACE = "namespace";
const NacosString PropertyKeyConst::ENDPOINT_QUERY_PARAMS = "endpointQueryParams";
const NacosString PropertyKeyConst::ACCESS_KEY = "accessKey";
const NacosString PropertyKeyConst::SECRET_KEY = "secretKey";
const NacosString PropertyKeyConst::APP_NAME = "appName";
const NacosString PropertyKeyConst::RAM_ROLE_NAME = "ramRoleName";
const NacosString PropertyKeyConst::SERVER_ADDR = "serverAddr";
const NacosString PropertyKeyConst::CONTEXT_PATH = "nacos.server.contextpath";
const NacosString PropertyKeyConst::ENDPOINT_CONTEXT_PATH = "endpointContextPath";
const NacosString PropertyKeyConst::CLUSTER_NAME = "clusterName";
const NacosString PropertyKeyConst::ENCODE = "encode";
const NacosString PropertyKeyConst::NAMING_LOAD_CACHE_AT_START = "namingLoadCacheAtStart";
const NacosString PropertyKeyConst::NAMING_CLIENT_BEAT_THREAD_COUNT = "namingClientBeatThreadCount";
const NacosString PropertyKeyConst::NAMING_POLLING_THREAD_COUNT = "namingPollingThreadCount";
const NacosString PropertyKeyConst::SRVLISTMGR_REFRESH_INTERVAL = "serverListMgr.refreshInterval";
const NacosString PropertyKeyConst::SERVER_REQ_TIMEOUT = "nacos.server.reqtimeout";
const NacosString PropertyKeyConst::SUBSCRIPTION_POLL_INTERVAL = "naming.poller.interval";
const NacosString PropertyKeyConst::UDP_RECEIVER_PORT = "nacos.udp.port";
const NacosString PropertyKeyConst::CONFIG_LONGPULLLING_TIMEOUT = "config.longpulling.timeout";
const NacosString PropertyKeyConst::HB_FAIL_WAIT_TIME = "naming.heartbeat.failwait";
const NacosString PropertyKeyConst::NACOS_SNAPSHOT_PATH = "nacos.snapshot.path";
const NacosString PropertyKeyConst::LOG_PATH = "nacos.log.path";
const NacosString PropertyKeyConst::LOG_ROTATE_SIZE = "nacos.log.rotateSize";
const NacosString PropertyKeyConst::LOG_LEVEL = "nacos.log.level";
const NacosString PropertyKeyConst::CLIENT_NAME = "nacos.client.name";
const NacosString PropertyKeyConst::AUTH_USERNAME = "nacos.auth.username";
const NacosString PropertyKeyConst::AUTH_PASSWORD = "nacos.auth.password";
const NacosString PropertyKeyConst::LOCAL_IP = "nacos.client.ip";
const NacosString PropertyKeyConst::INSTANCE_ID_SEQ_FILE = "nacos.instId.seq.file";
const NacosString PropertyKeyConst::INSTANCE_ID_PREFIX = "nacos.instId.prefix";
}//namespace nacos
================================================
FILE: src/constant/UtilAndComs.cpp
================================================
#include "constant/UtilAndComs.h"
namespace nacos{
NacosString UtilAndComs::VERSION = "Nacos-C-Client:v1.0.21";//TODO:fix nacos trunk code for cpp client
NacosString UtilAndComs::ENCODING = "UTF-8";
NacosString UtilAndComs::NACOS_URL_BASE = "/v1/ns";
NacosString UtilAndComs::NACOS_URL_INSTANCE = NACOS_URL_BASE + "/instance";
int UtilAndComs::REQUEST_DOMAIN_RETRY_COUNT = 3;
NacosString UtilAndComs::SERVER_ADDR_IP_SPLITER = ":";
int UtilAndComs::DEFAULT_CLIENT_BEAT_THREAD_COUNT = 4;//TODO:Calc this according to nr_processors of the host
int UtilAndComs::DEFAULT_POLLING_THREAD_COUNT = 1;//TODO:Calc this according to nr_processors of the host
//Underlying logic:
/*int UtilAndComs::DEFAULT_CLIENT_BEAT_THREAD_COUNT = Runtime.getRuntime()
.availableProcessors() > 1 ? Runtime.getRuntime().availableProcessors() / 2
: 1;
int UtilAndComs::DEFAULT_POLLING_THREAD_COUNT = Runtime.getRuntime()
.availableProcessors() > 1 ? Runtime.getRuntime().availableProcessors() / 2
: 1;*/
void UtilAndComs::Init() {
}
}//namespace nacos
================================================
FILE: src/crypto/MACProvider.cpp
================================================
//
// Created by liuhanyu on 2021/7/8.
//
#include "MACProvider.h"
#include "src/crypto/hmac_sha1/hmac/hmac.h"
namespace nacos {
std::map<int, IMAC*> *MACProvider::MACRegistry;
const int MACProvider::HMAC_SHA1;
class HMACSha1 : public IMAC {
public:
void getMac(const void *k, /* secret key */
size_t lk, /* length of the key in bytes */
const void *d, /* data */
size_t ld, /* length of data in bytes */
void *out, /* output buffer, at least "t" bytes */
size_t *t);
};
void HMACSha1::getMac(const void *k, /* secret key */
size_t lk, /* length of the key in bytes */
const void *d, /* data */
size_t ld, /* length of data in bytes */
void *out, /* output buffer, at least "t" bytes */
size_t *t) {
hmac_sha1((const uint8_t*)k, lk, (const uint8_t*)d, ld, (uint8_t*)out, t);
}
void MACProvider::Init() {
MACRegistry = new std::map<int, IMAC*>();
(*MACRegistry)[MACProvider::HMAC_SHA1] = new HMACSha1();
}
void MACProvider::DeInit() {
for (std::map<int, IMAC*>::iterator it = MACRegistry->begin(); it != MACRegistry->end(); it++) {
IMAC * curMACProvider = it->second;
delete curMACProvider;
}
delete MACRegistry;
}
IMAC *MACProvider::getMAC(int algorithm) {
if (MACRegistry->count(algorithm) > 0) {
return (*MACRegistry)[algorithm];
}
return NULL;
}
}
================================================
FILE: src/crypto/MACProvider.h
================================================
//
// Created by liuhanyu on 2021/7/8.
//
#ifndef NACOS_SDK_CPP_MACPROVIDER_H
#define NACOS_SDK_CPP_MACPROVIDER_H
#include "NacosString.h"
#include <map>
namespace nacos {
class IMAC {
public:
virtual void getMac(const void *k, /* secret key */
size_t lk, /* length of the key in bytes */
const void *d, /* data */
size_t ld, /* length of data in bytes */
void *out, /* output buffer, at least "t" bytes */
size_t *t) = 0;
virtual ~IMAC() {};
};
class MACProvider {
private:
static std::map<int, IMAC*> *MACRegistry;
public:
static void Init();
static void DeInit();
static IMAC *getMAC(int algorithm);
static const int HMAC_SHA1 = 930620;
};
}
#endif //NACOS_SDK_CPP_MACPROVIDER_H
================================================
FILE: src/crypto/SignatureTool.h
================================================
//
// Created by liuhanyu on 2021/7/8.
//
#ifndef SIGNATURE_TOOL
#define SIGNATURE_TOOL
#include "NacosString.h"
#include "MACProvider.h"
#include "base64/base64.h"
#include "src/debug/DebugAssertion.h"
namespace nacos {
/**
* SignatureTool
*
* @author Liu, Hanyu
* Signature tool
*/
class SignatureTool {
public:
//Returns a base64-encoded signature string
static NacosString SignWithHMAC_SHA1(const NacosString &dataToSign, const NacosString &secretKey) {
IMAC *digester = MACProvider::getMAC(MACProvider::HMAC_SHA1);
unsigned char signature[20];
size_t outlen = sizeof(signature);
digester->getMac(secretKey.c_str(), secretKey.length(), dataToSign.c_str(), dataToSign.length(), (void*)signature, &outlen);
NACOS_ASSERT(outlen == 20);//must be 20 since we're using HMAC_SHA1
NacosString encoded_signature = base64_encode(signature, sizeof(signature));
return encoded_signature;
}
};
}
#endif //NACOS_SDK_CPP_MACPROVIDER_H
================================================
FILE: src/crypto/base64/base64.h
================================================
/*
* Base64 encoding/decoding (RFC1341)
* Copyright (c) 2005-2011, Jouni Malinen <j@w1.fi>
*
* This software may be distributed under the terms of the BSD license.
* See README for more details.
*/
// 2016-12-12 - Gaspard Petit : Slightly modified to return a std::string
// instead of a buffer allocated with malloc.
#include <string>
namespace nacos {
static const unsigned char base64_table[65] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/**
* base64_encode - Base64 encode
* @src: Data to be encoded
* @len: Length of the data to be encoded
* @out_len: Pointer to output length variable, or %NULL if not used
* Returns: Allocated buffer of out_len bytes of encoded data,
* or empty string on failure
*/
static std::string base64_encode(const unsigned char *src, size_t len)
{
unsigned char *out, *pos;
const unsigned char *end, *in;
size_t olen;
olen = 4*((len + 2) / 3); /* 3-byte blocks to 4-byte */
if (olen < len)
return std::string(); /* integer overflow */
std::string outStr;
outStr.resize(olen);
out = (unsigned char*)&outStr[0];
end = src + len;
in = src;
pos = out;
while (end - in >= 3) {
*pos++ = base64_table[in[0] >> 2];
*pos++ = base64_table[((in[0] & 0x03) << 4) | (in[1] >> 4)];
*pos++ = base64_table[((in[1] & 0x0f) << 2) | (in[2] >> 6)];
*pos++ = base64_table[in[2] & 0x3f];
in += 3;
}
if (end - in) {
*pos++ = base64_table[in[0] >> 2];
if (end - in == 1) {
*pos++ = base64_table[(in[0] & 0x03) << 4];
*pos++ = '=';
}
else {
*pos++ = base64_table[((in[0] & 0x03) << 4) |
(in[1] >> 4)];
*pos++ = base64_table[(in[1] & 0x0f) << 2];
}
*pos++ = '=';
}
return outStr;
}
}
================================================
FILE: src/crypto/hmac_sha1/LICENSE
================================================
The MIT License (MIT)
Copyright (c) 2014 Bob Liu
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: src/crypto/hmac_sha1/README.md
================================================
hmac-sha1
=========
[](https://travis-ci.org/Akagi201/hmac-sha1)
Standalone implementation of `HMAC()` + `EVP_sha1()` in `OpenSSL`
## API
```
#include "hmac/hmac.h"
void hmac_sha1(const uint8_t *k, /* secret key */
size_t lk, /* length of the key in bytes */
const uint8_t *d, /* data */
size_t ld, /* length of data in bytes */
uint8_t *out, /* output buffer, at least "t" bytes */
size_t *t);
```
================================================
FILE: src/crypto/hmac_sha1/hmac/hmac.h
================================================
/**
* @file re_hmac.h Interface to HMAC functions
*
* Copyright (C) 2010 Creytiv.com
*/
#ifndef HMAC_H_
#define HMAC_H_ (1)
#include <stdint.h>
void hmac_sha1(const uint8_t *k, /* secret key */
size_t lk, /* length of the key in bytes */
const uint8_t *d, /* data */
size_t ld, /* length of data in bytes */
uint8_t *out, /* output buffer, at least "t" bytes */
size_t *t);
#endif // HMAC_H_
================================================
FILE: src/crypto/hmac_sha1/hmac/hmac_sha1.cpp
================================================
/**
* @file hmac_sha1.c Implements HMAC-SHA1 as of RFC 2202
*
* Copyright (C) 2010 Creytiv.com
*/
#include <string.h>
#include <stdint.h>
#ifdef USE_OPENSSL
#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/err.h>
#else
#include "../sha/sha.h"
#endif
#include "hmac.h"
/** SHA-1 Block size */
#ifndef SHA_BLOCKSIZE
#define SHA_BLOCKSIZE (64)
#endif
/**
* Function to compute the digest
*
* @param k Secret key
* @param lk Length of the key in bytes
* @param d Data
* @param ld Length of data in bytes
* @param out Digest output
* @param t Size of digest output
*/
void hmac_sha1(const uint8_t *k, /* secret key */
size_t lk, /* length of the key in bytes */
const uint8_t *d, /* data */
size_t ld, /* length of data in bytes */
uint8_t *out, /* output buffer, at least "t" bytes */
size_t *t) {
#ifdef USE_OPENSSL
if (!HMAC(EVP_sha1(), k, (int)lk, d, ld, out, t)) {
ERR_clear_error();
}
#else
SHA_CTX ictx, octx;
uint8_t isha[SHA_DIGEST_LENGTH], osha[SHA_DIGEST_LENGTH];
uint8_t key[SHA_DIGEST_LENGTH];
uint8_t buf[SHA_BLOCKSIZE];
size_t i;
if (lk > SHA_BLOCKSIZE) {
SHA_CTX tctx;
SHA1_Init(&tctx);
SHA1_Update(&tctx, k, lk);
SHA1_Final(key, &tctx);
k = key;
lk = SHA_DIGEST_LENGTH;
}
/**** Inner Digest ****/
SHA1_Init(&ictx);
/* Pad the key for inner digest */
for (i = 0; i < lk; ++i) {
buf[i] = k[i] ^ 0x36;
}
for (i = lk; i < SHA_BLOCKSIZE; ++i) {
buf[i] = 0x36;
}
SHA1_Update(&ictx, buf, SHA_BLOCKSIZE);
SHA1_Update(&ictx, d, ld);
SHA1_Final(isha, &ictx);
/**** Outer Digest ****/
SHA1_Init(&octx);
/* Pad the key for outter digest */
for (i = 0; i < lk; ++i) {
buf[i] = k[i] ^ 0x5c;
}
for (i = lk; i < SHA_BLOCKSIZE; ++i) {
buf[i] = 0x5c;
}
SHA1_Update(&octx, buf, SHA_BLOCKSIZE);
SHA1_Update(&octx, isha, SHA_DIGEST_LENGTH);
SHA1_Final(osha, &octx);
/* truncate and print the results */
*t = *t > SHA_DIGEST_LENGTH ? SHA_DIGEST_LENGTH : *t;
memcpy(out, osha, *t);
#endif
}
================================================
FILE: src/crypto/hmac_sha1/sha/sha.h
================================================
/**
* @file re_sha.h Interface to SHA (Secure Hash Standard) functions
*
* Copyright (C) 2010 Creytiv.com
*/
#ifndef SHA_H_
#define SHA_H_ (1)
#ifdef USE_OPENSSL
#include <openssl/sha.h>
#else
/* public api for steve reid's public domain SHA-1 implementation */
/* this file is in the public domain */
/** SHA-1 Context */
typedef struct {
uint32_t state[5];
/**< Context state */
uint32_t count[2];
/**< Counter */
uint8_t buffer[64]; /**< SHA-1 buffer */
} SHA1_CTX;
/** SHA-1 Context (OpenSSL compat) */
typedef SHA1_CTX SHA_CTX;
/** SHA-1 Digest size in bytes */
#define SHA1_DIGEST_SIZE 20
/** SHA-1 Digest size in bytes (OpenSSL compat) */
#define SHA_DIGEST_LENGTH SHA1_DIGEST_SIZE
void SHA1_Init(SHA1_CTX *context);
void SHA1_Update(SHA1_CTX *context, const void *p, size_t len);
void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX *context);
#endif
#endif // SHA_H_
================================================
FILE: src/crypto/hmac_sha1/sha/sha1.cpp
================================================
/**
* @file sha1.c SHA-1 in C
*/
/*
By Steve Reid <sreid@sea-to-sky.net>
100% Public Domain
-----------------
Modified 7/98
By James H. Brown <jbrown@burgoyne.com>
Still 100% Public Domain
Corrected a problem which generated improper hash values on 16 bit machines
Routine SHA1Update changed from
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int
len)
to
void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned
long len)
The 'len' parameter was declared an int which works fine on 32 bit machines.
However, on 16 bit machines an int is too small for the shifts being done
against
it. This caused the hash function to generate incorrect values if len was
greater than 8191 (8K - 1) due to the 'len << 3' on line 3 of SHA1Update().
Since the file IO in main() reads 16K at a time, any file 8K or larger would
be guaranteed to generate the wrong hash (e.g. Test Vector #3, a million
"a"s).
I also changed the declaration of variables i & j in SHA1Update to
unsigned long from unsigned int for the same reason.
These changes should make no difference to any 32 bit implementations since
an
int and a long are the same size in those environments.
--
I also corrected a few compiler warnings generated by Borland C.
1. Added #include <process.h> for exit() prototype
2. Removed unused variable 'j' in SHA1Final
3. Changed exit(0) to return(0) at end of main.
ALL changes I made can be located by searching for comments containing 'JHB'
-----------------
Modified 8/98
By Steve Reid <sreid@sea-to-sky.net>
Still 100% public domain
1- Removed #include <process.h> and used return() instead of exit()
2- Fixed overwriting of finalcount in SHA1Final() (discovered by Chris Hall)
3- Changed email address from steve@edmweb.com to sreid@sea-to-sky.net
-----------------
Modified 4/01
By Saul Kravitz <Saul.Kravitz@celera.com>
Still 100% PD
Modified to run on Compaq Alpha hardware.
-----------------
Modified 07/2002
By Ralph Giles <giles@artofcode.com>
Still 100% public domain
modified for use with stdint types, autoconf
code cleanup, removed attribution comments
switched SHA1Final() argument order for consistency
use SHA1_ prefix for public api
move public api to sha1.h
*/
/*
Test Vectors (from FIPS PUB 180-1)
"abc"
A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
A million repetitions of "a"
34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
*/
#define SHA1HANDSOFF (1)
#include <stdint.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <string.h>
#include "sha.h"
void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]);
#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
#if defined (BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)
#define WORDS_BIGENDIAN 1
#endif
#ifdef _BIG_ENDIAN
#define WORDS_BIGENDIAN 1
#endif
/* blk0() and blk() perform the initial expand. */
/* I got the idea of expanding during the round function from SSLeay */
/* FIXME: can we do this in an endian-proof way? */
#ifdef WORDS_BIGENDIAN
#define blk0(i) block->l[i]
#else
#define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xff00ff00) \
|(rol(block->l[i],8)&0x00ff00ff))
#endif
#define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
^block->l[(i+2)&15]^block->l[i&15],1))
/* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
#define R0(v, w, x, y, z, i) \
z+=((w&(x^y))^y)+blk0(i)+0x5a827999+rol(v,5);w=rol(w,30);
#define R1(v, w, x, y, z, i) \
z+=((w&(x^y))^y)+blk(i)+0x5a827999+rol(v,5);w=rol(w,30);
#define R2(v, w, x, y, z, i) \
z+=(w^x^y)+blk(i)+0x6ed9eba1+rol(v,5);w=rol(w,30);
#define R3(v, w, x, y, z, i) \
z+=(((w|x)&y)|(w&x))+blk(i)+0x8f1bbcdc+rol(v,5);w=rol(w,30);
#define R4(v, w, x, y, z, i) \
z+=(w^x^y)+blk(i)+0xca62c1d6+rol(v,5);w=rol(w,30);
/* Hash a single 512-bit block. This is the core of the algorithm. */
void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]) {
uint32_t a, b, c, d, e;
typedef union {
uint8_t c[64];
uint32_t l[16];
} CHAR64LONG16;
CHAR64LONG16 *block;
#ifdef SHA1HANDSOFF
CHAR64LONG16 workspace;
block = &workspace;
memcpy(block, buffer, 64);
#else
block = (CHAR64LONG16*)buffer;
#endif
/* Copy context->state[] to working vars */
a = state[0];
b = state[1];
c = state[2];
d = state[3];
e = state[4];
/* 4 rounds of 20 operations each. Loop unrolled. */
R0(a, b, c, d, e, 0);
R0(e, a, b, c, d, 1);
R0(d, e, a, b, c, 2);
R0(c, d, e, a, b, 3);
R0(b, c, d, e, a, 4);
R0(a, b, c, d, e, 5);
R0(e, a, b, c, d, 6);
R0(d, e, a, b, c, 7);
R0(c, d, e, a, b, 8);
R0(b, c, d, e, a, 9);
R0(a, b, c, d, e, 10);
R0(e, a, b, c, d, 11);
R0(d, e, a, b, c, 12);
R0(c, d, e, a, b, 13);
R0(b, c, d, e, a, 14);
R0(a, b, c, d, e, 15);
R1(e, a, b, c, d, 16);
R1(d, e, a, b, c, 17);
R1(c, d, e, a, b, 18);
R1(b, c, d, e, a, 19);
R2(a, b, c, d, e, 20);
R2(e, a, b, c, d, 21);
R2(d, e, a, b, c, 22);
R2(c, d, e, a, b, 23);
R2(b, c, d, e, a, 24);
R2(a, b, c, d, e, 25);
R2(e, a, b, c, d, 26);
R2(d, e, a, b, c, 27);
R2(c, d, e, a, b, 28);
R2(b, c, d, e, a, 29);
R2(a, b, c, d, e, 30);
R2(e, a, b, c, d, 31);
R2(d, e, a, b, c, 32);
R2(c, d, e, a, b, 33);
R2(b, c, d, e, a, 34);
R2(a, b, c, d, e, 35);
R2(e, a, b, c, d, 36);
R2(d, e, a, b, c, 37);
R2(c, d, e, a, b, 38);
R2(b, c, d, e, a, 39);
R3(a, b, c, d, e, 40);
R3(e, a, b, c, d, 41);
R3(d, e, a, b, c, 42);
R3(c, d, e, a, b, 43);
R3(b, c, d, e, a, 44);
R3(a, b, c, d, e, 45);
R3(e, a, b, c, d, 46);
R3(d, e, a, b, c, 47);
R3(c, d, e, a, b, 48);
R3(b, c, d, e, a, 49);
R3(a, b, c, d, e, 50);
R3(e, a, b, c, d, 51);
R3(d, e, a, b, c, 52);
R3(c, d, e, a, b, 53);
R3(b, c, d, e, a, 54);
R3(a, b, c, d, e, 55);
R3(e, a, b, c, d, 56);
R3(d, e, a, b, c, 57);
R3(c, d, e, a, b, 58);
R3(b, c, d, e, a, 59);
R4(a, b, c, d, e, 60);
R4(e, a, b, c, d, 61);
R4(d, e, a, b, c, 62);
R4(c, d, e, a, b, 63);
R4(b, c, d, e, a, 64);
R4(a, b, c, d, e, 65);
R4(e, a, b, c, d, 66);
R4(d, e, a, b, c, 67);
R4(c, d, e, a, b, 68);
R4(b, c, d, e, a, 69);
R4(a, b, c, d, e, 70);
R4(e, a, b, c, d, 71);
R4(d, e, a, b, c, 72);
R4(c, d, e, a, b, 73);
R4(b, c, d, e, a, 74);
R4(a, b, c, d, e, 75);
R4(e, a, b, c, d, 76);
R4(d, e, a, b, c, 77);
R4(c, d, e, a, b, 78);
R4(b, c, d, e, a, 79);
/* Add the working vars back into context.state[] */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
/* Wipe variables */
a = b = c = d = e = 0;
}
/**
* Initialize new context
*
* @param context SHA1-Context
*/
void SHA1_Init(SHA1_CTX *context) {
/* SHA1 initialization constants */
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
context->state[4] = 0xc3d2e1f0;
context->count[0] = context->count[1] = 0;
}
/**
* Run your data through this
*
* @param context SHA1-Context
* @param p Buffer to run SHA1 on
* @param len Number of bytes
*/
void SHA1_Update(SHA1_CTX *context, const void *p, size_t len) {
const uint8_t *data = (const uint8_t *)p;
size_t i, j;
j = (context->count[0] >> 3) & 63;
if ((context->count[0] += (uint32_t) (len << 3)) < (len << 3)) {
context->count[1]++;
}
context->count[1] += (uint32_t) (len >> 29);
if ((j + len) > 63) {
memcpy(&context->buffer[j], data, (i = 64 - j));
SHA1_Transform(context->state, context->buffer);
for (; i + 63 < len; i += 64) {
SHA1_Transform(context->state, data + i);
}
j = 0;
}
else i = 0;
memcpy(&context->buffer[j], &data[i], len - i);
}
/**
* Add padding and return the message digest
*
* @param digest Generated message digest
* @param context SHA1-Context
*/
void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX *context) {
uint32_t i;
uint8_t finalcount[8];
for (i = 0; i < 8; i++) {
finalcount[i] = (uint8_t) ((context->count[(i >= 4 ? 0 : 1)]
>> ((3 - (i & 3)) * 8)) & 255);
}
SHA1_Update(context, (uint8_t *) "\200", 1);
while ((context->count[0] & 504) != 448) {
SHA1_Update(context, (uint8_t *) "\0", 1);
}
SHA1_Update(context, finalcount, 8); /* Should cause SHA1_Transform */
for (i = 0; i < SHA1_DIGEST_SIZE; i++) {
digest[i] = (uint8_t)
((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
}
/* Wipe variables */
i = 0;
memset(context->buffer, 0, 64);
memset(context->state, 0, 20);
memset(context->count, 0, 8);
memset(finalcount, 0, 8); /* SWR */
#ifdef SHA1HANDSOFF /* make SHA1Transform overwrite its own static vars */
SHA1_Transform(context->state, context->buffer);
#endif
}
================================================
FILE: src/crypto/md5/md5.cpp
================================================
#include "md5.h"
using namespace std;
/* Constants for MD5Transform routine. */
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
/* F, G, H and I are basic MD5 functions.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits.
*/
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
Rotation is separate from addition to prevent recomputation.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + ac; \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + ac; \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + ac; \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + ac; \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
namespace nacos{
const byte MD5::PADDING[64] = {0x80};
const char MD5::HEX[16] = {
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', 'a', 'b',
'c', 'd', 'e', 'f'
};
/* Default construct. */
MD5::MD5() {
reset();
}
/* Construct a MD5 object with a input buffer. */
MD5::MD5(const void *input, size_t length) {
reset();
update(input, length);
}
/* Construct a MD5 object with a string. */
MD5::MD5(const NacosString &str) {
reset();
update(str);
}
/* Construct a MD5 object with a file. */
MD5::MD5(ifstream &in) {
reset();
update(in);
}
/* Return the message-digest */
const byte *MD5::digest() {
if (!_finished) {
_finished = true;
final();
}
return _digest;
}
/* Reset the calculate state */
void MD5::reset() {
_finished = false;
/* reset number of bits. */
_count[0] = _count[1] = 0;
/* Load magic initialization constants. */
_state[0] = 0x67452301;
_state[1] = 0xefcdab89;
_state[2] = 0x98badcfe;
_state[3] = 0x10325476;
}
/* Updating the context with a input buffer. */
void MD5::update(const void *input, size_t length) {
update((const byte *) input, length);
}
/* Updating the context with a string. */
void MD5::update(const NacosString &str) {
update((const byte *) str.c_str(), str.length());
}
/* Updating the context with a file. */
void MD5::update(ifstream &in) {
if (!in) {
return;
}
std::streamsize length;
char buffer[BUFFER_SIZE];
while (!in.eof()) {
in.read(buffer, BUFFER_SIZE);
length = in.gcount();
if (length > 0) {
update(buffer, length);
}
}
in.close();
}
/* MD5 block update operation. Continues an MD5 message-digest
operation, processing another message block, and updating the
context.
*/
void MD5::update(const byte *input, size_t length) {
uint32 i, index, partLen;
_finished = false;
/* Compute number of bytes mod 64 */
index = (uint32)((_count[0] >> 3) & 0x3f);
/* update number of bits */
if ((_count[0] += ((uint32) length << 3)) < ((uint32) length << 3)) {
++_count[1];
}
_count[1] += ((uint32) length >> 29);
partLen = 64 - index;
/* transform as many times as possible. */
if (length >= partLen) {
memcpy(&_buffer[index], input, partLen);
transform(_buffer);
for (i = partLen; i + 63 < length; i += 64) {
transform(&input[i]);
}
index = 0;
} else {
i = 0;
}
/* Buffer remaining input */
memcpy(&_buffer[index], &input[i], length - i);
}
/* MD5 finalization. Ends an MD5 message-_digest operation, writing the
the message _digest and zeroizing the context.
*/
void MD5::final() {
byte bits[8];
uint32 oldState[4];
uint32 oldCount[2];
uint32 index, padLen;
/* Save current state and count. */
memcpy(oldState, _state, 16);
memcpy(oldCount, _count, 8);
/* Save number of bits */
encode(_count, bits, 8);
/* Pad out to 56 mod 64. */
index = (uint32)((_count[0] >> 3) & 0x3f);
padLen = (index < 56) ? (56 - index) : (120 - index);
update(PADDING, padLen);
/* Append length (before padding) */
update(bits, 8);
/* Store state in digest */
encode(_state, _digest, 16);
/* Restore current state and count. */
memcpy(_state, oldState, 16);
memcpy(_count, oldCount, 8);
}
/* MD5 basic transformation. Transforms _state based on block. */
void MD5::transform(const byte block[64]) {
uint32 a = _state[0], b = _state[1], c = _state[2], d = _state[3], x[16];
decode(block, x, 64);
/* Round 1 */
FF (a, b, c, d, x[0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[9], S44, 0xeb86d391); /* 64 */
_state[0] += a;
_state[1] += b;
_state[2] += c;
_state[3] += d;
}
/* Encodes input (ulong) into output (byte). Assumes length is
a multiple of 4.
*/
void MD5::encode(const uint32 *input, byte *output, size_t length) {
for (size_t i = 0, j = 0; j < length; ++i, j += 4) {
output[j] = (byte)(input[i] & 0xff);
output[j + 1] = (byte)((input[i] >> 8) & 0xff);
output[j + 2] = (byte)((input[i] >> 16) & 0xff);
output[j + 3] = (byte)((input[i] >> 24) & 0xff);
}
}
/* Decodes input (byte) into output (ulong). Assumes length is
a multiple of 4.
*/
void MD5::decode(const byte *input, uint32 *output, size_t length) {
for (size_t i = 0, j = 0; j < length; ++i, j += 4) {
output[i] = ((uint32) input[j]) | (((uint32) input[j + 1]) << 8) |
(((uint32) input[j + 2]) << 16) | (((uint32) input[j + 3]) << 24);
}
}
/* Convert byte array to hex string. */
NacosString MD5::bytesToHexString(const byte *input, size_t length) {
NacosString str;
str.reserve(length << 1);
for (size_t i = 0; i < length; ++i) {
int t = input[i];
int a = t / 16;
int b = t % 16;
str.append(1, HEX[a]);
str.append(1, HEX[b]);
}
return str;
}
/* Convert digest to string value */
NacosString MD5::toString() {
return bytesToHexString(digest(), 16);
}
}//namespace nacos
================================================
FILE: src/crypto/md5/md5.h
================================================
#ifndef MD5_H
#define MD5_H
#include <string>
#include <string.h>
#include <fstream>
#include "NacosString.h"
namespace nacos{
/* Type define */
typedef unsigned char byte;
typedef unsigned int uint32;
using std::string;
using std::ifstream;
/* MD5 declaration. */
class MD5 {
public:
MD5();
MD5(const void *input, size_t length);
MD5(const NacosString &str);
MD5(ifstream &in);
void update(const void *input, size_t length);
void update(const NacosString &str);
void update(ifstream &in);
const byte *digest();
NacosString toString();
void reset();
private:
void update(const byte *input, size_t length);
void final();
void transform(const byte block[64]);
void encode(const uint32 *input, byte *output, size_t length);
void decode(const byte *input, uint32 *output, size_t length);
NacosString bytesToHexString(const byte *input, size_t length);
/* class uncopyable */
MD5(const MD5 &);
MD5 &operator=(const MD5 &);
private:
uint32 _state[4]; /* state (ABCD) */
uint32 _count[2]; /* number of bits, modulo 2^64 (low-order word first) */
byte _buffer[64]; /* input buffer */
byte _digest[16]; /* message digest */
bool _finished; /* calculate finished ? */
static const byte PADDING[64]; /* padding for calculate */
static const char HEX[16];
enum {
BUFFER_SIZE = 1024
};
};
}//namespace nacos
#endif
================================================
FILE: src/debug/DebugAssertion.h
================================================
#ifndef __DEBUG_ASSERTION_H_
#define __DEBUG_ASSERTION_H_
#include <stdlib.h>
#include <stdio.h>
#include "NacosString.h"
namespace nacos{
#define TEST_ITEM_START {
#define TEST_ITEM(testName, testfn) {(testName), (testfn)},
#define TEST_ITEM_END };
#define NACOS_ASSERT(x) \
if (!(x)) \
{ \
printf("Assertion failed! file:" __FILE__":%d\n", __LINE__); \
abort(); \
}
typedef bool (*TESTFN)();
typedef struct tagTestData {
NacosString testName;
TESTFN testFn;
} TestData;
#define SHOULD_BE_TRUE(assertion, message) \
do \
{ \
if (!(assertion)) \
{ \
cout << (message) << "...:failed" << endl; \
return false; \
} \
cout << (message) << "...:passed" << endl; \
} while(0);
#define SHOULD_BE_FALSE(assertion, message) SHOULD_BE_TRUE(!(assertion), (message))
#ifdef NACOS_AUTH
#define ADD_AUTH_INFO(x) \
do { \
(x)["nacos.auth.username"] = "nacos"; \
(x)["nacos.auth.password"] = "nacos"; \
} while (0)
#else
#define ADD_AUTH_INFO(x)
#endif
#ifdef NACOS_SPAS
#define ADD_SPAS_INFO(x) \
do { \
(x)["secretKey"] = "nacos"; \
(x)["accessKey"] = "nacos"; \
} while (0)
#else
#define ADD_SPAS_INFO(x)
#endif
}//namespace nacos
#endif
================================================
FILE: src/factory/NacosFactoryFactory.cpp
================================================
#include "factory/NacosFactoryFactory.h"
#include "src/factory/NacosServiceFactory.h"
namespace nacos {
INacosServiceFactory *NacosFactoryFactory::getNacosFactory(const NacosString &_configFile) {
NacosServiceFactory *factory = new NacosServiceFactory(_configFile);
return factory;
}
INacosServiceFactory *NacosFactoryFactory::getNacosFactory(Properties &_props) {
NacosServiceFactory *factory = new NacosServiceFactory(_props);
return factory;
}
}
================================================
FILE: src/factory/NacosServiceFactory.cpp
================================================
//
// Created by liuhanyu on 2020/8/30.
//
#include "src/factory/NacosServiceFactory.h"
#include "src/init/Init.h"
#include "src/naming/NacosNamingService.h"
#include "src/naming/NacosNamingMaintainService.h"
#include "ObjectConfigData.h"
#include "src/config/NacosConfigService.h"
#include "src/config/AppConfigManager.h"
#include "src/http/HttpDelegate.h"
#include "src/http/delegate/NoOpHttpDelegate.h"
#include "src/http/delegate/NacosAuthHttpDelegate.h"
#include "src/http/HTTPCli.h"
#include "src/naming/subscribe/EventDispatcher.h"
#include "src/naming/subscribe/SubscriptionPoller.h"
#include "src/naming/subscribe/UdpNamingServiceListener.h"
#include "src/naming/subscribe/HostReactor.h"
#include "src/security/SecurityManager.h"
#include "src/utils/ConfigParserUtils.h"
#include "src/utils/SequenceProvider.h"
#include "src/config/ConfigProxy.h"
#include "src/utils/DirUtils.h"
//Unlike Java, in cpp, there's no container, no spring to do the ORM job, so I have to handle it myself
namespace nacos{
volatile bool NacosServiceFactory::logSystemInitialized = false;
void buildSecurityManagerAndHttpDelegate(ObjectConfigData *objectConfigData) {
AppConfigManager *appConfigManager = objectConfigData->_appConfigManager;
if (appConfigManager->nacosAuthEnabled()) {
//nacos authentication is enabled
SecurityManager *securityManager = new SecurityManager(objectConfigData);
objectConfigData->_securityManager = securityManager;
HttpDelegate *httpDelegate = new NacosAuthHttpDelegate(objectConfigData);
objectConfigData->_httpDelegate = httpDelegate;
} else {
HttpDelegate *httpDelegate = new NoOpHttpDelegate(objectConfigData);
objectConfigData->_httpDelegate = httpDelegate;
}
}
AppConfigManager *NacosServiceFactory::buildConfigManager(ObjectConfigData *objectConfigData) {
//Create configuration data and load configs
AppConfigManager *appConfigManager = NULL;
if (configIsSet) {
appConfigManager = new AppConfigManager(configFile);
appConfigManager->loadConfig(configFile);
} else {
appConfigManager = new AppConfigManager(props);
}
objectConfigData->_appConfigManager = appConfigManager;
return appConfigManager;
}
void NacosServiceFactory::initializeRuntimeLogSettings(AppConfigManager *_appConfigManager) {
if (logSystemInitialized) {
return;
}
{
LockGuard __lockLogSystem(logSysInitLock);
if (logSystemInitialized) {
return;
}
logSystemInitialized = true;
Properties copiedProps = _appConfigManager->getAllConfig();
Logger::applyLogSettings(copiedProps);
}
}
//FIXME:Memory leak at initializing stage, e.g.:
//when a HttpDelegate is allocated in CreateConfigService, after that an EXCEPTION is thrown during the initialization of ServerListManager
//the resource for HttpDelegate is never released
NamingService *NacosServiceFactory::CreateNamingService() NACOS_THROW(NacosException) {
Init::doInit();
checkConfig();
ObjectConfigData *objectConfigData = new ObjectConfigData(NAMING);
objectConfigData->name = "config";
objectConfigData->encoding = "UTF-8";
AppConfigManager *appConfigManager = buildConfigManager(objectConfigData);
initializeRuntimeLogSettings(appConfigManager);
//Create http client
IHttpCli *httpCli= new HTTPCli();
objectConfigData->_httpCli = httpCli;
buildSecurityManagerAndHttpDelegate(objectConfigData);
//Create server manager
ServerListManager *serverListManager = new ServerListManager(objectConfigData);
objectConfigData->_serverListManager = serverListManager;
//Create naming service & heartbeat sender
NamingProxy *namingProxy = new NamingProxy(objectConfigData);
objectConfigData->_serverProxy = namingProxy;
BeatReactor *beatReactor = new BeatReactor(objectConfigData);
objectConfigData->_beatReactor = beatReactor;
EventDispatcher *eventDispatcher = new EventDispatcher();
objectConfigData->_eventDispatcher = eventDispatcher;
SubscriptionPoller *subscriptionPoller = new SubscriptionPoller(objectConfigData);
objectConfigData->_subscriptionPoller = subscriptionPoller;
UdpNamingServiceListener *udpNamingServiceListener = new UdpNamingServiceListener(objectConfigData);
objectConfigData->_udpNamingServiceListener = udpNamingServiceListener;
HostReactor *hostReactor = new HostReactor(objectConfigData);
objectConfigData->_hostReactor = hostReactor;
const NacosString &seqConfile = appConfigManager->get(PropertyKeyConst::INSTANCE_ID_SEQ_FILE);
SequenceProvider<int64_t> *sequenceProvider = new SequenceProvider<int64_t>(seqConfile, 1, 10);
objectConfigData->_sequenceProvider = sequenceProvider;
objectConfigData->checkAssembledObject();
NamingService *instance = new NacosNamingService(objectConfigData);
log_debug("Created config data: %s", objectConfigData->name.c_str());
return instance;
}
ConfigService *NacosServiceFactory::CreateConfigService() NACOS_THROW(NacosException) {
Init::doInit();
checkConfig();
ObjectConfigData *objectConfigData = new ObjectConfigData(CONFIG);
objectConfigData->name = "name";
objectConfigData->encoding = "UTF-8";
AppConfigManager *appConfigManager = buildConfigManager(objectConfigData);
initializeRuntimeLogSettings(appConfigManager);
//Create http client
IHttpCli *httpCli = NULL;
httpCli = new HTTPCli();
objectConfigData->_httpCli = httpCli;
buildSecurityManagerAndHttpDelegate(objectConfigData);
//Create server manager
ServerListManager *serverListManager = new ServerListManager(objectConfigData);
objectConfigData->_serverListManager = serverListManager;
ConfigProxy *configProxy = new ConfigProxy(objectConfigData);
objectConfigData->_configProxy = configProxy;
LocalSnapshotManager *localSnapshotManager = new LocalSnapshotManager(appConfigManager);
objectConfigData->_localSnapshotManager = localSnapshotManager;
ClientWorker *clientWorker = new ClientWorker(objectConfigData);
objectConfigData->_clientWorker = clientWorker;
objectConfigData->checkAssembledObject();
ConfigService *instance = new NacosConfigService(objectConfigData);
log_debug("Created config data: %s", objectConfigData->name.c_str());
return instance;
}
NamingMaintainService *NacosServiceFactory::CreateNamingMaintainService() NACOS_THROW(NacosException){
Init::doInit();
checkConfig();
ObjectConfigData *objectConfigData = new ObjectConfigData(MAINTAIN);
objectConfigData->name = "config";
objectConfigData->encoding = "UTF-8";
AppConfigManager *appConfigManager = buildConfigManager(objectConfigData);
initializeRuntimeLogSettings(appConfigManager);
//Create http client
IHttpCli *httpCli= new HTTPCli();
objectConfigData->_httpCli = httpCli;
buildSecurityManagerAndHttpDelegate(objectConfigData);
//Create server manager
ServerListManager *serverListManager = new ServerListManager(objectConfigData);
objectConfigData->_serverListManager = serverListManager;
//Create naming service & heartbeat sender
NamingProxy *namingProxy = new NamingProxy(objectConfigData);
objectConfigData->_serverProxy = namingProxy;
NacosNamingMaintainService *instance = new NacosNamingMaintainService(objectConfigData);
log_debug("Created config data: %s", objectConfigData->name.c_str());
return instance;
}
NacosServiceFactory::~NacosServiceFactory() {
}
void NacosServiceFactory::checkConfig() NACOS_THROW(InvalidFactoryConfigException) {
if (!configIsSet && !propsIsSet) {
throw InvalidFactoryConfigException();
}
}
void NacosServiceFactory::setConfig(const NacosString &_configFile) {
configIsSet = true;
configFile = _configFile;
};
void NacosServiceFactory::setProps(Properties &_props) {
propsIsSet = true;
props = _props;
};
NacosServiceFactory::NacosServiceFactory() {
configIsSet = false;
propsIsSet = false;
setConfig(DirUtils::getCwd() + "/" + ConfigConstant::DEFAULT_CONFIG_FILE);
}
NacosServiceFactory::NacosServiceFactory(const NacosString &_configFile) {
configIsSet = false;
propsIsSet = false;
setConfig(_configFile);
}
NacosServiceFactory::NacosServiceFactory(Properties &_props) {
configIsSet = false;
propsIsSet = false;
setProps(_props);
}
}//namespace nacos
================================================
FILE: src/factory/NacosServiceFactory.h
================================================
//
// Created by liuhanyu on 2020/8/30.
//
#ifndef NACOS_SDK_CPP_NACOSSERVICEFACTORY_H
#define NACOS_SDK_CPP_NACOSSERVICEFACTORY_H
#include "factory/INacosServiceFactory.h"
#include "Compatibility.h"
#include "src/thread/Mutex.h"
namespace nacos{
class AppConfigManager;
class ObjectConfigData;
class NacosServiceFactory : public INacosServiceFactory {
private:
NacosString configFile;
Properties props;
bool configIsSet;
bool propsIsSet;
Mutex logSysInitLock;
static volatile bool logSystemInitiali
gitextract_q11n9gsq/
├── .gitignore
├── LICENSE
├── README.md
├── README_zh_CN.md
├── examples/
│ ├── IntegratingIntoYourProject.cpp
│ ├── generate_examples.sh
│ ├── getAllInstances.cpp
│ ├── getConfig.cpp
│ ├── listenToKeys.cpp
│ ├── registerInstances.cpp
│ ├── setConfig.cpp
│ └── subscribeServices.cpp
├── include/
│ ├── Compatibility.h
│ ├── Nacos.h
│ ├── NacosExceptions.h
│ ├── NacosString.h
│ ├── Properties.h
│ ├── ResourceGuard.h
│ ├── config/
│ │ └── ConfigService.h
│ ├── constant/
│ │ ├── ConfigConstant.h
│ │ ├── NamingConstant.h
│ │ ├── PropertyKeyConst.h
│ │ └── UtilAndComs.h
│ ├── factory/
│ │ ├── INacosServiceFactory.h
│ │ └── NacosFactoryFactory.h
│ ├── listen/
│ │ └── Listener.h
│ ├── naming/
│ │ ├── ChangeAdvice.h
│ │ ├── Cluster.h
│ │ ├── Instance.h
│ │ ├── ListView.h
│ │ ├── NamingMaintainService.h
│ │ ├── NamingService.h
│ │ ├── ServiceInfo.h
│ │ ├── ServiceInfo2.h
│ │ ├── selectors/
│ │ │ ├── HealthInstanceSelector.h
│ │ │ ├── RandomByWeightSelector.h
│ │ │ ├── RandomSelector.h
│ │ │ └── Selector.h
│ │ └── subscribe/
│ │ └── EventListener.h
│ ├── server/
│ │ └── ServerSelector.h
│ └── thread/
│ └── AtomicInt.h
├── nacos-cpp-cli.properties
├── src/
│ ├── NacosExceptions.cpp
│ ├── NacosString.cpp
│ ├── config/
│ │ ├── AppConfigManager.cpp
│ │ ├── AppConfigManager.h
│ │ ├── ConcurrentDiskUtil.cpp
│ │ ├── ConcurrentDiskUtil.h
│ │ ├── ConfigProxy.cpp
│ │ ├── ConfigProxy.h
│ │ ├── IOUtils.cpp
│ │ ├── IOUtils.h
│ │ ├── JVMUtil.h
│ │ ├── LocalSnapshotManager.cpp
│ │ ├── LocalSnapshotManager.h
│ │ ├── NacosConfigService.cpp
│ │ ├── NacosConfigService.h
│ │ ├── SnapShotSwitch.cpp
│ │ └── SnapShotSwitch.h
│ ├── constant/
│ │ ├── ConfigConstant.cpp
│ │ ├── NamingConstant.cpp
│ │ ├── PropertyKeyConst.cpp
│ │ └── UtilAndComs.cpp
│ ├── crypto/
│ │ ├── MACProvider.cpp
│ │ ├── MACProvider.h
│ │ ├── SignatureTool.h
│ │ ├── base64/
│ │ │ └── base64.h
│ │ ├── hmac_sha1/
│ │ │ ├── LICENSE
│ │ │ ├── README.md
│ │ │ ├── hmac/
│ │ │ │ ├── hmac.h
│ │ │ │ └── hmac_sha1.cpp
│ │ │ └── sha/
│ │ │ ├── sha.h
│ │ │ └── sha1.cpp
│ │ └── md5/
│ │ ├── md5.cpp
│ │ └── md5.h
│ ├── debug/
│ │ └── DebugAssertion.h
│ ├── factory/
│ │ ├── NacosFactoryFactory.cpp
│ │ ├── NacosServiceFactory.cpp
│ │ ├── NacosServiceFactory.h
│ │ ├── ObjectConfigData.cpp
│ │ └── ObjectConfigData.h
│ ├── http/
│ │ ├── HTTPCli.cpp
│ │ ├── HTTPCli.h
│ │ ├── HttpDelegate.h
│ │ ├── HttpStatus.h
│ │ ├── IHttpCli.h
│ │ └── delegate/
│ │ ├── NacosAuthHttpDelegate.cpp
│ │ ├── NacosAuthHttpDelegate.h
│ │ ├── NoOpHttpDelegate.cpp
│ │ └── NoOpHttpDelegate.h
│ ├── init/
│ │ ├── Init.cpp
│ │ └── Init.h
│ ├── json/
│ │ ├── JSON.cpp
│ │ ├── JSON.h
│ │ └── rapidjson/
│ │ ├── allocators.h
│ │ ├── cursorstreamwrapper.h
│ │ ├── document.h
│ │ ├── encodedstream.h
│ │ ├── encodings.h
│ │ ├── error/
│ │ │ ├── en.h
│ │ │ └── error.h
│ │ ├── filereadstream.h
│ │ ├── filewritestream.h
│ │ ├── fwd.h
│ │ ├── internal/
│ │ │ ├── biginteger.h
│ │ │ ├── diyfp.h
│ │ │ ├── dtoa.h
│ │ │ ├── ieee754.h
│ │ │ ├── itoa.h
│ │ │ ├── meta.h
│ │ │ ├── pow10.h
│ │ │ ├── regex.h
│ │ │ ├── stack.h
│ │ │ ├── strfunc.h
│ │ │ ├── strtod.h
│ │ │ └── swap.h
│ │ ├── istreamwrapper.h
│ │ ├── memorybuffer.h
│ │ ├── memorystream.h
│ │ ├── msinttypes/
│ │ │ ├── inttypes.h
│ │ │ └── stdint.h
│ │ ├── ostreamwrapper.h
│ │ ├── pointer.h
│ │ ├── prettywriter.h
│ │ ├── rapidjson.h
│ │ ├── reader.h
│ │ ├── schema.h
│ │ ├── stream.h
│ │ ├── stringbuffer.h
│ │ └── writer.h
│ ├── listen/
│ │ ├── ClientWorker.cpp
│ │ ├── ClientWorker.h
│ │ ├── ListeningData.h
│ │ └── OperateItem.h
│ ├── log/
│ │ ├── Logger.cpp
│ │ └── Logger.h
│ ├── naming/
│ │ ├── Cluster.cpp
│ │ ├── Instance.cpp
│ │ ├── NacosNamingMaintainService.cpp
│ │ ├── NacosNamingMaintainService.h
│ │ ├── NacosNamingService.cpp
│ │ ├── NacosNamingService.h
│ │ ├── NamingProxy.cpp
│ │ ├── NamingProxy.h
│ │ ├── ServiceInfo.cpp
│ │ ├── beat/
│ │ │ ├── BeatInfo.cpp
│ │ │ ├── BeatInfo.h
│ │ │ ├── BeatReactor.cpp
│ │ │ ├── BeatReactor.h
│ │ │ ├── BeatTask.cpp
│ │ │ └── BeatTask.h
│ │ ├── cache/
│ │ │ ├── ChangeAdvice.cpp
│ │ │ ├── NamingCache.cpp
│ │ │ └── NamingCache.h
│ │ ├── selectors/
│ │ │ ├── HealthInstanceSelector.cpp
│ │ │ ├── RandomByWeightSelector.cpp
│ │ │ └── RandomSelector.cpp
│ │ └── subscribe/
│ │ ├── EventDispatcher.cpp
│ │ ├── EventDispatcher.h
│ │ ├── EventListener.cpp
│ │ ├── HostReactor.cpp
│ │ ├── HostReactor.h
│ │ ├── SubscriptionPoller.cpp
│ │ ├── SubscriptionPoller.h
│ │ ├── UdpNamingServiceListener.cpp
│ │ └── UdpNamingServiceListener.h
│ ├── security/
│ │ ├── SecurityManager.cpp
│ │ └── SecurityManager.h
│ ├── server/
│ │ ├── NacosServerInfo.h
│ │ ├── ServerListManager.cpp
│ │ └── ServerListManager.h
│ ├── thread/
│ │ ├── BlockingQueue.h
│ │ ├── DelayedThreadPool.cpp
│ │ ├── DelayedThreadPool.h
│ │ ├── Mutex.h
│ │ ├── RWLock.h
│ │ ├── Task.h
│ │ ├── Thread.cpp
│ │ ├── Thread.h
│ │ ├── ThreadLocal.h
│ │ ├── ThreadPool.cpp
│ │ ├── ThreadPool.h
│ │ ├── Tid.cpp
│ │ └── Tid.h
│ └── utils/
│ ├── ConfigParserUtils.cpp
│ ├── ConfigParserUtils.h
│ ├── DirUtils.cpp
│ ├── DirUtils.h
│ ├── Env.h
│ ├── GroupKey.h
│ ├── NamingUtils.h
│ ├── NetUtils.cpp
│ ├── NetUtils.h
│ ├── ParamUtils.h
│ ├── RandomUtils.cpp
│ ├── RandomUtils.h
│ ├── SequenceProvider.h
│ ├── TimeUtils.cpp
│ ├── TimeUtils.h
│ ├── UuidUtils.cpp
│ ├── UuidUtils.h
│ ├── url.cpp
│ └── url.h
└── test/
├── allinone.cpp
└── testcase/
├── AssertString.cpp
├── DebugTest.cpp
├── testAppConfigManager.cpp
├── testCache.cpp
├── testDelayedThreadPool.cpp
├── testDeleteConfig.cpp
├── testDeleteListenedKeys.cpp
├── testEndpointWithNamingSvc.cpp
├── testGetAllInstances.cpp
├── testGetConfig.cpp
├── testGetServiceNames.cpp
├── testHttpRequest.cpp
├── testIOUtils.cpp
├── testInstanceSelector.cpp
├── testJson2BizObjects.cpp
├── testListenWorker.cpp
├── testListeningKeys.cpp
├── testListeningKeysWithHttpPrefix.cpp
├── testMAC.cpp
├── testMD5.cpp
├── testMaintainInstances.cpp
├── testMaintainServices.cpp
├── testNamingService.cpp
├── testNamingSubscribe.cpp
├── testNetUtils.cpp
├── testPublishConfig.cpp
├── testPublishConfigWithHttpPrefix.cpp
├── testRapidJson.cpp
├── testSequenceProvider.cpp
├── testServerListManager.cpp
├── testStringExplode.cpp
├── testThreadLocal.cpp
├── testThreadSmoke.cpp
├── testURL.cpp
└── testUUID.cpp
SYMBOL INDEX (1120 symbols across 224 files)
FILE: examples/IntegratingIntoYourProject.cpp
function main (line 7) | int main() {
FILE: examples/getAllInstances.cpp
function main (line 8) | int main() {
FILE: examples/getConfig.cpp
function main (line 7) | int main() {
FILE: examples/listenToKeys.cpp
class MyListener (line 8) | class MyListener : public Listener {
method MyListener (line 12) | MyListener(int num) {
method receiveConfigInfo (line 16) | void receiveConfigInfo(const NacosString &configInfo) {
function main (line 24) | int main() {
FILE: examples/registerInstances.cpp
function main (line 8) | int main() {
FILE: examples/setConfig.cpp
function main (line 7) | int main() {
FILE: examples/subscribeServices.cpp
class MyServiceListener (line 8) | class MyServiceListener : public EventListener {
method MyServiceListener (line 12) | MyServiceListener(int num) {
method receiveNamingInfo (line 16) | void receiveNamingInfo(const ServiceInfo &serviceInfo){
function main (line 25) | int main() {
FILE: include/NacosExceptions.h
function namespace (line 8) | namespace nacos{
FILE: include/NacosString.h
function namespace (line 11) | namespace nacos{
FILE: include/Properties.h
function namespace (line 7) | namespace nacos{
FILE: include/ResourceGuard.h
function namespace (line 8) | namespace nacos{
FILE: include/config/ConfigService.h
function namespace (line 8) | namespace nacos{
FILE: include/constant/ConfigConstant.h
function namespace (line 12) | namespace nacos{
FILE: include/constant/NamingConstant.h
function namespace (line 6) | namespace nacos{
FILE: include/constant/PropertyKeyConst.h
function namespace (line 6) | namespace nacos{
FILE: include/constant/UtilAndComs.h
function namespace (line 6) | namespace nacos{
FILE: include/factory/INacosServiceFactory.h
function namespace (line 13) | namespace nacos{
FILE: include/factory/NacosFactoryFactory.h
function namespace (line 4) | namespace nacos {
FILE: include/listen/Listener.h
function namespace (line 7) | namespace nacos{
FILE: include/naming/ChangeAdvice.h
function namespace (line 8) | namespace nacos{
FILE: include/naming/Cluster.h
function namespace (line 7) | namespace nacos{
FILE: include/naming/Instance.h
function namespace (line 7) | namespace nacos{
FILE: include/naming/ListView.h
function namespace (line 7) | namespace nacos{
FILE: include/naming/NamingMaintainService.h
function namespace (line 12) | namespace nacos{
FILE: include/naming/NamingService.h
function namespace (line 13) | namespace nacos{
FILE: include/naming/ServiceInfo.h
function namespace (line 8) | namespace nacos{
FILE: include/naming/ServiceInfo2.h
function namespace (line 8) | namespace nacos{ namespace naming {
FILE: include/naming/selectors/HealthInstanceSelector.h
function namespace (line 7) | namespace nacos { namespace naming { namespace selectors {
FILE: include/naming/selectors/RandomByWeightSelector.h
function namespace (line 9) | namespace nacos { namespace naming { namespace selectors {
FILE: include/naming/selectors/RandomSelector.h
function namespace (line 7) | namespace nacos { namespace naming { namespace selectors {
FILE: include/naming/selectors/Selector.h
function namespace (line 7) | namespace nacos { namespace naming { namespace selectors {
FILE: include/naming/subscribe/EventListener.h
function namespace (line 12) | namespace nacos{
FILE: include/server/ServerSelector.h
function namespace (line 13) | namespace nacos{
FILE: include/thread/AtomicInt.h
function namespace (line 4) | namespace nacos{
FILE: src/NacosExceptions.cpp
type nacos (line 3) | namespace nacos{
function NACOS_NOTHROW (line 4) | NACOS_NOTHROW() {
function NACOS_NOTHROW (line 9) | NACOS_NOTHROW() {
FILE: src/NacosString.cpp
type nacos (line 6) | namespace nacos{
function NacosString (line 17) | NacosString NacosStringOps::valueOf<bool>(bool val) {
FILE: src/config/AppConfigManager.cpp
type nacos (line 17) | namespace nacos{
function NACOS_THROW (line 27) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 33) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 42) | NACOS_THROW(NacosException) {
function NacosString (line 53) | const NacosString& AppConfigManager::get(const NacosString &key) {
function NacosString (line 97) | NacosString getAppNameFromEnv() {
FILE: src/config/AppConfigManager.h
function namespace (line 9) | namespace nacos{
FILE: src/config/ConcurrentDiskUtil.cpp
type nacos (line 17) | namespace nacos{
function NACOS_THROW (line 19) | NACOS_THROW(IOException) {
function NACOS_THROW (line 56) | NACOS_THROW(IOException) {
FILE: src/config/ConcurrentDiskUtil.h
function namespace (line 8) | namespace nacos{
FILE: src/config/ConfigProxy.cpp
type nacos (line 13) | namespace nacos {
function NacosString (line 15) | NacosString ConfigProxy::getDataToSign(const std::list <NacosString> &...
function NACOS_THROW (line 43) | NACOS_THROW(NetworkException) {
FILE: src/config/ConfigProxy.h
function namespace (line 10) | namespace nacos {
FILE: src/config/IOUtils.cpp
type nacos (line 13) | namespace nacos{
type stat (line 15) | struct stat
function NACOS_THROW (line 24) | NACOS_THROW(IOException) {
function NACOS_THROW (line 38) | NACOS_THROW(IOException) {
type stat (line 48) | struct stat
type stat (line 76) | struct stat
function NacosString (line 100) | NacosString IOUtils::getParentFile(const NacosString &thefile) {
type stat (line 113) | struct stat
type dirent (line 123) | struct dirent
type stat (line 130) | struct stat
type stat (line 156) | struct stat
type dirent (line 170) | struct dirent
type stat (line 200) | struct stat
type dirent (line 214) | struct dirent
FILE: src/config/IOUtils.h
function namespace (line 9) | namespace nacos{
FILE: src/config/JVMUtil.h
function namespace (line 4) | namespace nacos{
FILE: src/config/LocalSnapshotManager.cpp
type nacos (line 19) | namespace nacos{
function NacosString (line 21) | NacosString LocalSnapshotManager::getFailover(const NacosString &serve...
function NacosString (line 42) | NacosString LocalSnapshotManager::getSnapshot
function NACOS_THROW (line 65) | NACOS_THROW(IOException) {
function NacosString (line 135) | NacosString LocalSnapshotManager::getFailoverFile(const NacosString &s...
function NacosString (line 153) | NacosString LocalSnapshotManager::getSnapshotFile(const NacosString &e...
FILE: src/config/LocalSnapshotManager.h
function namespace (line 15) | namespace nacos{
FILE: src/config/NacosConfigService.cpp
type nacos (line 9) | namespace nacos{
function NACOS_THROW (line 10) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 28) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 37) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 45) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 55) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 95) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 145) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 208) | NACOS_THROW(NacosException) {
FILE: src/config/NacosConfigService.h
function namespace (line 13) | namespace nacos{
FILE: src/config/SnapShotSwitch.cpp
type nacos (line 4) | namespace nacos{
FILE: src/config/SnapShotSwitch.h
function namespace (line 4) | namespace nacos{
FILE: src/constant/ConfigConstant.cpp
type nacos (line 9) | namespace nacos{
FILE: src/constant/NamingConstant.cpp
type nacos (line 3) | namespace nacos{
FILE: src/constant/PropertyKeyConst.cpp
type nacos (line 3) | namespace nacos{
FILE: src/constant/UtilAndComs.cpp
type nacos (line 3) | namespace nacos{
FILE: src/crypto/MACProvider.cpp
type nacos (line 8) | namespace nacos {
class HMACSha1 (line 13) | class HMACSha1 : public IMAC {
function IMAC (line 46) | IMAC *MACProvider::getMAC(int algorithm) {
FILE: src/crypto/MACProvider.h
function namespace (line 10) | namespace nacos {
FILE: src/crypto/SignatureTool.h
function namespace (line 13) | namespace nacos {
FILE: src/crypto/base64/base64.h
function namespace (line 14) | namespace nacos {
FILE: src/crypto/hmac_sha1/hmac/hmac_sha1.cpp
function hmac_sha1 (line 38) | void hmac_sha1(const uint8_t *k, /* secret key */
FILE: src/crypto/hmac_sha1/sha/sha.h
type SHA1_CTX (line 18) | typedef struct {
type SHA1_CTX (line 27) | typedef SHA1_CTX SHA_CTX;
FILE: src/crypto/hmac_sha1/sha/sha1.cpp
function SHA1_Transform (line 132) | void SHA1_Transform(uint32_t state[5], const uint8_t buffer[64]) {
function SHA1_Init (line 254) | void SHA1_Init(SHA1_CTX *context) {
function SHA1_Update (line 272) | void SHA1_Update(SHA1_CTX *context, const void *p, size_t len) {
function SHA1_Final (line 300) | void SHA1_Final(uint8_t digest[SHA1_DIGEST_SIZE], SHA1_CTX *context) {
FILE: src/crypto/md5/md5.cpp
type nacos (line 60) | namespace nacos{
function byte (line 94) | const byte *MD5::digest() {
function NacosString (line 324) | NacosString MD5::bytesToHexString(const byte *input, size_t length) {
function NacosString (line 338) | NacosString MD5::toString() {
FILE: src/crypto/md5/md5.h
function namespace (line 9) | namespace nacos{
FILE: src/debug/DebugAssertion.h
function namespace (line 8) | namespace nacos{
FILE: src/factory/NacosFactoryFactory.cpp
type nacos (line 3) | namespace nacos {
function INacosServiceFactory (line 5) | INacosServiceFactory *NacosFactoryFactory::getNacosFactory(const Nacos...
function INacosServiceFactory (line 10) | INacosServiceFactory *NacosFactoryFactory::getNacosFactory(Properties ...
FILE: src/factory/NacosServiceFactory.cpp
type nacos (line 27) | namespace nacos{
function buildSecurityManagerAndHttpDelegate (line 31) | void buildSecurityManagerAndHttpDelegate(ObjectConfigData *objectConfi...
function AppConfigManager (line 45) | AppConfigManager *NacosServiceFactory::buildConfigManager(ObjectConfig...
function NACOS_THROW (line 81) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 130) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 166) | NACOS_THROW(NacosException){
function NACOS_THROW (line 200) | NACOS_THROW(InvalidFactoryConfigException) {
FILE: src/factory/NacosServiceFactory.h
function namespace (line 12) | namespace nacos{
FILE: src/factory/ObjectConfigData.cpp
type nacos (line 16) | namespace nacos{
function NACOS_THROW (line 35) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 54) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 68) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 263) | NACOS_THROW(NacosException) {
FILE: src/factory/ObjectConfigData.h
function namespace (line 10) | namespace nacos{
FILE: src/http/HTTPCli.cpp
type nacos (line 9) | namespace nacos{
function receiveResponseCallback (line 10) | static size_t
function receiveHeaderCallback (line 25) | static size_t receiveHeaderCallback(
function CURL (line 53) | CURL *HTTPCli::getCurlHandle() {
function NacosString (line 85) | NacosString HTTPCli::encodingParams(list <NacosString> ¶ms) {
function NacosString (line 99) | NacosString HTTPCli::encodingParams(map <NacosString, NacosString> &pa...
function NACOS_THROW (line 129) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 142) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 155) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 250) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 264) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 278) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 376) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 390) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 404) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 494) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 507) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 520) | NACOS_THROW(NetworkException) {
FILE: src/http/HTTPCli.h
function namespace (line 12) | namespace nacos{
FILE: src/http/HttpDelegate.h
function namespace (line 14) | namespace nacos{
FILE: src/http/HttpStatus.h
function class (line 7) | class HttpStatus
FILE: src/http/IHttpCli.h
function namespace (line 16) | namespace nacos{
FILE: src/http/delegate/NacosAuthHttpDelegate.cpp
type nacos (line 10) | namespace nacos {
function NacosString (line 11) | NacosString NacosAuthHttpDelegate::getEncode() const {
function NACOS_THROW (line 26) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 40) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 54) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 68) | NACOS_THROW(NetworkException) {
FILE: src/http/delegate/NacosAuthHttpDelegate.h
function namespace (line 20) | namespace nacos{
FILE: src/http/delegate/NoOpHttpDelegate.cpp
type nacos (line 5) | namespace nacos{
function NacosString (line 6) | NacosString NoOpHttpDelegate::getEncode() const {
function NACOS_THROW (line 24) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 38) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 51) | NACOS_THROW(NetworkException) {
function NACOS_THROW (line 65) | NACOS_THROW(NetworkException) {
FILE: src/http/delegate/NoOpHttpDelegate.h
function namespace (line 16) | namespace nacos{
FILE: src/init/Init.cpp
type nacos (line 13) | namespace nacos{
FILE: src/init/Init.h
function namespace (line 6) | namespace nacos{
FILE: src/json/JSON.cpp
type nacos (line 15) | namespace nacos{
function NacosString (line 16) | NacosString documentToString(const Document &d) {
function NacosString (line 24) | NacosString valueToString(const Value &d) {
function NacosString (line 32) | NacosString JSON::toJSONString(const map <NacosString, NacosString> &m...
function AddKV (line 66) | void AddKV(Document &d, const NacosString &k, const NacosString &v) {
function AddKO (line 74) | void AddKO(Document &d, const NacosString &k, Value &o) {
function NacosString (line 80) | NacosString JSON::toJSONString(BeatInfo &beatInfo) {
function NACOS_THROW (line 110) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 166) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 219) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 225) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 231) | NACOS_THROW(NacosException) {
function NacosServerInfo (line 287) | NacosServerInfo parseOneNacosSvr(const Value &curSvr) {
function NACOS_THROW (line 303) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 329) | NACOS_THROW(NacosException) {
function parseMetadata (line 365) | map<NacosString, NacosString> parseMetadata(const Value &value) {
function NACOS_THROW (line 376) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 425) | NACOS_THROW(NacosException)
function NACOS_THROW (line 443) | NACOS_THROW(NacosException)
FILE: src/json/JSON.h
function namespace (line 25) | namespace nacos{
FILE: src/json/rapidjson/allocators.h
function class (line 75) | class CrtAllocator {
function Clear (line 158) | void Clear() {
function Capacity (line 171) | size_t Capacity() const {
function Free (line 238) | static void Free(void *ptr) { (void)ptr; }
function AddChunk (line 250) | bool AddChunk(size_t capacity) {
type ChunkHeader (line 269) | struct ChunkHeader {
FILE: src/json/rapidjson/cursorstreamwrapper.h
function Ch (line 47) | Ch Take() {
FILE: src/json/rapidjson/document.h
type GenericMember (line 107) | typedef GenericMember<Encoding,Allocator> PlainType;
type typename (line 108) | typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
type ValueType (line 120) | typedef ValueType value_type;
type ValueType (line 121) | typedef ValueType * pointer;
type ValueType (line 122) | typedef ValueType & reference;
type std (line 123) | typedef std::ptrdiff_t difference_type;
type std (line 124) | typedef std::random_access_iterator_tag iterator_category;
type pointer (line 128) | typedef pointer Pointer;
type reference (line 130) | typedef reference Reference;
type difference_type (line 132) | typedef difference_type DifferenceType;
function ptr_ (line 156) | GenericMemberIterator(const NonConstIterator & it) : ptr_(it.ptr_) {}
function ConstIterator (line 178) | bool operator==(ConstIterator that) const { return ptr_ == that.ptr_; }
function ConstIterator (line 179) | bool operator!=(ConstIterator that) const { return ptr_ != that.ptr_; }
function ConstIterator (line 180) | bool operator<=(ConstIterator that) const { return ptr_ <= that.ptr_; }
function ConstIterator (line 181) | bool operator>=(ConstIterator that) const { return ptr_ >= that.ptr_; }
function operator (line 182) | bool operator< (ConstIterator that) const { return ptr_ < that.ptr_; }
function operator (line 183) | bool operator> (ConstIterator that) const { return ptr_ > that.ptr_; }
function Reference (line 188) | Reference operator*() const { return *ptr_; }
function Pointer (line 189) | Pointer operator->() const { return ptr_; }
function Reference (line 190) | Reference operator[](DifferenceType n) const { return ptr_[n]; }
type CharType (line 257) | typedef CharType Ch;
function explicit (line 309) | explicit GenericStringRef(const CharType* str)
function operator (line 327) | operator const Ch *() const { return s; }
function namespace (line 409) | namespace internal {
function Is (line 433) | static bool Is(const ValueType& v) { return v.IsBool(); }
function Get (line 434) | static bool Get(const ValueType& v) { return v.GetBool(); }
function Is (line 441) | static bool Is(const ValueType& v) { return v.IsInt(); }
function Get (line 442) | static int Get(const ValueType& v) { return v.GetInt(); }
function Is (line 449) | static bool Is(const ValueType& v) { return v.IsUint(); }
function Get (line 450) | static unsigned Get(const ValueType& v) { return v.GetUint(); }
function Is (line 459) | static bool Is(const ValueType& v) { return v.IsInt(); }
function Get (line 460) | static long Get(const ValueType& v) { return v.GetInt(); }
function Is (line 468) | static bool Is(const ValueType& v) { return v.IsUint(); }
function Get (line 469) | static unsigned long Get(const ValueType& v) { return v.GetUint(); }
function Is (line 477) | static bool Is(const ValueType& v) { return v.IsInt64(); }
function Get (line 478) | static int64_t Get(const ValueType& v) { return v.GetInt64(); }
function Is (line 485) | static bool Is(const ValueType& v) { return v.IsUint64(); }
function Get (line 486) | static uint64_t Get(const ValueType& v) { return v.GetUint64(); }
function Is (line 493) | static bool Is(const ValueType& v) { return v.IsDouble(); }
function Get (line 494) | static double Get(const ValueType& v) { return v.GetDouble(); }
function Is (line 501) | static bool Is(const ValueType& v) { return v.IsFloat(); }
function Get (line 502) | static float Get(const ValueType& v) { return v.GetFloat(); }
type typename (line 509) | typedef const typename ValueType::Ch* StringType;
function Is (line 510) | static bool Is(const ValueType& v) { return v.IsString(); }
function StringType (line 511) | static StringType Get(const ValueType& v) { return v.GetString(); }
function Is (line 520) | static bool Is(const ValueType& v) { return v.IsString(); }
function StringType (line 521) | static StringType Get(const ValueType& v) { return StringType(v.GetStrin...
type typename (line 528) | typedef typename ValueType::Array ArrayType;
function Is (line 529) | static bool Is(const ValueType& v) { return v.IsArray(); }
function ArrayType (line 530) | static ArrayType Get(ValueType& v) { return v.GetArray(); }
type typename (line 537) | typedef typename ValueType::ConstArray ArrayType;
function Is (line 538) | static bool Is(const ValueType& v) { return v.IsArray(); }
function ArrayType (line 539) | static ArrayType Get(const ValueType& v) { return v.GetArray(); }
type typename (line 544) | typedef typename ValueType::Object ObjectType;
function Is (line 545) | static bool Is(const ValueType& v) { return v.IsObject(); }
function ObjectType (line 546) | static ObjectType Get(ValueType& v) { return v.GetObject(); }
type typename (line 553) | typedef typename ValueType::ConstObject ObjectType;
function Is (line 554) | static bool Is(const ValueType& v) { return v.IsObject(); }
function ObjectType (line 555) | static ObjectType Get(const ValueType& v) { return v.GetObject(); }
type Encoding (line 582) | typedef Encoding EncodingType;
type Allocator (line 583) | typedef Allocator AllocatorType;
type typename (line 584) | typedef typename Encoding::Ch Ch;
type GenericStringRef (line 585) | typedef GenericStringRef<Ch> StringRefType;
type typename (line 586) | typedef typename GenericMemberIterator<false,Encoding,Allocator>::Iterat...
type typename (line 587) | typedef typename GenericMemberIterator<true,Encoding,Allocator>::Iterato...
type GenericValue (line 588) | typedef GenericValue* ValueIterator;
type GenericValue (line 589) | typedef const GenericValue* ConstValueIterator;
type GenericValue (line 590) | typedef GenericValue<Encoding, Allocator> ValueType;
function explicit (line 703) | explicit GenericValue(bool b) RAPIDJSON_NOEXCEPT
function explicit (line 712) | explicit GenericValue(int i) RAPIDJSON_NOEXCEPT : data_() {
function explicit (line 718) | explicit GenericValue(unsigned u) RAPIDJSON_NOEXCEPT : data_() {
function explicit (line 724) | explicit GenericValue(int64_t i64) RAPIDJSON_NOEXCEPT : data_() {
function explicit (line 739) | explicit GenericValue(uint64_t u64) RAPIDJSON_NOEXCEPT : data_() {
function explicit (line 751) | explicit GenericValue(double d) RAPIDJSON_NOEXCEPT : data_() { data_.n.d...
function explicit (line 754) | explicit GenericValue(float f) RAPIDJSON_NOEXCEPT : data_() { data_.n.d ...
function explicit (line 760) | explicit GenericValue(StringRefType s) RAPIDJSON_NOEXCEPT : data_() { Se...
function data_ (line 781) | GenericValue(Array a) RAPIDJSON_NOEXCEPT : data_(a.value_.data_) {
function data_ (line 792) | GenericValue(Object o) RAPIDJSON_NOEXCEPT : data_(o.value_.data_) {
type GenericValue (line 936) | typedef GenericValue<Encoding, SourceAllocator> RhsType;
function rhs (line 983) | bool operator==(const std::basic_string<Ch>& rhs) const { return *this =...
function GetBool (line 1084) | bool GetBool() const { RAPIDJSON_ASSERT(IsBool()); return data_.f.flags ...
function SizeType (line 1099) | SizeType MemberCount() const { RAPIDJSON_ASSERT(IsObject()); return data...
function ObjectEmpty (line 1105) | bool ObjectEmpty() const { RAPIDJSON_ASSERT(IsObject()); return data_.o....
function GenericValue (line 1156) | const GenericValue& operator[](const std::basic_string<Ch>& name) const ...
function ConstMemberIterator (line 1161) | ConstMemberIterator MemberBegin() const { RAPIDJSON_ASSERT(IsObject()); ...
function MemberIterator (line 1167) | MemberIterator MemberBegin() { RAPIDJSON_ASSERT(IsObject()); ...
function MemberIterator (line 1170) | MemberIterator MemberEnd() { RAPIDJSON_ASSERT(IsObject()); ...
function HasMember (line 1195) | bool HasMember(const Ch* name) const { return FindMember(name) != Member...
function HasMember (line 1206) | bool HasMember(const std::basic_string<Ch>& name) const { return FindMem...
function MemberIterator (line 1233) | MemberIterator FindMember(const Ch* name) {
function ConstMemberIterator (line 1238) | ConstMemberIterator FindMember(const Ch* name) const { return const_cast...
function MemberIterator (line 1273) | MemberIterator FindMember(const std::basic_string<Ch>& name) { return Fi...
function ConstMemberIterator (line 1274) | ConstMemberIterator FindMember(const std::basic_string<Ch>& name) const ...
function RemoveAllMembers (line 1429) | void RemoveAllMembers() {
function RemoveMember (line 1444) | bool RemoveMember(const Ch* name) {
function MemberIterator (line 1472) | MemberIterator RemoveMember(MemberIterator m) {
function MemberIterator (line 1496) | MemberIterator EraseMember(ConstMemberIterator pos) {
function MemberIterator (line 1509) | MemberIterator EraseMember(ConstMemberIterator first, ConstMemberIterato...
function EraseMember (line 1530) | bool EraseMember(const Ch* name) {
function Object (line 1550) | Object GetObject() { RAPIDJSON_ASSERT(IsObject()); return Object(*this); }
function ConstObject (line 1551) | ConstObject GetObject() const { RAPIDJSON_ASSERT(IsObject()); return Con...
function SizeType (line 1563) | SizeType Size() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size; }
function Empty (line 1569) | bool Empty() const { RAPIDJSON_ASSERT(IsArray()); return data_.a.size ==...
function GenericValue (line 1593) | const GenericValue& operator[](SizeType index) const { return const_cast...
function ValueIterator (line 1597) | ValueIterator Begin() { RAPIDJSON_ASSERT(IsArray()); return GetElementsP...
function ValueIterator (line 1600) | ValueIterator End() { RAPIDJSON_ASSERT(IsArray()); return GetElementsPoi...
function ValueIterator (line 1702) | ValueIterator Erase(ConstValueIterator pos) {
function ValueIterator (line 1714) | ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) {
function Array (line 1729) | Array GetArray() { RAPIDJSON_ASSERT(IsArray()); return Array(*this); }
function ConstArray (line 1730) | ConstArray GetArray() const { RAPIDJSON_ASSERT(IsArray()); return ConstA...
function GetDouble (line 1745) | double GetDouble() const {
function Ch (line 1773) | const Ch* GetString() const { RAPIDJSON_ASSERT(IsString()); return (data...
function SizeType (line 1778) | SizeType GetStringLength() const { RAPIDJSON_ASSERT(IsString()); return ...
type Flag (line 1945) | struct Flag {
type String (line 1956) | struct String {
function SetLength (line 1970) | struct ShortString {
type I (line 1982) | struct I {
type U (line 1986) | struct U {
type I (line 1991) | struct I {
type U (line 1995) | struct U {
type ObjectData (line 2005) | struct ObjectData {
type ArrayData (line 2011) | struct ArrayData {
function RAPIDJSON_FORCEINLINE (line 2026) | RAPIDJSON_FORCEINLINE const Ch* GetStringPointer() const { return RAPIDJ...
function RAPIDJSON_FORCEINLINE (line 2027) | RAPIDJSON_FORCEINLINE const Ch* SetStringPointer(const Ch* str) { return...
function RAPIDJSON_FORCEINLINE (line 2028) | RAPIDJSON_FORCEINLINE GenericValue* GetElementsPointer() const { return ...
function RAPIDJSON_FORCEINLINE (line 2029) | RAPIDJSON_FORCEINLINE GenericValue* SetElementsPointer(GenericValue* ele...
function RAPIDJSON_FORCEINLINE (line 2030) | RAPIDJSON_FORCEINLINE Member* GetMembersPointer() const { return RAPIDJS...
function RAPIDJSON_FORCEINLINE (line 2031) | RAPIDJSON_FORCEINLINE Member* SetMembersPointer(Member* members) { retur...
function SetArrayRaw (line 2034) | void SetArrayRaw(GenericValue* values, SizeType count, Allocator& alloca...
function SetObjectRaw (line 2047) | void SetObjectRaw(Member* members, SizeType count, Allocator& allocator) {
function SetStringRaw (line 2060) | void SetStringRaw(StringRefType s) RAPIDJSON_NOEXCEPT {
function SetStringRaw (line 2067) | void SetStringRaw(StringRefType s, Allocator& allocator) {
function RawAssign (line 2084) | void RawAssign(GenericValue& rhs) RAPIDJSON_NOEXCEPT {
type GenericValue (line 2110) | typedef GenericValue<UTF8<> > Value;
type GenericValue (line 2127) | typedef GenericValue<Encoding, Allocator> ValueType;
type Allocator (line 2128) | typedef Allocator AllocatorType;
type ClearStackOnExit (line 2422) | struct ClearStackOnExit {
function Bool (line 2438) | bool Bool(bool b) { new (stack_.template Push<ValueType>()) ValueType(b)...
function Int (line 2439) | bool Int(int i) { new (stack_.template Push<ValueType>()) ValueType(i); ...
function Uint (line 2440) | bool Uint(unsigned i) { new (stack_.template Push<ValueType>()) ValueTyp...
function Int64 (line 2441) | bool Int64(int64_t i) { new (stack_.template Push<ValueType>()) ValueTyp...
function Uint64 (line 2442) | bool Uint64(uint64_t i) { new (stack_.template Push<ValueType>()) ValueT...
function Double (line 2443) | bool Double(double d) { new (stack_.template Push<ValueType>()) ValueTyp...
function RawNumber (line 2445) | bool RawNumber(const Ch* str, SizeType length, bool copy) {
function String (line 2453) | bool String(const Ch* str, SizeType length, bool copy) {
function StartObject (line 2461) | bool StartObject() { new (stack_.template Push<ValueType>()) ValueType(k...
function Key (line 2463) | bool Key(const Ch* str, SizeType length, bool copy) { return String(str,...
function EndObject (line 2465) | bool EndObject(SizeType memberCount) {
function StartArray (line 2471) | bool StartArray() { new (stack_.template Push<ValueType>()) ValueType(kA...
function EndArray (line 2473) | bool EndArray(SizeType elementCount) {
function ClearStack (line 2485) | void ClearStack() {
function Destroy (line 2494) | void Destroy() {
type GenericDocument (line 2506) | typedef GenericDocument<UTF8<> > Document;
type ValueT (line 2518) | typedef ValueT PlainType;
type typename (line 2519) | typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
type ValueType (line 2520) | typedef ValueType* ValueIterator;
type ValueT (line 2521) | typedef const ValueT* ConstValueIterator;
type typename (line 2522) | typedef typename ValueType::AllocatorType AllocatorType;
type typename (line 2523) | typedef typename ValueType::StringRefType StringRefType;
function value_ (line 2528) | GenericArray(const GenericArray& rhs) : value_(rhs.value_) {}
function GenericArray (line 2539) | GenericArray Reserve(SizeType newCapacity, AllocatorType &allocator) con...
function GenericArray (line 2540) | GenericArray PushBack(ValueType& value, AllocatorType& allocator) const ...
function GenericArray (line 2542) | GenericArray PushBack(ValueType&& value, AllocatorType& allocator) const...
function GenericArray (line 2544) | GenericArray PushBack(StringRefType value, AllocatorType& allocator) con...
function ValueIterator (line 2547) | ValueIterator Erase(ConstValueIterator pos) const { return value_.Erase(...
function ValueIterator (line 2548) | ValueIterator Erase(ConstValueIterator first, ConstValueIterator last) c...
function value_ (line 2557) | value_(value) {}
type ValueT (line 2571) | typedef ValueT PlainType;
type typename (line 2572) | typedef typename internal::MaybeAddConst<Const,PlainType>::Type ValueType;
type GenericMemberIterator (line 2573) | typedef GenericMemberIterator<Const, typename
type GenericMemberIterator (line 2574) | typedef GenericMemberIterator<true, typename
type typename (line 2575) | typedef typename ValueType::AllocatorType AllocatorType;
type typename (line 2576) | typedef typename ValueType::StringRefType StringRefType;
type typename (line 2577) | typedef typename ValueType::EncodingType EncodingType;
type typename (line 2578) | typedef typename ValueType::Ch Ch;
function value_ (line 2583) | GenericObject(const GenericObject& rhs) : value_(rhs.value_) {}
function GenericObject (line 2597) | GenericObject MemberReserve(SizeType newCapacity, AllocatorType &allocat...
function HasMember (line 2598) | bool HasMember(const Ch* name) const { return value_.HasMember(name); }
function MemberIterator (line 2603) | MemberIterator FindMember(const Ch* name) const { return value_.FindMemb...
function GenericObject (line 2611) | GenericObject AddMember(ValueType& name, std::basic_string<Ch>& value, A...
function GenericObject (line 2615) | GenericObject AddMember(ValueType&& name, ValueType&& value, AllocatorTy...
function GenericObject (line 2616) | GenericObject AddMember(ValueType&& name, ValueType& value, AllocatorTyp...
function GenericObject (line 2617) | GenericObject AddMember(ValueType& name, ValueType&& value, AllocatorTyp...
function GenericObject (line 2618) | GenericObject AddMember(StringRefType name, ValueType&& value, Allocator...
function GenericObject (line 2620) | GenericObject AddMember(StringRefType name, ValueType& value, AllocatorT...
function GenericObject (line 2621) | GenericObject AddMember(StringRefType name, StringRefType value, Allocat...
function RemoveMember (line 2624) | bool RemoveMember(const Ch* name) const { return value_.RemoveMember(nam...
function value_ (line 2645) | value_(value) {}
FILE: src/json/rapidjson/encodedstream.h
function RAPIDJSON_DIAG_PUSH (line 27) | RAPIDJSON_DIAG_PUSH
function Ch (line 49) | Ch Take() { Ch c = current_; current_ = Encoding::Take(is_); return c; }
function Put (line 53) | void Put(Ch) { RAPIDJSON_ASSERT(false); }
function Flush (line 54) | void Flush() { RAPIDJSON_ASSERT(false); }
function Ch (line 55) | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
function PutEnd (line 56) | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
function is_ (line 72) | is_(is) {
function Ch (line 78) | Ch Take() { return is_.Take(); }
function Put (line 82) | void Put(Ch) {}
function Flush (line 83) | void Flush() {}
function Ch (line 84) | Ch* PutBegin() { return 0; }
function PutEnd (line 85) | size_t PutEnd(Ch*) { return 0; }
function os_ (line 105) | os_(os) {
function Put (line 110) | void Put(Ch c) { Encoding::Put(os_, c); }
function Flush (line 111) | void Flush() { os_.Flush(); }
function Ch (line 115) | Ch Take() { RAPIDJSON_ASSERT(false); return 0;}
function Tell (line 116) | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
function Ch (line 157) | Ch Take() { Ch c = current_; current_ = takeFunc_(*is_); return c; }
function Put (line 161) | void Put(Ch) { RAPIDJSON_ASSERT(false); }
function Flush (line 162) | void Flush() { RAPIDJSON_ASSERT(false); }
function Ch (line 163) | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
function PutEnd (line 164) | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
function DetectType (line 171) | void DetectType() {
type Ch (line 219) | typedef Ch (*TakeFunc)(InputByteStream& is);
function Put (line 260) | void Put(Ch c) { putFunc_(*os_, c); }
function Flush (line 261) | void Flush() { os_->Flush(); }
function Ch (line 265) | Ch Take() { RAPIDJSON_ASSERT(false); return 0;}
function Tell (line 266) | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
function PutBOM (line 274) | void PutBOM() {
FILE: src/json/rapidjson/encodings.h
function RAPIDJSON_DIAG_PUSH (line 25) | RAPIDJSON_DIAG_PUSH
function else (line 131) | else if (codepoint <= 0xFFFF) {
function GetRange (line 204) | static unsigned char GetRange(unsigned char c) {
type CharType (line 270) | typedef CharType Ch;
type CharType (line 419) | typedef CharType Ch;
type CharType (line 543) | typedef CharType Ch;
type UTFType (line 603) | enum UTFType {
type CharType (line 616) | typedef CharType Ch;
function Encode (line 623) | void Encode(OutputStream& os, unsigned codepoint) {
function EncodeUnsafe (line 630) | void EncodeUnsafe(OutputStream& os, unsigned codepoint) {
function Decode (line 637) | bool Decode(InputStream& is, unsigned* codepoint) {
FILE: src/json/rapidjson/error/en.h
function RAPIDJSON_DIAG_PUSH (line 21) | RAPIDJSON_DIAG_PUSH
FILE: src/json/rapidjson/error/error.h
function RAPIDJSON_NAMESPACE_BEGIN (line 55) | RAPIDJSON_NAMESPACE_BEGIN
type RAPIDJSON_ERROR_CHARTYPE (line 153) | typedef const RAPIDJSON_ERROR_CHARTYPE* (*GetParseErrorFunc)(ParseErrorC...
FILE: src/json/rapidjson/filereadstream.h
function RAPIDJSON_DIAG_PUSH (line 22) | RAPIDJSON_DIAG_PUSH
function Ch (line 51) | Ch Take() { Ch c = *current_; Read(); return c; }
function Put (line 55) | void Put(Ch) { RAPIDJSON_ASSERT(false); }
function Flush (line 56) | void Flush() { RAPIDJSON_ASSERT(false); }
function Ch (line 57) | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
function PutEnd (line 58) | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
function Ch (line 61) | const Ch* Peek4() const {
FILE: src/json/rapidjson/filewritestream.h
function RAPIDJSON_DIAG_PUSH (line 22) | RAPIDJSON_DIAG_PUSH
function Put (line 40) | void Put(char c) {
function PutN (line 47) | void PutN(char c, size_t n) {
function Flush (line 63) | void Flush() {
function Peek (line 75) | char Peek() const { RAPIDJSON_ASSERT(false); return 0; }
function Tell (line 77) | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
function PutEnd (line 79) | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
function PutN (line 94) | inline void PutN(FileWriteStream& stream, char c, size_t n) {
FILE: src/json/rapidjson/fwd.h
type GenericStringStream (line 49) | typedef GenericStringStream<UTF8<char> > StringStream;
type GenericInsituStringStream (line 54) | typedef GenericInsituStringStream<UTF8<char> > InsituStringStream;
type GenericStringBuffer (line 61) | typedef GenericStringBuffer<UTF8<char>, CrtAllocator> StringBuffer;
type GenericMemoryBuffer (line 76) | typedef GenericMemoryBuffer<CrtAllocator> MemoryBuffer;
type MemoryStream (line 80) | struct MemoryStream
type GenericReader (line 90) | typedef GenericReader<UTF8<char>, UTF8<char>, CrtAllocator> Reader;
type GenericValue (line 116) | typedef GenericValue<UTF8<char>, MemoryPoolAllocator<CrtAllocator> > Value;
type GenericDocument (line 121) | typedef GenericDocument<UTF8<char>, MemoryPoolAllocator<CrtAllocator>, C...
type GenericPointer (line 128) | typedef GenericPointer<Value, CrtAllocator> Pointer;
type GenericSchemaDocument (line 138) | typedef GenericSchemaDocument<Value, CrtAllocator> SchemaDocument;
type IGenericRemoteSchemaDocumentProvider (line 139) | typedef IGenericRemoteSchemaDocumentProvider<SchemaDocument> IRemoteSche...
type GenericSchemaValidator (line 147) | typedef GenericSchemaValidator<SchemaDocument, BaseReaderHandler<UTF8<ch...
FILE: src/json/rapidjson/internal/biginteger.h
function RAPIDJSON_NAMESPACE_BEGIN (line 25) | RAPIDJSON_NAMESPACE_BEGIN
function Difference (line 186) | bool Difference(const BigInteger& rhs, BigInteger* out) const {
function Compare (line 208) | int Compare(const BigInteger& rhs) const {
function Type (line 220) | Type GetDigit(size_t index) const { RAPIDJSON_ASSERT(index < count_); re...
function PushBack (line 234) | void PushBack(Type digit) {
function ParseUint64 (line 239) | static uint64_t ParseUint64(const char* begin, const char* end) {
function MulAdd64 (line 249) | static uint64_t MulAdd64(uint64_t a, uint64_t b, uint64_t k, uint64_t* o...
FILE: src/json/rapidjson/internal/diyfp.h
function RAPIDJSON_DIAG_PUSH (line 40) | RAPIDJSON_DIAG_PUSH
type uint128 (line 79) | __extension__ typedef unsigned __int128 uint128;
function DiyFp (line 121) | DiyFp NormalizeBoundary() const {
function NormalizedBoundaries (line 132) | void NormalizedBoundaries(DiyFp* minus, DiyFp* plus) const {
function ToDouble (line 141) | double ToDouble() const {
function DiyFp (line 175) | inline DiyFp GetCachedPowerByIndex(size_t index) {
function DiyFp (line 238) | inline DiyFp GetCachedPower(int e, int* K) {
function DiyFp (line 252) | inline DiyFp GetCachedPower10(int exp, int *outExp) {
FILE: src/json/rapidjson/internal/dtoa.h
function RAPIDJSON_NAMESPACE_BEGIN (line 26) | RAPIDJSON_NAMESPACE_BEGIN
FILE: src/json/rapidjson/internal/ieee754.h
function RAPIDJSON_NAMESPACE_BEGIN (line 20) | RAPIDJSON_NAMESPACE_BEGIN
FILE: src/json/rapidjson/internal/itoa.h
function RAPIDJSON_NAMESPACE_BEGIN (line 20) | RAPIDJSON_NAMESPACE_BEGIN
FILE: src/json/rapidjson/internal/meta.h
function RAPIDJSON_NAMESPACE_BEGIN (line 35) | RAPIDJSON_NAMESPACE_BEGIN
FILE: src/json/rapidjson/internal/pow10.h
function RAPIDJSON_NAMESPACE_BEGIN (line 20) | RAPIDJSON_NAMESPACE_BEGIN
FILE: src/json/rapidjson/internal/regex.h
function RAPIDJSON_NAMESPACE_BEGIN (line 44) | RAPIDJSON_NAMESPACE_BEGIN
function SizeType (line 322) | SizeType NewState(SizeType out, SizeType out1, unsigned codepoint) {
function PushOperand (line 331) | void PushOperand(Stack<Allocator>& operandStack, unsigned codepoint) {
function ImplicitConcatenation (line 336) | void ImplicitConcatenation(Stack<Allocator>& atomCountStack, Stack<Alloc...
function SizeType (line 342) | SizeType Append(SizeType l1, SizeType l2) {
function Patch (line 350) | void Patch(SizeType l, SizeType s) {
function Eval (line 357) | bool Eval(Stack<Allocator>& operandStack, Operator op) {
function EvalQuantifier (line 414) | bool EvalQuantifier(Stack<Allocator>& operandStack, unsigned n, unsigned...
function SizeType (line 453) | static SizeType Min(SizeType a, SizeType b) { return a < b ? a : b; }
function CloneTopOperand (line 455) | void CloneTopOperand(Stack<Allocator>& operandStack) {
function SizeType (line 555) | SizeType NewRange(unsigned codepoint) {
type typename (line 610) | typedef typename Encoding::Ch Ch;
function Match (line 634) | bool Match(const Ch* s) {
function Search (line 644) | bool Search(const Ch* s) {
type typename (line 651) | typedef typename RegexType::Range Range;
function AddState (line 692) | bool AddState(Stack<Allocator>& l, SizeType index) {
function MatchRange (line 707) | bool MatchRange(SizeType rangeIndex, unsigned codepoint) const {
type GenericRegex (line 726) | typedef GenericRegex<UTF8<> > Regex;
type GenericRegexSearch (line 727) | typedef GenericRegexSearch<Regex> RegexSearch;
FILE: src/json/rapidjson/internal/stack.h
function RAPIDJSON_DIAG_PUSH (line 23) | RAPIDJSON_DIAG_PUSH
function T (line 151) | T* Top() const {
function T (line 160) | T* End() const { return reinterpret_cast<T*>(stackTop_); }
function T (line 166) | T* Bottom() const { return reinterpret_cast<T*>(stack_); }
function Resize (line 201) | void Resize(size_t newCapacity) {
function Destroy (line 208) | void Destroy() {
FILE: src/json/rapidjson/internal/strfunc.h
function RAPIDJSON_NAMESPACE_BEGIN (line 21) | RAPIDJSON_NAMESPACE_BEGIN
FILE: src/json/rapidjson/internal/strtod.h
function RAPIDJSON_NAMESPACE_BEGIN (line 25) | RAPIDJSON_NAMESPACE_BEGIN
FILE: src/json/rapidjson/internal/swap.h
function RAPIDJSON_DIAG_PUSH (line 21) | RAPIDJSON_DIAG_PUSH
FILE: src/json/rapidjson/istreamwrapper.h
function RAPIDJSON_DIAG_PUSH (line 26) | RAPIDJSON_DIAG_PUSH
function Ch (line 73) | Ch Take() { Ch c = *current_; Read(); return c; }
function Put (line 77) | void Put(Ch) { RAPIDJSON_ASSERT(false); }
function Flush (line 78) | void Flush() { RAPIDJSON_ASSERT(false); }
function Ch (line 79) | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
function PutEnd (line 80) | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
function Ch (line 83) | const Ch* Peek4() const {
function Read (line 92) | void Read() {
type BasicIStreamWrapper (line 119) | typedef BasicIStreamWrapper<std::istream> IStreamWrapper;
type BasicIStreamWrapper (line 120) | typedef BasicIStreamWrapper<std::wistream> WIStreamWrapper;
FILE: src/json/rapidjson/memorystream.h
function RAPIDJSON_DIAG_PUSH (line 21) | RAPIDJSON_DIAG_PUSH
function Ch (line 46) | Ch Take() { return RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; }
function Ch (line 49) | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
function Put (line 50) | void Put(Ch) { RAPIDJSON_ASSERT(false); }
function Flush (line 51) | void Flush() { RAPIDJSON_ASSERT(false); }
function PutEnd (line 52) | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
function Ch (line 55) | const Ch* Peek4() const {
FILE: src/json/rapidjson/msinttypes/inttypes.h
type imaxdiv_t (line 57) | typedef struct {
function _inline (line 286) | static
FILE: src/json/rapidjson/msinttypes/stdint.h
type int_least8_t (line 140) | typedef int8_t int_least8_t;
type int_least16_t (line 141) | typedef int16_t int_least16_t;
type int_least32_t (line 142) | typedef int32_t int_least32_t;
type int_least64_t (line 143) | typedef int64_t int_least64_t;
type uint_least8_t (line 144) | typedef uint8_t uint_least8_t;
type uint_least16_t (line 145) | typedef uint16_t uint_least16_t;
type uint_least32_t (line 146) | typedef uint32_t uint_least32_t;
type uint_least64_t (line 147) | typedef uint64_t uint_least64_t;
type int_fast8_t (line 150) | typedef int8_t int_fast8_t;
type int_fast16_t (line 151) | typedef int16_t int_fast16_t;
type int_fast32_t (line 152) | typedef int32_t int_fast32_t;
type int_fast64_t (line 153) | typedef int64_t int_fast64_t;
type uint_fast8_t (line 154) | typedef uint8_t uint_fast8_t;
type uint_fast16_t (line 155) | typedef uint16_t uint_fast16_t;
type uint_fast32_t (line 156) | typedef uint32_t uint_fast32_t;
type uint_fast64_t (line 157) | typedef uint64_t uint_fast64_t;
type intmax_t (line 169) | typedef int64_t intmax_t;
type uintmax_t (line 170) | typedef uint64_t uintmax_t;
FILE: src/json/rapidjson/ostreamwrapper.h
function RAPIDJSON_DIAG_PUSH (line 22) | RAPIDJSON_DIAG_PUSH
function Put (line 50) | void Put(Ch c) {
function Flush (line 54) | void Flush() {
function Peek (line 59) | char Peek() const { RAPIDJSON_ASSERT(false); return 0; }
function Tell (line 61) | size_t Tell() const { RAPIDJSON_ASSERT(false); return 0; }
function PutEnd (line 63) | size_t PutEnd(char*) { RAPIDJSON_ASSERT(false); return 0; }
type BasicOStreamWrapper (line 72) | typedef BasicOStreamWrapper<std::ostream> OStreamWrapper;
type BasicOStreamWrapper (line 73) | typedef BasicOStreamWrapper<std::wostream> WOStreamWrapper;
FILE: src/json/rapidjson/pointer.h
function RAPIDJSON_DIAG_PUSH (line 25) | RAPIDJSON_DIAG_PUSH
function Token (line 353) | const Token* GetTokens() const { return tokens_; }
function Erase (line 771) | bool Erase(ValueType& root) const {
function NeedPercentEncode (line 850) | bool NeedPercentEncode(Ch c) const {
function Parse (line 862) | void Parse(const Ch* source, size_t length) {
function class (line 1040) | class PercentDecodeStream {
function Put (line 1088) | void Put(char c) { // UTF-8 must be byte
type GenericPointer (line 1109) | typedef GenericPointer<Value> Pointer;
FILE: src/json/rapidjson/prettywriter.h
function RAPIDJSON_DIAG_PUSH (line 26) | RAPIDJSON_DIAG_PUSH
function Null (line 95) | bool Null() { PrettyPrefix(kNullType); return Base::En...
function Bool (line 96) | bool Bool(bool b) { PrettyPrefix(b ? kTrueType : kFalseType); ...
function Int (line 97) | bool Int(int i) { PrettyPrefix(kNumberType); return Base::En...
function Uint (line 98) | bool Uint(unsigned u) { PrettyPrefix(kNumberType); return Base::En...
function Int64 (line 99) | bool Int64(int64_t i64) { PrettyPrefix(kNumberType); return Base::En...
function Uint64 (line 100) | bool Uint64(uint64_t u64) { PrettyPrefix(kNumberType); return Base::En...
function Double (line 101) | bool Double(double d) { PrettyPrefix(kNumberType); return Base::En...
function StartObject (line 123) | bool StartObject() {
function StartArray (line 157) | bool StartArray() {
function String (line 187) | bool String(const Ch* str) { return String(str, internal::StrLen(str)); }
function Key (line 188) | bool Key(const Ch* str) { return Key(str, internal::StrLen(str)); }
function RawValue (line 201) | bool RawValue(const Ch* json, size_t length, Type type) {
function WriteIndent (line 252) | void WriteIndent() {
FILE: src/json/rapidjson/rapidjson.h
type STATIC_ASSERTION_FAILURE (line 427) | struct STATIC_ASSERTION_FAILURE
FILE: src/json/rapidjson/reader.h
function RAPIDJSON_DIAG_PUSH (line 46) | RAPIDJSON_DIAG_PUSH
type ParseFlag (line 145) | enum ParseFlag {
type typename (line 197) | typedef typename Encoding::Ch Ch;
type typename (line 199) | typedef typename internal::SelectIf<internal::IsSame<Derived, void>, Bas...
function Default (line 201) | bool Default() { return true; }
function Null (line 202) | bool Null() { return static_cast<Override&>(*this).Default(); }
function Bool (line 203) | bool Bool(bool) { return static_cast<Override&>(*this).Default(); }
function Int (line 204) | bool Int(int) { return static_cast<Override&>(*this).Default(); }
function Uint (line 205) | bool Uint(unsigned) { return static_cast<Override&>(*this).Default(); }
function Int64 (line 206) | bool Int64(int64_t) { return static_cast<Override&>(*this).Default(); }
function Uint64 (line 207) | bool Uint64(uint64_t) { return static_cast<Override&>(*this).Default(); }
function Double (line 208) | bool Double(double) { return static_cast<Override&>(*this).Default(); }
function RawNumber (line 210) | bool RawNumber(const Ch* str, SizeType len, bool copy) { return static_c...
function String (line 211) | bool String(const Ch*, SizeType, bool) { return static_cast<Override&>(*...
function StartObject (line 212) | bool StartObject() { return static_cast<Override&>(*this).Default(); }
function Key (line 213) | bool Key(const Ch* str, SizeType len, bool copy) { return static_cast<Ov...
function EndObject (line 214) | bool EndObject(SizeType) { return static_cast<Override&>(*this).Default(...
function StartArray (line 215) | bool StartArray() { return static_cast<Override&>(*this).Default(); }
function EndArray (line 216) | bool EndArray(SizeType) { return static_cast<Override&>(*this).Default(); }
function namespace (line 222) | namespace internal {
function SkipWhitespace (line 503) | inline void SkipWhitespace(InsituStringStream& is) {
function SkipWhitespace (line 508) | inline void SkipWhitespace(StringStream& is) {
function SkipWhitespace (line 512) | inline void SkipWhitespace(EncodedInputStream<UTF8<>, MemoryStream>& is) {
function IterativeParseInit (line 605) | void IterativeParseInit() {
function ClearStack (line 696) | void ClearStack() { stack_.Clear(); }
type ClearStackOnExit (line 699) | struct ClearStackOnExit {
function Consume (line 893) | bool Consume(InputStream& is, typename InputStream::Ch expect) {
function RAPIDJSON_FORCEINLINE (line 931) | RAPIDJSON_FORCEINLINE void Put(Ch c) {
function RAPIDJSON_FORCEINLINE (line 936) | RAPIDJSON_FORCEINLINE void* Push(SizeType count) {
function Ch (line 943) | Ch* Pop() {
type typename (line 1399) | typedef typename InputStream::Ch Ch;
function is (line 1401) | is(s) { (void)reader; }
function RAPIDJSON_FORCEINLINE (line 1404) | RAPIDJSON_FORCEINLINE Ch TakePush() { return is.Take(); }
function RAPIDJSON_FORCEINLINE (line 1405) | RAPIDJSON_FORCEINLINE Ch Take() { return is.Take(); }
function RAPIDJSON_FORCEINLINE (line 1406) | RAPIDJSON_FORCEINLINE void Push(char) {}
function Tell (line 1408) | size_t Tell() { return is.Tell(); }
function Length (line 1409) | size_t Length() { return 0; }
function RAPIDJSON_FORCEINLINE (line 1424) | RAPIDJSON_FORCEINLINE Ch TakePush() {
function RAPIDJSON_FORCEINLINE (line 1429) | RAPIDJSON_FORCEINLINE void Push(char c) {
function Length (line 1433) | size_t Length() { return stackStream.Length(); }
function RAPIDJSON_FORCEINLINE (line 1450) | RAPIDJSON_FORCEINLINE Ch Take() { return Base::TakePush(); }
type IterativeParsingState (line 1754) | enum IterativeParsingState {
type Token (line 1782) | enum Token {
function RAPIDJSON_FORCEINLINE (line 1801) | RAPIDJSON_FORCEINLINE Token Tokenize(Ch c) const {
function RAPIDJSON_FORCEINLINE (line 1828) | RAPIDJSON_FORCEINLINE IterativeParsingState Predict(IterativeParsingStat...
function IterativeParsingState (line 1995) | IterativeParsingState Transit(IterativeParsingState src, Token token, It...
function RAPIDJSON_FORCEINLINE (line 2167) | RAPIDJSON_FORCEINLINE bool IsIterativeParsingDelimiterState(IterativePar...
function RAPIDJSON_FORCEINLINE (line 2171) | RAPIDJSON_FORCEINLINE bool IsIterativeParsingCompleteState(IterativePars...
type GenericReader (line 2217) | typedef GenericReader<UTF8<>, UTF8<> > Reader;
FILE: src/json/rapidjson/schema.h
function namespace (line 77) | namespace internal {
function namespace (line 129) | namespace internal {
type typename (line 399) | typedef typename SchemaDocumentType::AllocatorType AllocatorType;
type typename (line 400) | typedef typename SchemaDocumentType::PointerType PointerType;
type typename (line 401) | typedef typename ValueType::EncodingType EncodingType;
type typename (line 402) | typedef typename EncodingType::Ch Ch;
type SchemaValidationContext (line 403) | typedef SchemaValidationContext<SchemaDocumentType> Context;
type Schema (line 404) | typedef Schema<SchemaDocumentType> SchemaType;
type GenericValue (line 405) | typedef GenericValue<EncodingType, AllocatorType> SValue;
type IValidationErrorHandler (line 406) | typedef IValidationErrorHandler<Schema> ErrorHandler;
type typename (line 447) | typedef typename ValueType::ConstValueIterator ConstValueIterator;
type typename (line 448) | typedef typename ValueType::ConstMemberIterator ConstMemberIterator;
type Hasher (line 466) | typedef Hasher<EncodingType, MemoryPoolAllocator<> > EnumHasherType;
function BeginValue (line 676) | bool BeginValue(Context& context) const {
function Null (line 785) | bool Null(Context& context) const {
function Bool (line 793) | bool Bool(Context& context, bool) const {
function Int (line 801) | bool Int(Context& context, int i) const {
function Uint (line 807) | bool Uint(Context& context, unsigned u) const {
function Int64 (line 813) | bool Int64(Context& context, int64_t i) const {
function Uint64 (line 819) | bool Uint64(Context& context, uint64_t u) const {
function Double (line 825) | bool Double(Context& context, double d) const {
function String (line 843) | bool String(Context& context, const Ch* str, SizeType length, bool) const {
function StartObject (line 871) | bool StartObject(Context& context) const {
function Key (line 892) | bool Key(Context& context, const Ch* str, SizeType len, bool) const {
function EndObject (line 941) | bool EndObject(Context& context, SizeType memberCount) const {
function StartArray (line 988) | bool StartArray(Context& context) const {
function EndArray (line 1000) | bool EndArray(Context& context, SizeType elementCount) const {
type SchemaValueType (line 1062) | enum SchemaValueType {
type internal (line 1074) | typedef internal::GenericRegex<EncodingType, AllocatorType> RegexType;
type std (line 1076) | typedef std::basic_regex<Ch> RegexType;
type RegexType (line 1078) | typedef char RegexType;
type SchemaArray (line 1081) | struct SchemaArray {
function ValueType (line 1098) | static const ValueType* GetMember(const ValueType& value, const ValueTyp...
function AssignIfExist (line 1103) | static void AssignIfExist(bool& out, const ValueType& value, const Value...
function AssignIfExist (line 1109) | static void AssignIfExist(SizeType& out, const ValueType& value, const V...
function AssignIfExist (line 1115) | void AssignIfExist(SchemaArray& out, SchemaDocumentType& schemaDocument,...
function IsPatternMatch (line 1145) | static bool IsPatternMatch(const RegexType* pattern, const Ch *str, Size...
function IsPatternMatch (line 1164) | static bool IsPatternMatch(const RegexType* pattern, const Ch *str, Size...
function FindPropertyIndex (line 1222) | bool FindPropertyIndex(const ValueType& name, SizeType* outIndex) const {
function CheckInt (line 1235) | bool CheckInt(Context& context, int64_t i) const {
function CheckUint (line 1283) | bool CheckUint(Context& context, uint64_t i) const {
function CheckDoubleMinimum (line 1331) | bool CheckDoubleMinimum(Context& context, double d) const {
function CheckDoubleMaximum (line 1339) | bool CheckDoubleMaximum(Context& context, double d) const {
function CheckDoubleMultipleOf (line 1347) | bool CheckDoubleMultipleOf(Context& context, double d) const {
function DisallowedType (line 1358) | void DisallowedType(Context& context, const ValueType& actualType) const {
type Property (line 1374) | struct Property {
type PatternProperty (line 1385) | struct PatternProperty {
function virtual (line 1485) | virtual ~IGenericRemoteSchemaDocumentProvider() {}
type IGenericRemoteSchemaDocumentProvider (line 1505) | typedef IGenericRemoteSchemaDocumentProvider<GenericSchemaDocument> IRem...
type Allocator (line 1506) | typedef Allocator AllocatorType;
type typename (line 1507) | typedef typename ValueType::EncodingType EncodingType;
type typename (line 1508) | typedef typename EncodingType::Ch Ch;
type internal (line 1509) | typedef internal::Schema<GenericSchemaDocument> SchemaType;
type GenericPointer (line 1510) | typedef GenericPointer<ValueType, Allocator> PointerType;
type GenericValue (line 1511) | typedef GenericValue<EncodingType, Allocator> URIType;
type SchemaRefEntry (line 1615) | struct SchemaRefEntry {
function CreateSchemaRecursive (line 1635) | void CreateSchemaRecursive(const SchemaType** schema, const PointerType&...
function CreateSchema (line 1652) | void CreateSchema(const SchemaType** schema, const PointerType& pointer,...
function HandleRefSchema (line 1664) | bool HandleRefSchema(const PointerType& source, const SchemaType** schem...
function SchemaType (line 1711) | const SchemaType* GetSchema(const PointerType& pointer) const {
function PointerType (line 1718) | PointerType GetPointer(const SchemaType* schema) const {
function SchemaType (line 1725) | const SchemaType* GetTypeless() const { return typeless_; }
type GenericSchemaDocument (line 1741) | typedef GenericSchemaDocument<Value> SchemaDocument;
type IGenericRemoteSchemaDocumentProvider (line 1743) | typedef IGenericRemoteSchemaDocumentProvider<SchemaDocument> IRemoteSche...
type typename (line 1771) | typedef typename SchemaDocumentType::PointerType PointerType;
type typename (line 1772) | typedef typename SchemaType::EncodingType EncodingType;
type typename (line 1773) | typedef typename SchemaType::SValue SValue;
type typename (line 1774) | typedef typename EncodingType::Ch Ch;
type GenericStringRef (line 1775) | typedef GenericStringRef<Ch> StringRefType;
type GenericValue (line 1776) | typedef GenericValue<EncodingType, StateAllocator> ValueType;
function Reset (line 1846) | void Reset() {
function Ch (line 1870) | const Ch* GetInvalidSchemaKeyword() const {
function NotMultipleOf (line 1884) | void NotMultipleOf(int64_t actual, const SValue& expected) {
function NotMultipleOf (line 1887) | void NotMultipleOf(uint64_t actual, const SValue& expected) {
function NotMultipleOf (line 1890) | void NotMultipleOf(double actual, const SValue& expected) {
function AboveMaximum (line 1893) | void AboveMaximum(int64_t actual, const SValue& expected, bool exclusive) {
function AboveMaximum (line 1897) | void AboveMaximum(uint64_t actual, const SValue& expected, bool exclusiv...
function AboveMaximum (line 1901) | void AboveMaximum(double actual, const SValue& expected, bool exclusive) {
function BelowMinimum (line 1905) | void BelowMinimum(int64_t actual, const SValue& expected, bool exclusive) {
function BelowMinimum (line 1909) | void BelowMinimum(uint64_t actual, const SValue& expected, bool exclusiv...
function BelowMinimum (line 1913) | void BelowMinimum(double actual, const SValue& expected, bool exclusive) {
function TooLong (line 1918) | void TooLong(const Ch* str, SizeType length, SizeType expected) {
function TooShort (line 1922) | void TooShort(const Ch* str, SizeType length, SizeType expected) {
function DoesNotMatch (line 1926) | void DoesNotMatch(const Ch* str, SizeType length) {
function DisallowedItem (line 1932) | void DisallowedItem(SizeType index) {
function TooFewItems (line 1937) | void TooFewItems(SizeType actualCount, SizeType expectedCount) {
function TooManyItems (line 1941) | void TooManyItems(SizeType actualCount, SizeType expectedCount) {
function DuplicateItems (line 1945) | void DuplicateItems(SizeType index1, SizeType index2) {
function TooManyProperties (line 1954) | void TooManyProperties(SizeType actualCount, SizeType expectedCount) {
function TooFewProperties (line 1958) | void TooFewProperties(SizeType actualCount, SizeType expectedCount) {
function StartMissingProperties (line 1962) | void StartMissingProperties() {
function AddMissingProperty (line 1965) | void AddMissingProperty(const SValue& name) {
function EndMissingProperties (line 1968) | bool EndMissingProperties() {
function PropertyViolations (line 1977) | void PropertyViolations(ISchemaValidator** subvalidators, SizeType count) {
function DisallowedProperty (line 1981) | void DisallowedProperty(const Ch* name, SizeType length) {
function StartDependencyErrors (line 1987) | void StartDependencyErrors() {
function StartMissingDependentProperties (line 1990) | void StartMissingDependentProperties() {
function AddMissingDependentProperty (line 1993) | void AddMissingDependentProperty(const SValue& targetName) {
function EndMissingDependentProperties (line 1996) | void EndMissingDependentProperties(const SValue& sourceName) {
function AddDependencySchemaError (line 2001) | void AddDependencySchemaError(const SValue& sourceName, ISchemaValidator...
function EndDependencyErrors (line 2005) | bool EndDependencyErrors() {
function DisallowedValue (line 2015) | void DisallowedValue() {
function StartDisallowedType (line 2019) | void StartDisallowedType() {
function AddExpectedType (line 2022) | void AddExpectedType(const typename SchemaType::ValueType& expectedType) {
function EndDisallowedType (line 2025) | void EndDisallowedType(const typename SchemaType::ValueType& actualType) {
function NotAllOf (line 2032) | void NotAllOf(ISchemaValidator** subvalidators, SizeType count) {
function NoneOf (line 2037) | void NoneOf(ISchemaValidator** subvalidators, SizeType count) {
function NotOneOf (line 2040) | void NotOneOf(ISchemaValidator** subvalidators, SizeType count) {
function Disallowed (line 2043) | void Disallowed() {
function Null (line 2104) | bool Null() { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Null, (Curren...
function Bool (line 2105) | bool Bool(bool b) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Bool, (Curren...
function Int (line 2106) | bool Int(int i) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Int, (Curren...
function Uint (line 2107) | bool Uint(unsigned u) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Uint, (Curren...
function Int64 (line 2108) | bool Int64(int64_t i) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Int64, (Curren...
function Uint64 (line 2109) | bool Uint64(uint64_t u) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Uint64, (Curren...
function Double (line 2110) | bool Double(double d) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Double, (Curren...
function RawNumber (line 2111) | bool RawNumber(const Ch* str, SizeType length, bool copy)
function String (line 2113) | bool String(const Ch* str, SizeType length, bool copy)
function StartObject (line 2116) | bool StartObject() {
function Key (line 2122) | bool Key(const Ch* str, SizeType len, bool copy) {
function EndObject (line 2130) | bool EndObject(SizeType memberCount) {
function StartArray (line 2137) | bool StartArray() {
function EndArray (line 2143) | bool EndArray(SizeType elementCount) {
function virtual (line 2156) | virtual ISchemaValidator* CreateSchemaValidator(const SchemaType& root) {
function virtual (line 2164) | virtual void DestroySchemaValidator(ISchemaValidator* validator) {
function virtual (line 2170) | virtual void* CreateHasher() {
function virtual (line 2174) | virtual uint64_t GetHashCode(void* hasher) {
function virtual (line 2178) | virtual void DestroryHasher(void* hasher) {
function virtual (line 2184) | virtual void* MallocState(size_t size) {
function virtual (line 2188) | virtual void FreeState(void* p) {
type GenericValue (line 2194) | typedef GenericValue<UTF8<>, StateAllocator> HashCodeArray;
type internal (line 2195) | typedef internal::Hasher<EncodingType, StateAllocator> HasherType;
function BeginValue (line 2233) | bool BeginValue() {
function EndValue (line 2264) | bool EndValue() {
function AppendToken (line 2303) | void AppendToken(const Ch* str, SizeType len) {
function RAPIDJSON_FORCEINLINE (line 2320) | RAPIDJSON_FORCEINLINE void PushSchema(const SchemaType& schema) { new (s...
function RAPIDJSON_FORCEINLINE (line 2322) | RAPIDJSON_FORCEINLINE void PopSchema() {
function AddErrorLocation (line 2331) | void AddErrorLocation(ValueType& result, bool parent) {
function AddError (line 2350) | void AddError(ValueType& keyword, ValueType& error) {
function MergeError (line 2369) | void MergeError(ValueType& other) {
type GenericSchemaValidator (line 2417) | typedef GenericSchemaValidator<SchemaDocument> SchemaValidator;
type typename (line 2441) | typedef typename InputStream::Ch Ch;
type GenericValue (line 2442) | typedef GenericValue<SourceEncoding, StackAllocator> ValueType;
function Ch (line 2477) | const Ch* GetInvalidSchemaKeyword() const { return invalidSchemaKeyword_; }
FILE: src/json/rapidjson/stream.h
function RAPIDJSON_NAMESPACE_BEGIN (line 22) | RAPIDJSON_NAMESPACE_BEGIN
function is_ (line 122) | is_(is) {}
function Ch (line 125) | Ch Take() { return is_.Take(); }
function Tell (line 126) | size_t Tell() { return is_.Tell(); }
function Ch (line 127) | Ch* PutBegin() { return is_.PutBegin(); }
function Put (line 128) | void Put(Ch ch) { is_.Put(ch); }
function Flush (line 129) | void Flush() { is_.Flush(); }
function PutEnd (line 130) | size_t PutEnd(Ch* ch) { return is_.PutEnd(ch); }
function Ch (line 133) | const Ch* Peek4() const { return is_.Peek4(); }
type typename (line 155) | typedef typename Encoding::Ch Ch;
function Ch (line 160) | Ch Take() { return *src_++; }
function Ch (line 163) | Ch* PutBegin() { RAPIDJSON_ASSERT(false); return 0; }
function Put (line 164) | void Put(Ch) { RAPIDJSON_ASSERT(false); }
function Flush (line 165) | void Flush() { RAPIDJSON_ASSERT(false); }
function PutEnd (line 166) | size_t PutEnd(Ch*) { RAPIDJSON_ASSERT(false); return 0; }
type GenericStringStream (line 178) | typedef GenericStringStream<UTF8<> > StringStream;
type typename (line 189) | typedef typename Encoding::Ch Ch;
function Ch (line 194) | Ch Peek() { return *src_; }
function Ch (line 195) | Ch Take() { return *src_++; }
function Tell (line 196) | size_t Tell() { return static_cast<size_t>(src_ - head_); }
function Put (line 199) | void Put(Ch c) { RAPIDJSON_ASSERT(dst_ != 0); *dst_++ = c; }
function Ch (line 201) | Ch* PutBegin() { return dst_ = src_; }
function PutEnd (line 202) | size_t PutEnd(Ch* begin) { return static_cast<size_t>(dst_ - begin); }
function Flush (line 203) | void Flush() {}
function Ch (line 205) | Ch* Push(size_t count) { Ch* begin = dst_; dst_ += count; return begin; }
function Pop (line 206) | void Pop(size_t count) { dst_ -= count; }
type GenericInsituStringStream (line 219) | typedef GenericInsituStringStream<UTF8<> > InsituStringStream;
FILE: src/json/rapidjson/writer.h
type WriteFlag (line 65) | enum WriteFlag {
function Reset (line 133) | void Reset(OutputStream& os) {
function SetMaxDecimalPlaces (line 172) | void SetMaxDecimalPlaces(int maxDecimalPlaces) {
function Null (line 181) | bool Null() { Prefix(kNullType); return EndValue(Write...
function Bool (line 182) | bool Bool(bool b) { Prefix(b ? kTrueType : kFalseType); return...
function Int (line 183) | bool Int(int i) { Prefix(kNumberType); return EndValue(Write...
function Uint (line 184) | bool Uint(unsigned u) { Prefix(kNumberType); return EndValue(Write...
function Int64 (line 185) | bool Int64(int64_t i64) { Prefix(kNumberType); return EndValue(Write...
function Uint64 (line 186) | bool Uint64(uint64_t u64) { Prefix(kNumberType); return EndValue(Write...
function Double (line 193) | bool Double(double d) { Prefix(kNumberType); return EndValue(Write...
function StartObject (line 215) | bool StartObject() {
function StartArray (line 239) | bool StartArray() {
function String (line 258) | bool String(const Ch* const& str) { return String(str, internal::StrLen(...
function Key (line 259) | bool Key(const Ch* const& str) { return Key(str, internal::StrLen(str)); }
function RawValue (line 271) | bool RawValue(const Ch* json, size_t length, Type type) {
function Flush (line 281) | void Flush() {
type Level (line 287) | struct Level {
function WriteNull (line 295) | bool WriteNull() {
function WriteBool (line 300) | bool WriteBool(bool b) {
function WriteInt (line 312) | bool WriteInt(int i) {
function WriteUint (line 321) | bool WriteUint(unsigned u) {
function WriteInt64 (line 330) | bool WriteInt64(int64_t i64) {
function WriteUint64 (line 339) | bool WriteUint64(uint64_t u64) {
function WriteDouble (line 348) | bool WriteDouble(double d) {
function WriteString (line 376) | bool WriteString(const Ch* str, SizeType length) {
function ScanWriteUnescapedString (line 450) | bool ScanWriteUnescapedString(GenericStringStream<SourceEncoding>& is, s...
function WriteStartObject (line 454) | bool WriteStartObject() { os_->Put('{'); return true; }
function WriteEndObject (line 455) | bool WriteEndObject() { os_->Put('}'); return true; }
function WriteStartArray (line 456) | bool WriteStartArray() { os_->Put('['); return true; }
function WriteEndArray (line 457) | bool WriteEndArray() { os_->Put(']'); return true; }
function WriteRawValue (line 459) | bool WriteRawValue(const Ch* json, size_t length) {
function Prefix (line 472) | void Prefix(Type type) {
function EndValue (line 493) | bool EndValue(bool ret) {
function WriteUint (line 521) | inline bool Writer<StringBuffer>::WriteUint(unsigned u) {
function WriteInt64 (line 529) | inline bool Writer<StringBuffer>::WriteInt64(int64_t i64) {
function WriteUint64 (line 537) | inline bool Writer<StringBuffer>::WriteUint64(uint64_t u) {
function WriteDouble (line 545) | inline bool Writer<StringBuffer>::WriteDouble(double d) {
FILE: src/listen/ClientWorker.cpp
type nacos (line 20) | namespace nacos{
function NACOS_THROW (line 44) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 74) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 290) | NACOS_THROW(NetworkException,NacosException) {
FILE: src/listen/ClientWorker.h
function namespace (line 24) | namespace nacos{
FILE: src/listen/ListeningData.h
function namespace (line 11) | namespace nacos{
FILE: src/listen/OperateItem.h
function namespace (line 13) | namespace nacos{
FILE: src/log/Logger.cpp
type nacos (line 18) | namespace nacos{
function NacosString (line 59) | const NacosString &Logger::getBaseDir() {
function LOG_LEVEL (line 63) | LOG_LEVEL Logger::getLogLevel() {
type stat (line 78) | struct stat
type tm (line 108) | struct tm
FILE: src/log/Logger.h
function namespace (line 28) | namespace nacos{
FILE: src/naming/Cluster.cpp
type nacos (line 3) | namespace nacos{
function NacosString (line 5) | NacosString Cluster::getName() const {
function HealthChecker (line 13) | HealthChecker Cluster::getHealthChecker() const {
FILE: src/naming/Instance.cpp
type nacos (line 5) | namespace nacos{
function NacosString (line 18) | NacosString Instance::toString() const{
function NacosString (line 26) | NacosString Instance::toInetAddr() {
function Instance (line 30) | Instance & Instance::operator = (const Instance &rhs)
FILE: src/naming/NacosNamingMaintainService.cpp
type nacos (line 7) | namespace nacos{
function NACOS_THROW (line 22) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 33) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 37) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 45) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 49) | NACOS_THROW(NacosException) {
FILE: src/naming/NacosNamingMaintainService.h
function namespace (line 13) | namespace nacos{
FILE: src/naming/NacosNamingService.cpp
type nacos (line 15) | namespace nacos{
function NACOS_THROW (line 37) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 47) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 57) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 68) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 82) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 91) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 115) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 125) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 135) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 146) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 160) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 168) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 177) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 186) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 195) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 208) | NACOS_THROW (NacosException)
function NACOS_THROW (line 220) | NACOS_THROW (NacosException)
function NACOS_THROW (line 230) | NACOS_THROW (NacosException)
function NACOS_THROW (line 241) | NACOS_THROW (NacosException)
function NACOS_THROW (line 257) | NACOS_THROW (NacosException)
function NACOS_THROW (line 276) | NACOS_THROW (NacosException)
function NACOS_THROW (line 286) | NACOS_THROW (NacosException)
function NACOS_THROW (line 292) | NACOS_THROW (NacosException)
function NACOS_THROW (line 298) | NACOS_THROW (NacosException) {
function NACOS_THROW (line 302) | NACOS_THROW (NacosException){
function NACOS_THROW (line 312) | NACOS_THROW(NacosException)
function NACOS_THROW (line 327) | NACOS_THROW(NacosException)
function NACOS_THROW (line 342) | NACOS_THROW(NacosException)
function NACOS_THROW (line 357) | NACOS_THROW(NacosException)
FILE: src/naming/NacosNamingService.h
function namespace (line 15) | namespace nacos{
FILE: src/naming/NamingProxy.cpp
type nacos (line 16) | namespace nacos{
function NACOS_THROW (line 41) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 61) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 77) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 92) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 149) | NACOS_THROW(NacosException) {
function NacosString (line 153) | NacosString NamingProxy::getDataToSign(const std::list <NacosString> &...
function NACOS_THROW (line 172) | NACOS_THROW(NacosException) {
function NacosString (line 250) | inline NacosString NamingProxy::getNamespaceId() {
function NACOS_THROW (line 296) | NACOS_THROW(NacosException)
function NACOS_THROW (line 313) | NACOS_THROW(NacosException)
function areYouOk (line 335) | bool areYouOk(const NacosString &imVeryOk) {
function NACOS_THROW (line 353) | NACOS_THROW(NacosException) {
function assembleServiceInfoRequest (line 363) | void assembleServiceInfoRequest(list<NacosString> &target, const Servi...
function NACOS_THROW (line 381) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 392) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 438) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 462) | NACOS_THROW(NacosException) {
FILE: src/naming/NamingProxy.h
function namespace (line 17) | namespace nacos{
FILE: src/naming/ServiceInfo.cpp
type nacos (line 10) | namespace nacos{
type timeval (line 48) | struct timeval
function NacosString (line 63) | NacosString ServiceInfo::getName() {
function NacosString (line 71) | NacosString ServiceInfo::getGroupName() {
function NacosString (line 87) | NacosString ServiceInfo::getClusters() {
function NacosString (line 136) | NacosString ServiceInfo::getJsonFromServer() const{
function NacosString (line 145) | NacosString ServiceInfo::getKey() const{
function NacosString (line 150) | NacosString ServiceInfo::getKeyEncoded() const{
function NacosString (line 170) | NacosString ServiceInfo::getKey(const NacosString &name, const NacosSt...
function NacosString (line 179) | NacosString ServiceInfo::toString() const{
function NacosString (line 185) | NacosString ServiceInfo::toInstanceString() const{
function NacosString (line 198) | NacosString ServiceInfo::getChecksum() const{
FILE: src/naming/beat/BeatInfo.cpp
type nacos (line 5) | namespace nacos{
function NacosString (line 6) | NacosString BeatInfo::toString() {
FILE: src/naming/beat/BeatInfo.h
function namespace (line 26) | namespace nacos{
FILE: src/naming/beat/BeatReactor.cpp
type nacos (line 9) | namespace nacos{
function NacosString (line 137) | NacosString BeatReactor::buildKey(const NacosString &serviceName, cons...
FILE: src/naming/beat/BeatReactor.h
function namespace (line 17) | namespace nacos{
FILE: src/naming/beat/BeatTask.cpp
type nacos (line 7) | namespace nacos{
function BeatInfo (line 12) | BeatInfo BeatTask::getBeatInfo() const {
FILE: src/naming/beat/BeatTask.h
function namespace (line 13) | namespace nacos{
FILE: src/naming/cache/ChangeAdvice.cpp
type nacos (line 5) | namespace nacos{
function NacosString (line 74) | NacosString ChangeAdvice::toString()
FILE: src/naming/cache/NamingCache.cpp
type nacos (line 3) | namespace nacos{
function NACOS_THROW (line 4) | NACOS_THROW(NacosException)
FILE: src/naming/cache/NamingCache.h
function namespace (line 13) | namespace nacos{
FILE: src/naming/selectors/HealthInstanceSelector.cpp
type nacos (line 4) | namespace nacos { namespace naming { namespace selectors {
type naming (line 4) | namespace naming { namespace selectors {
type selectors (line 4) | namespace selectors {
FILE: src/naming/selectors/RandomByWeightSelector.cpp
type nacos (line 10) | namespace nacos { namespace naming { namespace selectors {
type naming (line 10) | namespace naming { namespace selectors {
type selectors (line 10) | namespace selectors {
FILE: src/naming/selectors/RandomSelector.cpp
type nacos (line 6) | namespace nacos { namespace naming { namespace selectors {
type naming (line 6) | namespace naming { namespace selectors {
type selectors (line 6) | namespace selectors {
FILE: src/naming/subscribe/EventDispatcher.cpp
type nacos (line 10) | namespace nacos{
FILE: src/naming/subscribe/EventDispatcher.h
function namespace (line 10) | namespace nacos{
FILE: src/naming/subscribe/EventListener.cpp
type nacos (line 4) | namespace nacos {
FILE: src/naming/subscribe/HostReactor.cpp
type nacos (line 10) | namespace nacos {
FILE: src/naming/subscribe/HostReactor.h
function namespace (line 13) | namespace nacos {
FILE: src/naming/subscribe/SubscriptionPoller.cpp
type nacos (line 9) | namespace nacos{
type PollingData (line 33) | struct PollingData
FILE: src/naming/subscribe/SubscriptionPoller.h
function namespace (line 14) | namespace nacos{
FILE: src/naming/subscribe/UdpNamingServiceListener.cpp
type nacos (line 16) | namespace nacos {
function NACOS_THROW (line 18) | NACOS_THROW(NacosException) {
type sockaddr (line 93) | struct sockaddr
type sockaddr_in (line 94) | struct sockaddr_in
FILE: src/naming/subscribe/UdpNamingServiceListener.h
function namespace (line 18) | namespace nacos{
FILE: src/security/SecurityManager.cpp
type nacos (line 13) | namespace nacos {
function NACOS_THROW (line 19) | NACOS_THROW(NacosException, NetworkException) {
function NACOS_THROW (line 38) | NACOS_THROW (NacosException) {
function NacosString (line 85) | NacosString &SecurityManager::getAccessToken() {
FILE: src/security/SecurityManager.h
function namespace (line 14) | namespace nacos {
function class (line 29) | class SecurityManager {
FILE: src/server/NacosServerInfo.h
function namespace (line 11) | namespace nacos{
FILE: src/server/ServerListManager.cpp
type nacos (line 11) | namespace nacos{
function NacosString (line 73) | NacosString ServerListManager::getCurrentServerAddr() {
function NACOS_THROW (line 88) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 150) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 158) | NACOS_THROW(NacosException) {
function NACOS_THROW (line 199) | NACOS_THROW(NacosException) {
function NacosString (line 242) | NacosString ServerListManager::serverListToString(const std::list <Nac...
function NacosString (line 257) | NacosString ServerListManager::toString() const {
function NacosString (line 319) | const NacosString &ServerListManager::getContextPath() const {
FILE: src/server/ServerListManager.h
function namespace (line 17) | namespace nacos{
FILE: src/thread/BlockingQueue.h
function namespace (line 11) | namespace nacos{
FILE: src/thread/DelayedThreadPool.cpp
type nacos (line 5) | namespace nacos {
class DelayedWorker (line 10) | class DelayedWorker : public Task {
method DelayedWorker (line 15) | DelayedWorker(DelayedThreadPool &container) : _container(container) {
method run (line 19) | void run() {
type tagAscOrdFunctor (line 110) | struct tagAscOrdFunctor{
FILE: src/thread/DelayedThreadPool.h
function namespace (line 10) | namespace nacos {
FILE: src/thread/Mutex.h
function namespace (line 16) | namespace nacos{
FILE: src/thread/RWLock.h
function namespace (line 13) | namespace nacos{
FILE: src/thread/Task.h
function namespace (line 6) | namespace nacos{
FILE: src/thread/Thread.cpp
type sigaction (line 5) | struct sigaction
type sigaction (line 8) | struct sigaction
FILE: src/thread/Thread.h
function namespace (line 14) | namespace nacos{
FILE: src/thread/ThreadLocal.h
function namespace (line 6) | namespace nacos{
FILE: src/thread/ThreadPool.cpp
type nacos (line 7) | namespace nacos{
function Task (line 37) | Task *ThreadPool::take() {
FILE: src/thread/ThreadPool.h
function namespace (line 11) | namespace nacos{
FILE: src/thread/Tid.cpp
function TID_T (line 13) | TID_T gettidv1() {
FILE: src/utils/ConfigParserUtils.cpp
type nacos (line 12) | namespace nacos {
function NACOS_THROW (line 14) | NACOS_THROW(NacosException) {
FILE: src/utils/ConfigParserUtils.h
function namespace (line 11) | namespace nacos {
FILE: src/utils/DirUtils.cpp
type nacos (line 24) | namespace nacos{
function NacosString (line 25) | NacosString DirUtils::getHome() {
function NacosString (line 31) | NacosString DirUtils::getCwd() {
FILE: src/utils/DirUtils.h
function namespace (line 6) | namespace nacos{
FILE: src/utils/GroupKey.h
function namespace (line 28) | namespace nacos{
FILE: src/utils/NamingUtils.h
function namespace (line 9) | namespace nacos{
FILE: src/utils/NetUtils.cpp
type nacos (line 13) | namespace nacos{
function NACOS_THROW (line 15) | NACOS_THROW(NacosException){
function NACOS_THROW (line 52) | NACOS_THROW(NacosException)
FILE: src/utils/NetUtils.h
function namespace (line 8) | namespace nacos{
FILE: src/utils/ParamUtils.h
function namespace (line 12) | namespace nacos{
FILE: src/utils/RandomUtils.cpp
type nacos (line 10) | namespace nacos{
function NACOS_THROW (line 44) | NACOS_THROW (NacosException) {
FILE: src/utils/RandomUtils.h
function namespace (line 16) | namespace nacos{
FILE: src/utils/SequenceProvider.h
function namespace (line 11) | namespace nacos
FILE: src/utils/TimeUtils.cpp
type nacos (line 4) | namespace nacos{
type timeval (line 6) | struct timeval
type timeval (line 12) | struct timeval
FILE: src/utils/TimeUtils.h
function namespace (line 7) | namespace nacos{
FILE: src/utils/UuidUtils.cpp
type nacos (line 9) | namespace nacos{
function NacosString (line 16) | NacosString UuidUtils::generateUuid() {
FILE: src/utils/UuidUtils.h
function namespace (line 15) | namespace nacos{
FILE: src/utils/url.cpp
type nacos (line 4) | namespace nacos{
function NacosString (line 5) | NacosString urlencode(const NacosString &content) {
function NacosString (line 22) | NacosString urldecode(const NacosString &content) {
FILE: src/utils/url.h
function namespace (line 6) | namespace nacos{
FILE: test/allinone.cpp
function main (line 213) | int main() {
FILE: test/testcase/AssertString.cpp
function testStringEqual (line 10) | bool testStringEqual() {
FILE: test/testcase/DebugTest.cpp
function testDebug (line 6) | bool testDebug() {
function testVaArgs (line 15) | bool testVaArgs() {
function testlogPrint (line 24) | bool testlogPrint() {
function testVaArgs2 (line 31) | bool testVaArgs2() {
FILE: test/testcase/testAppConfigManager.cpp
function testAppConfigManager (line 9) | bool testAppConfigManager() {
FILE: test/testcase/testCache.cpp
function testSaveSnapshot (line 10) | bool testSaveSnapshot() {
function testCleanTestenvCacheAndGetTestenv (line 29) | bool testCleanTestenvCacheAndGetTestenv() {
function testCleanPrdCacheAndGetPrdenv (line 70) | bool testCleanPrdCacheAndGetPrdenv() {
function testCleanAllCache (line 111) | bool testCleanAllCache() {
FILE: test/testcase/testDelayedThreadPool.cpp
class DelayedTask (line 12) | class DelayedTask : public Task {
method DelayedTask (line 17) | DelayedTask() {
method run (line 21) | void run() {
function testDelayedThread (line 38) | bool testDelayedThread() {
function testDelayedThread2 (line 65) | bool testDelayedThread2() {
FILE: test/testcase/testDeleteConfig.cpp
function testDeleteConfig (line 11) | bool testDeleteConfig() {
FILE: test/testcase/testDeleteListenedKeys.cpp
class MyListener (line 15) | class MyListener : public Listener {
method MyListener (line 19) | MyListener(int num) {
method receiveConfigInfo (line 23) | void receiveConfigInfo(const NacosString &configInfo) {
function testRemoveKeyBeingWatched (line 31) | bool testRemoveKeyBeingWatched() {
FILE: test/testcase/testEndpointWithNamingSvc.cpp
function testEndpointWithNamingProxy (line 21) | bool testEndpointWithNamingProxy() {
FILE: test/testcase/testGetAllInstances.cpp
function testGetAllInstances (line 21) | bool testGetAllInstances() {
FILE: test/testcase/testGetConfig.cpp
function testGetConfig (line 11) | bool testGetConfig() {
function testGetConfigwithDefaultPort (line 36) | bool testGetConfigwithDefaultPort() {
function testInvalidConfig (line 52) | bool testInvalidConfig() {
FILE: test/testcase/testGetServiceNames.cpp
function testGetServiceNames (line 21) | bool testGetServiceNames() {
FILE: test/testcase/testHttpRequest.cpp
function testNormalHttpRequest (line 10) | bool testNormalHttpRequest() {
function testNoServerRequest (line 44) | bool testNoServerRequest() {
FILE: test/testcase/testIOUtils.cpp
function testReadWriteFile (line 12) | bool testReadWriteFile() {
function testGetFileSize (line 27) | bool testGetFileSize() {
function testFileExists (line 41) | bool testFileExists() {
function testCreateAndRemove (line 61) | bool testCreateAndRemove() {
function testCleanDirectory (line 76) | bool testCleanDirectory() {
FILE: test/testcase/testInstanceSelector.cpp
function testInstanceSelectors (line 24) | bool testInstanceSelectors() {
function testRandomByWeightSelector (line 70) | bool testRandomByWeightSelector()
FILE: test/testcase/testJson2BizObjects.cpp
function testString2ServiceInfo (line 12) | bool testString2ServiceInfo() {
function testMalformedJson2ServiceInfo (line 48) | bool testMalformedJson2ServiceInfo() {
function testMalformedDouble2ServiceInfo (line 89) | bool testMalformedDouble2ServiceInfo() {
function testLackcacheMillisServiceInfo (line 132) | bool testLackcacheMillisServiceInfo() {
FILE: test/testcase/testListenWorker.cpp
class KeyChangeListener (line 18) | class KeyChangeListener : public Listener {
method setKey (line 22) | void setKey(const NacosString &_key) { key = _key; }
method NacosString (line 24) | NacosString getKey() const { return key; }
method receiveConfigInfo (line 26) | void receiveConfigInfo(const NacosString &configInfo) {
function testAddListener (line 32) | bool testAddListener() {
FILE: test/testcase/testListeningKeys.cpp
class MyListener (line 15) | class MyListener : public Listener {
method MyListener (line 19) | MyListener(int num) {
method receiveConfigInfo (line 23) | void receiveConfigInfo(const NacosString &configInfo) {
function testListeningKeys (line 31) | bool testListeningKeys() {
FILE: test/testcase/testListeningKeysWithHttpPrefix.cpp
class MyListenerHttpPrefix (line 15) | class MyListenerHttpPrefix : public Listener {
method MyListenerHttpPrefix (line 19) | MyListenerHttpPrefix(int num) {
method receiveConfigInfo (line 23) | void receiveConfigInfo(const NacosString &configInfo) {
function testListeningKeysWithHttpPrefix (line 31) | bool testListeningKeysWithHttpPrefix() {
FILE: test/testcase/testMAC.cpp
type _HMACSHA1TestCase (line 9) | struct _HMACSHA1TestCase {
function testHMACSHA1 (line 27) | bool testHMACSHA1() {
FILE: test/testcase/testMD5.cpp
function testMD5 (line 9) | bool testMD5() {
FILE: test/testcase/testMaintainInstances.cpp
function testMaintainUpdateInstance (line 18) | bool testMaintainUpdateInstance() {
FILE: test/testcase/testMaintainServices.cpp
function testMaintainGetService (line 17) | bool testMaintainGetService() {
function testMaintainUpdateService (line 45) | bool testMaintainUpdateService() {
function testMaintainCreateService (line 80) | bool testMaintainCreateService() {
FILE: test/testcase/testNamingService.cpp
function testNamingProxySmokeTest (line 23) | bool testNamingProxySmokeTest() {
function testNamingProxyServerHealthy (line 102) | bool testNamingProxyServerHealthy() {
function testNamingProxyFailOver (line 137) | bool testNamingProxyFailOver() {
class NamingServiceSelector (line 142) | class NamingServiceSelector : public naming::selectors::Selector<Instanc...
method setSelectPort (line 146) | void setSelectPort(int port) { _port = port; }
method select (line 147) | list<Instance> select(const std::list<Instance> &itemsToSelect) {
function testNamingServiceRegister (line 160) | bool testNamingServiceRegister() {
function testNamingServiceAndDeRegisterActively (line 226) | bool testNamingServiceAndDeRegisterActively() {
FILE: test/testcase/testNamingSubscribe.cpp
class MyServiceListener (line 15) | class MyServiceListener : public EventListener {
method MyServiceListener (line 19) | MyServiceListener(int num) {
method receiveNamingInfo (line 23) | void receiveNamingInfo(const ServiceInfo &serviceInfo){
function testListenService (line 32) | bool testListenService() {
function testSubscribeAlotOfServices (line 64) | bool testSubscribeAlotOfServices() {
FILE: test/testcase/testNetUtils.cpp
function testGetHostIp (line 8) | bool testGetHostIp() {
FILE: test/testcase/testPublishConfig.cpp
function testPublishConfig (line 14) | bool testPublishConfig() {
FILE: test/testcase/testPublishConfigWithHttpPrefix.cpp
function testPublishConfigWithHttpPrefix (line 14) | bool testPublishConfigWithHttpPrefix() {
FILE: test/testcase/testRapidJson.cpp
function testRapidJsonIntroduce (line 13) | bool testRapidJsonIntroduce() {
function testSerialize (line 37) | bool testSerialize() {
FILE: test/testcase/testSequenceProvider.cpp
function testSequenceProvider (line 27) | bool testSequenceProvider() {
FILE: test/testcase/testServerListManager.cpp
function testServerListManager (line 14) | bool testServerListManager() {
FILE: test/testcase/testStringExplode.cpp
function testStringExplode (line 11) | bool testStringExplode() {
function testStringExplode2 (line 46) | bool testStringExplode2() {
FILE: test/testcase/testThreadLocal.cpp
class ThreadLocalWithInit (line 14) | class ThreadLocalWithInit : public ThreadLocal<int*> {
method onCreate (line 16) | void onCreate(int **value){
method onDestroy (line 21) | void onDestroy(int **value) {
function testThreadLocal (line 67) | bool testThreadLocal() {
function testThreadLocalPtr (line 89) | bool testThreadLocalPtr() {
function testThreadLocalPtrWithInitializer (line 111) | bool testThreadLocalPtrWithInitializer() {
FILE: test/testcase/testThreadSmoke.cpp
class ThreadPoolLongRunTask (line 13) | class ThreadPoolLongRunTask : public Task {
method ThreadPoolLongRunTask (line 16) | ThreadPoolLongRunTask(int taskId) {
method run (line 21) | void run() {
function testThreadSmoke (line 35) | bool testThreadSmoke() {
function testThreadPoolSmoke (line 55) | bool testThreadPoolSmoke() {
class SmokingTestThreadTask (line 87) | class SmokingTestThreadTask : public Task {
method SmokingTestThreadTask (line 91) | SmokingTestThreadTask(const NacosString &taskName, AtomicInt<int> &cou...
method run (line 95) | void run() {
function testThreadPoolConcurrentWithAtomicCounter (line 106) | bool testThreadPoolConcurrentWithAtomicCounter() {
FILE: test/testcase/testURL.cpp
function testURLEncodeAndDecode (line 10) | bool testURLEncodeAndDecode() {
FILE: test/testcase/testUUID.cpp
function testUUID (line 8) | bool testUUID() {
function testUUIDMT (line 29) | bool testUUIDMT() {
Condensed preview — 239 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,301K chars).
[
{
"path": ".gitignore",
"chars": 446,
"preview": "# Prerequisites\n*.d\n\n# Compiled Object files\n*.slo\n*.lo\n*.o\n*.obj\n\n# Precompiled Headers\n*.gch\n*.pch\n\n# Compiled Dynamic"
},
{
"path": "LICENSE",
"chars": 11357,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 12581,
"preview": "<img src=\"https://github.com/alibaba/nacos/blob/develop/doc/Nacos_Logo.png\" width=\"50%\" height=\"50%\" /> \n\n[中文版本说明请点这里](h"
},
{
"path": "README_zh_CN.md",
"chars": 11244,
"preview": "<img src=\"https://github.com/alibaba/nacos/blob/develop/doc/Nacos_Logo.png\" width=\"50%\" height=\"50%\" />\n\n# Nacos-sdk-cpp"
},
{
"path": "examples/IntegratingIntoYourProject.cpp",
"chars": 772,
"preview": "#include <iostream>\n#include \"Nacos.h\"\n\nusing namespace std;\nusing namespace nacos;\n\nint main() {\n Properties props;\n"
},
{
"path": "examples/generate_examples.sh",
"chars": 622,
"preview": "#!/bin/bash\n\ng++ -I/usr/local/include/nacos/ IntegratingIntoYourProject.cpp -lnacos-cli -o IntegratingIntoYourProject.ou"
},
{
"path": "examples/getAllInstances.cpp",
"chars": 790,
"preview": "#include <iostream>\n#include <list>\n#include \"Nacos.h\"\n\nusing namespace std;\nusing namespace nacos;\n\nint main() {\n Pr"
},
{
"path": "examples/getConfig.cpp",
"chars": 772,
"preview": "#include <iostream>\n#include \"Nacos.h\"\n\nusing namespace std;\nusing namespace nacos;\n\nint main() {\n Properties props;\n"
},
{
"path": "examples/listenToKeys.cpp",
"chars": 1335,
"preview": "#include <iostream>\n#include \"Nacos.h\"\n#include <stdio.h>\n\nusing namespace std;\nusing namespace nacos;\n\nclass MyListener"
},
{
"path": "examples/registerInstances.cpp",
"chars": 1604,
"preview": "#include <iostream>\n#include <unistd.h>\n#include \"Nacos.h\"\n\nusing namespace std;\nusing namespace nacos;\n\nint main() {\n "
},
{
"path": "examples/setConfig.cpp",
"chars": 1175,
"preview": "#include <iostream>\n#include \"Nacos.h\"\n\nusing namespace std;\nusing namespace nacos;\n\nint main() {\n Properties props;\n"
},
{
"path": "examples/subscribeServices.cpp",
"chars": 1659,
"preview": "#include <iostream>\n#include \"Nacos.h\"\n#include <stdio.h>\n\nusing namespace std;\nusing namespace nacos;\n\nclass MyServiceL"
},
{
"path": "include/Compatibility.h",
"chars": 356,
"preview": "//\n// Created by liuhanyu on 2021/4/7.\n// Compatibility header\n\n#ifndef NACOS_SDK_CPP_COMPATIBILITY_H\n#define NACOS_SDK_"
},
{
"path": "include/Nacos.h",
"chars": 809,
"preview": "/*\n * Copyright 1999-2020 Alibaba Group Holding Ltd.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\""
},
{
"path": "include/NacosExceptions.h",
"chars": 3886,
"preview": "#ifndef __NACOS_EXCEPTIONS_H_\r\n#define __NACOS_EXCEPTIONS_H_\r\n\r\n#include <exception>\r\n#include \"NacosString.h\"\r\n#include"
},
{
"path": "include/NacosString.h",
"chars": 814,
"preview": "#ifndef __NACOS_STRING_H_\r\n#define __NACOS_STRING_H_\r\n\r\n#include <string>\r\n#include <sstream>\r\n\r\n#define NacosString std"
},
{
"path": "include/Properties.h",
"chars": 649,
"preview": "#ifndef __PROPERTIES_H_\r\n#define __PROPERTIES_H_\r\n\r\n#include <map>\r\n#include \"NacosString.h\"\r\n\r\nnamespace nacos{\r\nclass "
},
{
"path": "include/ResourceGuard.h",
"chars": 483,
"preview": "//\n// Created by liuhanyu on 2020/9/6.\n//\n\n#ifndef NACOS_SDK_CPP_RESOURCEGUARD_H\n#define NACOS_SDK_CPP_RESOURCEGUARD_H\n\n"
},
{
"path": "include/config/ConfigService.h",
"chars": 2423,
"preview": "#ifndef __CFG_SVC_H_\r\n#define __CFG_SVC_H_\r\n\r\n#include \"NacosExceptions.h\"\r\n#include \"NacosString.h\"\r\n#include \"listen/L"
},
{
"path": "include/constant/ConfigConstant.h",
"chars": 1279,
"preview": "#ifndef __CONFIG_CONSTANTS_H_\n#define __CONFIG_CONSTANTS_H_\n\n#include \"NacosString.h\"\n\n/**\n * Constant\n *\n * @author Nac"
},
{
"path": "include/constant/NamingConstant.h",
"chars": 765,
"preview": "#ifndef __NAMING_CONSTANT_H_\n#define __NAMING_CONSTANT_H_\n\n#include \"NacosString.h\"\n\nnamespace nacos{\nclass NamingConsta"
},
{
"path": "include/constant/PropertyKeyConst.h",
"chars": 2126,
"preview": "#ifndef __PROP_KEY_CONST_H_\n#define __PROP_KEY_CONST_H_\n\n#include \"NacosString.h\"\n\nnamespace nacos{\nclass PropertyKeyCon"
},
{
"path": "include/constant/UtilAndComs.h",
"chars": 629,
"preview": "#ifndef __UTIL_N_COMS_H_\n#define __UTIL_N_COMS_H_\n\n#include \"NacosString.h\"\n\nnamespace nacos{\nclass UtilAndComs {\npublic"
},
{
"path": "include/factory/INacosServiceFactory.h",
"chars": 732,
"preview": "//\n// Created by liuhanyu on 2020/8/30.\n//\n\n#ifndef NACOS_SDK_CPP_INACOSSERVICEFACTORY_H\n#define NACOS_SDK_CPP_INACOSSER"
},
{
"path": "include/factory/NacosFactoryFactory.h",
"chars": 323,
"preview": "#ifndef NACOS_FACTORY_FACTORY_H\n#define NACOS_FACTORY_FACTORY_H\n#include \"factory/INacosServiceFactory.h\"\nnamespace naco"
},
{
"path": "include/listen/Listener.h",
"chars": 735,
"preview": "#ifndef __LISTENER_H_\r\n#define __LISTENER_H_\r\n\r\n#include \"NacosString.h\"\r\n#include \"thread/AtomicInt.h\"\r\n\r\nnamespace nac"
},
{
"path": "include/naming/ChangeAdvice.h",
"chars": 776,
"preview": "#ifndef __CHG_ADVICE_H_\n#define __CHG_ADVICE_H_\n\n#include \"NacosString.h\"\n#include \"naming/ServiceInfo.h\"\n\n//The wrapper"
},
{
"path": "include/naming/Cluster.h",
"chars": 765,
"preview": "#ifndef __CLUSTER_H_\n#define __CLUSTER_H_\n\n#include <map>\n#include \"NacosString.h\"\n\nnamespace nacos{\nclass HealthChecker"
},
{
"path": "include/naming/Instance.h",
"chars": 1284,
"preview": "#ifndef __INSTANCE_H_\r\n#define __INSTANCE_H_\r\n\r\n#include <map>\r\n#include \"NacosString.h\"\r\n\r\nnamespace nacos{\r\n\r\n//a serv"
},
{
"path": "include/naming/ListView.h",
"chars": 479,
"preview": "#ifndef __NACOS_LIST_VUE_H_\n#define __NACOS_LIST_VUE_H_\n\n#include <list>\n#include \"NacosString.h\"\n\nnamespace nacos{\ntemp"
},
{
"path": "include/naming/NamingMaintainService.h",
"chars": 1019,
"preview": "#ifndef __NAM_MAINTN_SVC_H_\n#define __NAM_MAINTN_SVC_H_\n\n#include <list>\n#include \"naming/Instance.h\"\n#include \"naming/S"
},
{
"path": "include/naming/NamingService.h",
"chars": 22675,
"preview": "#ifndef __NAM_SVC_H_\r\n#define __NAM_SVC_H_\r\n\r\n#include <list>\r\n#include \"naming/Instance.h\"\r\n#include \"naming/selectors/"
},
{
"path": "include/naming/ServiceInfo.h",
"chars": 2232,
"preview": "#ifndef __SVC_INFO_H_\r\n#define __SVC_INFO_H_\r\n\r\n#include <list>\r\n#include \"NacosString.h\"\r\n#include \"naming/Instance.h\"\r"
},
{
"path": "include/naming/ServiceInfo2.h",
"chars": 3789,
"preview": "#ifndef __SVC_INFO_2_H_\n#define __SVC_INFO_2_H_\n\n#include <list>\n#include \"NacosString.h\"\n#include \"naming/Cluster.h\"\n\nn"
},
{
"path": "include/naming/selectors/HealthInstanceSelector.h",
"chars": 388,
"preview": "#ifndef __HEALTH_INST_SELECTOR_H_\n#define __HEALTH_INST_SELECTOR_H_\n\n#include <list>\n#include \"naming/selectors/Selector"
},
{
"path": "include/naming/selectors/RandomByWeightSelector.h",
"chars": 417,
"preview": "#ifndef __WEIGHTED_RND_SELECTOR_H_\n#define __WEIGHTED_RND_SELECTOR_H_\n\n#include <list>\n#include \"naming/selectors/Select"
},
{
"path": "include/naming/selectors/RandomSelector.h",
"chars": 363,
"preview": "#ifndef __RND_SELECTOR_H_\n#define __RND_SELECTOR_H_\n\n#include <list>\n#include \"naming/selectors/Selector.h\"\n\nnamespace n"
},
{
"path": "include/naming/selectors/Selector.h",
"chars": 428,
"preview": "#ifndef __SELECTOR_H_\n#define __SELECTOR_H_\n\n#include <list>\n#include \"naming/Instance.h\"\n\nnamespace nacos { namespace n"
},
{
"path": "include/naming/subscribe/EventListener.h",
"chars": 860,
"preview": "//\n// Created by liuhanyu on 2020/9/24.\n//\n\n#ifndef NACOS_SDK_CPP_EVENTLISTENER_H\n#define NACOS_SDK_CPP_EVENTLISTENER_H\n"
},
{
"path": "include/server/ServerSelector.h",
"chars": 580,
"preview": "#ifndef NACOS_SDK_CPP_SERVERSELECTOR_H\n#define NACOS_SDK_CPP_SERVERSELECTOR_H\n\n#include \"NacosServerInfo.h\"\n#include <li"
},
{
"path": "include/thread/AtomicInt.h",
"chars": 605,
"preview": "#ifndef __ATOMIC_INT_H_\n#define __ATOMIC_INT_H_\n\nnamespace nacos{\ntemplate<typename T>\nclass AtomicInt {\nprivate:\n vo"
},
{
"path": "nacos-cpp-cli.properties",
"chars": 1098,
"preview": "#!!please NOTE that the file format for this properties should be UNIX!!\n#specify nacos server address here(separated by"
},
{
"path": "src/NacosExceptions.cpp",
"chars": 363,
"preview": "#include \"NacosExceptions.h\"\r\n\r\nnamespace nacos{\r\nNacosException::NacosException(int errorcode, const char *errormsg) NA"
},
{
"path": "src/NacosString.cpp",
"chars": 574,
"preview": "#include <math.h>\r\n#include <stdio.h>\r\n#include <sstream>\r\n#include \"NacosString.h\"\r\n\r\nnamespace nacos{\r\nconst NacosStri"
},
{
"path": "src/config/AppConfigManager.cpp",
"chars": 4447,
"preview": "#include \"src/utils/ParamUtils.h\"\n#include \"AppConfigManager.h\"\n#include \"NacosString.h\"\n#include \"Properties.h\"\n#includ"
},
{
"path": "src/config/AppConfigManager.h",
"chars": 1276,
"preview": "#ifndef __APP_CFG_MGR_H_\n#define __APP_CFG_MGR_H_\n\n#include \"NacosExceptions.h\"\n#include \"NacosString.h\"\n#include \"Prope"
},
{
"path": "src/config/ConcurrentDiskUtil.cpp",
"chars": 2149,
"preview": "#include <errno.h>\r\n#include <stdio.h>\r\n#include <stdlib.h>\r\n#include <sys/file.h>\r\n#include \"ConcurrentDiskUtil.h\"\r\n#in"
},
{
"path": "src/config/ConcurrentDiskUtil.h",
"chars": 920,
"preview": "#ifndef __CONC_DISK_UTIL_H_\n#define __CONC_DISK_UTIL_H_\n\n#include \"NacosString.h\"\n#include \"NacosExceptions.h\"\n#include "
},
{
"path": "src/config/ConfigProxy.cpp",
"chars": 3014,
"preview": "//\n// Created by liuhanyu on 2021/7/6.\n//\n\n#include \"ConfigProxy.h\"\n#include \"src/http/HttpDelegate.h\"\n#include \"src/uti"
},
{
"path": "src/config/ConfigProxy.h",
"chars": 766,
"preview": "//\n// Created by liuhanyu on 2021/7/6.\n//\n\n#ifndef NACOS_SDK_CPP_CONFIGPROXY_H\n#define NACOS_SDK_CPP_CONFIGPROXY_H\n#incl"
},
{
"path": "src/config/IOUtils.cpp",
"chars": 7096,
"preview": "#include \"IOUtils.h\"\r\n#include <sys/stat.h>\r\n#include <sys/types.h>\r\n#include <dirent.h>\r\n#include <string.h>\r\n#include "
},
{
"path": "src/config/IOUtils.h",
"chars": 1316,
"preview": "#ifndef __IO_UTILS_H_\n#define __IO_UTILS_H_\n\n#include <list>\n#include \"NacosString.h\"\n#include \"NacosExceptions.h\"\n#incl"
},
{
"path": "src/config/JVMUtil.h",
"chars": 569,
"preview": "#ifndef __JVMUTIL_H_\n#define __JVMUTIL_H_\n\nnamespace nacos{\nclass JVMUtil {\npublic:\n /**\n * whether is multi inst"
},
{
"path": "src/config/LocalSnapshotManager.cpp",
"chars": 6700,
"preview": "#include \"LocalSnapshotManager.h\"\n#include <stdio.h>\n#include <list>\n#include <unistd.h>\n#include <sys/types.h>\n#include"
},
{
"path": "src/config/LocalSnapshotManager.h",
"chars": 1812,
"preview": "#ifndef __LOCAL_SNAPSHOT_MGR_H_\n#define __LOCAL_SNAPSHOT_MGR_H_\n\n#include \"NacosString.h\"\n#include \"NacosExceptions.h\"\n#"
},
{
"path": "src/config/NacosConfigService.cpp",
"chars": 8573,
"preview": "#include \"NacosConfigService.h\"\r\n#include \"src/security/SecurityManager.h\"\r\n#include \"src/log/Logger.h\"\r\n#include \"Confi"
},
{
"path": "src/config/NacosConfigService.h",
"chars": 3372,
"preview": "#ifndef __NACOS_CFG_SVC_H_\n#define __NACOS_CFG_SVC_H_\n\n#include \"config/ConfigService.h\"\n#include \"src/http/HttpDelegate"
},
{
"path": "src/config/SnapShotSwitch.cpp",
"chars": 330,
"preview": "#include \"LocalSnapshotManager.h\"\r\n#include \"SnapShotSwitch.h\"\r\n\r\nnamespace nacos{\r\nbool SnapShotSwitch::getIsSnapShot()"
},
{
"path": "src/config/SnapShotSwitch.h",
"chars": 290,
"preview": "#ifndef __SS_SWITCH_H_\n#define __SS_SWITCH_H_\n\nnamespace nacos{\nclass SnapShotSwitch {\nprivate:\n /**\n * whether u"
},
{
"path": "src/constant/ConfigConstant.cpp",
"chars": 1506,
"preview": "#include \"constant/ConfigConstant.h\"\n\n/**\n * Constant\n *\n * @author Nacos\n */\n\nnamespace nacos{\nconst NacosString Config"
},
{
"path": "src/constant/NamingConstant.cpp",
"chars": 954,
"preview": "#include \"constant/NamingConstant.h\"\n\nnamespace nacos{\nconst NacosString NamingConstant::SERVICE_NAME = \"serviceName\";\n\n"
},
{
"path": "src/constant/PropertyKeyConst.cpp",
"chars": 2619,
"preview": "#include \"constant/PropertyKeyConst.h\"\n\nnamespace nacos{\nconst NacosString PropertyKeyConst::IS_USE_ENDPOINT_PARSING_RUL"
},
{
"path": "src/constant/UtilAndComs.cpp",
"chars": 1036,
"preview": "#include \"constant/UtilAndComs.h\"\n\nnamespace nacos{\nNacosString UtilAndComs::VERSION = \"Nacos-C-Client:v1.0.21\";//TODO:f"
},
{
"path": "src/crypto/MACProvider.cpp",
"chars": 1528,
"preview": "//\n// Created by liuhanyu on 2021/7/8.\n//\n\n#include \"MACProvider.h\"\n#include \"src/crypto/hmac_sha1/hmac/hmac.h\"\n\nnamespa"
},
{
"path": "src/crypto/MACProvider.h",
"chars": 802,
"preview": "//\n// Created by liuhanyu on 2021/7/8.\n//\n\n#ifndef NACOS_SDK_CPP_MACPROVIDER_H\n#define NACOS_SDK_CPP_MACPROVIDER_H\n#incl"
},
{
"path": "src/crypto/SignatureTool.h",
"chars": 1002,
"preview": "//\n// Created by liuhanyu on 2021/7/8.\n//\n\n#ifndef SIGNATURE_TOOL\n#define SIGNATURE_TOOL\n\n#include \"NacosString.h\"\n#incl"
},
{
"path": "src/crypto/base64/base64.h",
"chars": 1880,
"preview": "/*\n* Base64 encoding/decoding (RFC1341)\n* Copyright (c) 2005-2011, Jouni Malinen <j@w1.fi>\n*\n* This software may be dist"
},
{
"path": "src/crypto/hmac_sha1/LICENSE",
"chars": 1075,
"preview": "The MIT License (MIT)\n\nCopyright (c) 2014 Bob Liu\n\nPermission is hereby granted, free of charge, to any person obtaining"
},
{
"path": "src/crypto/hmac_sha1/README.md",
"chars": 510,
"preview": "hmac-sha1\n=========\n\n[](https://travis-ci.org/Akagi201/hmac"
},
{
"path": "src/crypto/hmac_sha1/hmac/hmac.h",
"chars": 443,
"preview": "/**\n* @file re_hmac.h Interface to HMAC functions\n*\n* Copyright (C) 2010 Creytiv.com\n*/\n\n#ifndef HMAC_H_\n#define HMAC_H"
},
{
"path": "src/crypto/hmac_sha1/hmac/hmac_sha1.cpp",
"chars": 2198,
"preview": "/**\n* @file hmac_sha1.c Implements HMAC-SHA1 as of RFC 2202\n*\n* Copyright (C) 2010 Creytiv.com\n*/\n#include <string.h>\n#"
},
{
"path": "src/crypto/hmac_sha1/sha/sha.h",
"chars": 921,
"preview": "/**\n* @file re_sha.h Interface to SHA (Secure Hash Standard) functions\n*\n* Copyright (C) 2010 Creytiv.com\n*/\n\n#ifndef S"
},
{
"path": "src/crypto/hmac_sha1/sha/sha1.cpp",
"chars": 9212,
"preview": "/**\n* @file sha1.c SHA-1 in C\n*/\n\n/*\nBy Steve Reid <sreid@sea-to-sky.net>\n100% Public Domain\n\n-----------------\nModified"
},
{
"path": "src/crypto/md5/md5.cpp",
"chars": 9806,
"preview": "#include \"md5.h\"\n\nusing namespace std;\n\n/* Constants for MD5Transform routine. */\n#define S11 7\n#define S12 12\n#define S"
},
{
"path": "src/crypto/md5/md5.h",
"chars": 1447,
"preview": "#ifndef MD5_H\n#define MD5_H\n\n#include <string>\n#include <string.h>\n#include <fstream>\n#include \"NacosString.h\"\n\nnamespac"
},
{
"path": "src/debug/DebugAssertion.h",
"chars": 1199,
"preview": "#ifndef __DEBUG_ASSERTION_H_\n#define __DEBUG_ASSERTION_H_\n\n#include <stdlib.h>\n#include <stdio.h>\n#include \"NacosString."
},
{
"path": "src/factory/NacosFactoryFactory.cpp",
"chars": 483,
"preview": "#include \"factory/NacosFactoryFactory.h\"\n#include \"src/factory/NacosServiceFactory.h\"\nnamespace nacos {\n\nINacosServiceFa"
},
{
"path": "src/factory/NacosServiceFactory.cpp",
"chars": 8477,
"preview": "//\n// Created by liuhanyu on 2020/8/30.\n//\n\n#include \"src/factory/NacosServiceFactory.h\"\n#include \"src/init/Init.h\"\n#inc"
},
{
"path": "src/factory/NacosServiceFactory.h",
"chars": 1348,
"preview": "//\n// Created by liuhanyu on 2020/8/30.\n//\n\n#ifndef NACOS_SDK_CPP_NACOSSERVICEFACTORY_H\n#define NACOS_SDK_CPP_NACOSSERVI"
},
{
"path": "src/factory/ObjectConfigData.cpp",
"chars": 7303,
"preview": "#include \"ObjectConfigData.h\"\n#include \"src/http/HttpDelegate.h\"\n#include \"src/naming/NamingProxy.h\"\n#include \"src/namin"
},
{
"path": "src/factory/ObjectConfigData.h",
"chars": 2036,
"preview": "#ifndef __OBJ_CFG_DATA_H_\n#define __OBJ_CFG_DATA_H_\n\n#include \"naming/NamingService.h\"\n#include \"config/ConfigService.h\""
},
{
"path": "src/http/HTTPCli.cpp",
"chars": 20318,
"preview": "#include <string.h>\r\n#include \"HTTPCli.h\"\r\n#include \"src/utils/url.h\"\r\n#include \"constant/UtilAndComs.h\"\r\n#include \"src/"
},
{
"path": "src/http/HTTPCli.h",
"chars": 4371,
"preview": "#ifndef __HTTP_CLI_H_\n#define __HTTP_CLI_H_\n\n\n#include <pthread.h>\n#include <curl/curl.h>\n#include \"NacosString.h\"\n#incl"
},
{
"path": "src/http/HttpDelegate.h",
"chars": 2771,
"preview": "#ifndef __HTTP_AGENT_H_\n#define __HTTP_AGENT_H_\n\n#include \"NacosExceptions.h\"\n#include \"NacosString.h\"\n#include \"IHttpCl"
},
{
"path": "src/http/HttpStatus.h",
"chars": 3689,
"preview": "#ifndef __HTTP_STATUS_H_\n#define __HTTP_STATUS_H_\n//Copied from JAVA source code HttpURLConnection.java\n// REMIND: do we"
},
{
"path": "src/http/IHttpCli.h",
"chars": 3595,
"preview": "#ifndef __IHTTP_CLI_H_\n#define __IHTTP_CLI_H_\n\n#include <list>\n#include <map>\n#include <curl/curl.h>\n#include \"NacosExce"
},
{
"path": "src/http/delegate/NacosAuthHttpDelegate.cpp",
"chars": 2205,
"preview": "//\n// Created by liuhanyu on 2020/12/5.\n//\n\n#include \"NacosAuthHttpDelegate.h\"\n#include \"src/security/SecurityManager.h\""
},
{
"path": "src/http/delegate/NacosAuthHttpDelegate.h",
"chars": 1755,
"preview": "//\n// Created by liuhanyu on 2020/12/5.\n//\n\n#ifndef NACOS_SDK_CPP_NACOSAUTHHTTPDELEGATE_H\n#define NACOS_SDK_CPP_NACOSAUT"
},
{
"path": "src/http/delegate/NoOpHttpDelegate.cpp",
"chars": 2123,
"preview": "#include \"NoOpHttpDelegate.h\"\n\nusing namespace std;\n\nnamespace nacos{\nNacosString NoOpHttpDelegate::getEncode() const {\n"
},
{
"path": "src/http/delegate/NoOpHttpDelegate.h",
"chars": 1538,
"preview": "#ifndef __SVR_HTTP_AGENT_H_\n#define __SVR_HTTP_AGENT_H_\n\n#include \"NacosExceptions.h\"\n#include \"NacosString.h\"\n#include "
},
{
"path": "src/init/Init.cpp",
"chars": 1437,
"preview": "#include \"Init.h\"\n#include \"src/http/HTTPCli.h\"\n#include \"src/config/SnapShotSwitch.h\"\n#include \"src/config/JVMUtil.h\"\n#"
},
{
"path": "src/init/Init.h",
"chars": 301,
"preview": "#ifndef __INIT_H_\n#define __INIT_H_\n\n#include \"src/thread/Mutex.h\"\n\nnamespace nacos{\nclass Init {\nprivate:\n static bo"
},
{
"path": "src/json/JSON.cpp",
"chars": 15113,
"preview": "#include \"src/json/JSON.h\"\n#include \"src/naming/beat/BeatInfo.h\"\n#include \"NacosString.h\"\n\n/**\n * JSON\n *\n * @author Liu"
},
{
"path": "src/json/JSON.h",
"chars": 2234,
"preview": "#ifndef __JSON_H_\n#define __JSON_H_\n\n#include <map>\n#include \"NacosString.h\"\n#include \"src/naming/beat/BeatInfo.h\"\n#incl"
},
{
"path": "src/json/rapidjson/allocators.h",
"chars": 10675,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/cursorstreamwrapper.h",
"chars": 2281,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A"
},
{
"path": "src/json/rapidjson/document.h",
"chars": 118108,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/encodedstream.h",
"chars": 10681,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/encodings.h",
"chars": 29281,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/error/en.h",
"chars": 3870,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/error/error.h",
"chars": 6229,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/filereadstream.h",
"chars": 3001,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/filewritestream.h",
"chars": 3146,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/fwd.h",
"chars": 4035,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/biginteger.h",
"chars": 9150,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/diyfp.h",
"chars": 12004,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A"
},
{
"path": "src/json/rapidjson/internal/dtoa.h",
"chars": 8125,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/ieee754.h",
"chars": 3010,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/itoa.h",
"chars": 10147,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A"
},
{
"path": "src/json/rapidjson/internal/meta.h",
"chars": 6657,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/pow10.h",
"chars": 3611,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/regex.h",
"chars": 26122,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/stack.h",
"chars": 7200,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/strfunc.h",
"chars": 2215,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/strtod.h",
"chars": 8994,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/internal/swap.h",
"chars": 1435,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A"
},
{
"path": "src/json/rapidjson/istreamwrapper.h",
"chars": 4082,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/memorybuffer.h",
"chars": 2579,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/memorystream.h",
"chars": 2667,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/msinttypes/inttypes.h",
"chars": 8372,
"preview": "// ISO C9x compliant inttypes.h for Microsoft Visual Studio\n// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) "
},
{
"path": "src/json/rapidjson/msinttypes/stdint.h",
"chars": 9386,
"preview": "// ISO C9x compliant stdint.h for Microsoft Visual Studio\n// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG"
},
{
"path": "src/json/rapidjson/ostreamwrapper.h",
"chars": 2331,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/pointer.h",
"chars": 60793,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/prettywriter.h",
"chars": 10507,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/rapidjson.h",
"chars": 23185,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/reader.h",
"chars": 93232,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A"
},
{
"path": "src/json/rapidjson/schema.h",
"chars": 103713,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available->\n// \n// Copyright (C) 2015 THL"
},
{
"path": "src/json/rapidjson/stream.h",
"chars": 6753,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n//\n// Copyright (C) 2015 THL A"
},
{
"path": "src/json/rapidjson/stringbuffer.h",
"chars": 4031,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/json/rapidjson/writer.h",
"chars": 26981,
"preview": "// Tencent is pleased to support the open source community by making RapidJSON available.\n// \n// Copyright (C) 2015 THL "
},
{
"path": "src/listen/ClientWorker.cpp",
"chars": 19751,
"preview": "#include <vector>\n#include \"ClientWorker.h\"\n#include \"listen/Listener.h\"\n#include \"src/utils/url.h\"\n#include \"src/utils/"
},
{
"path": "src/listen/ClientWorker.h",
"chars": 2991,
"preview": "#ifndef __CLIENT_WORKER_H_\n#define __CLIENT_WORKER_H_\n\n#include <map>\n#include <vector>\n#include <pthread.h>\n#include \"N"
},
{
"path": "src/listen/ListeningData.h",
"chars": 3430,
"preview": "#ifndef __LISTENINGDATA_H_\n#define __LISTENINGDATA_H_\n\n#include <map>\n#include <list>\n#include \"NacosString.h\"\n#include "
},
{
"path": "src/listen/OperateItem.h",
"chars": 1121,
"preview": "#ifndef __OPERATE_ITM_H_\n#define __OPERATE_ITM_H_\n\n#include \"NacosString.h\"\n#include \"listen/Listener.h\"\n\n/**\n * Listeni"
},
{
"path": "src/log/Logger.cpp",
"chars": 7927,
"preview": "#include <stdio.h>\n#include <unistd.h>\n#include <sys/types.h>\n#include <stdlib.h>\n#include \"Logger.h\"\n#include \"src/util"
},
{
"path": "src/log/Logger.h",
"chars": 2971,
"preview": "#ifndef __LOGGER_H_\n#define __LOGGER_H_\n\n#include <cstdarg>\n#include <stdint.h>\n#include \"NacosString.h\"\n#include \"src/t"
},
{
"path": "src/naming/Cluster.cpp",
"chars": 605,
"preview": "#include \"naming/Cluster.h\"\n\nnamespace nacos{\n\nNacosString Cluster::getName() const {\n return name;\n}\n\nvoid Cluster::"
},
{
"path": "src/naming/Instance.cpp",
"chars": 1844,
"preview": "#include \"naming/Instance.h\"\r\n#include \"src/utils/ParamUtils.h\"\r\n#include \"src/log/Logger.h\"\r\n\r\nnamespace nacos{\r\nInstan"
},
{
"path": "src/naming/NacosNamingMaintainService.cpp",
"chars": 2078,
"preview": "#include \"src/naming/NacosNamingMaintainService.h\"\n#include \"src/security/SecurityManager.h\"\n#include \"constant/ConfigCo"
},
{
"path": "src/naming/NacosNamingMaintainService.h",
"chars": 1404,
"preview": "#ifndef __NACOS_NAM_MTN_SVC_H_\n#define __NACOS_NAM_MTN_SVC_H_\n\n#include \"naming/NamingMaintainService.h\"\n#include \"namin"
},
{
"path": "src/naming/NacosNamingService.cpp",
"chars": 13043,
"preview": "#include \"src/naming/NacosNamingService.h\"\r\n#include \"src/naming/subscribe/SubscriptionPoller.h\"\r\n#include \"src/naming/s"
},
{
"path": "src/naming/NacosNamingService.h",
"chars": 6183,
"preview": "#ifndef __NACOS_NAM_SVC_H_\n#define __NACOS_NAM_SVC_H_\n\n#include \"naming/NamingService.h\"\n#include \"naming/Instance.h\"\n#i"
},
{
"path": "src/naming/NamingProxy.cpp",
"chars": 22214,
"preview": "#include <map>\r\n#include \"NamingProxy.h\"\r\n#include \"constant/NamingConstant.h\"\r\n#include \"constant/UtilAndComs.h\"\r\n#incl"
},
{
"path": "src/naming/NamingProxy.h",
"chars": 2990,
"preview": "#ifndef __NAMING_PROXY_H_\n#define __NAMING_PROXY_H_\n\n#include <map>\n#include <list>\n#include \"NacosString.h\"\n#include \"N"
},
{
"path": "src/naming/ServiceInfo.cpp",
"chars": 4856,
"preview": "#include \"naming/ServiceInfo.h\"\n#include <vector>\n#include <list>\n#include <sys/time.h>\n#include \"NacosString.h\"\n#includ"
},
{
"path": "src/naming/beat/BeatInfo.cpp",
"chars": 193,
"preview": "#include \"src/json/JSON.h\"\r\n#include \"BeatInfo.h\"\r\n#include \"NacosString.h\"\r\n\r\nnamespace nacos{\r\nNacosString BeatInfo::t"
},
{
"path": "src/naming/beat/BeatInfo.h",
"chars": 1049,
"preview": "#ifndef __BEAT_INFO_H_\n#define __BEAT_INFO_H_\n\n#include <map>\n#include \"NacosString.h\"\n\n/*\n * Copyright 1999-2018 Alibab"
},
{
"path": "src/naming/beat/BeatReactor.cpp",
"chars": 5313,
"preview": "#include <map>\r\n#include \"BeatReactor.h\"\r\n#include \"BeatTask.h\"\r\n#include \"NacosString.h\"\r\n#include \"src/debug/DebugAsse"
},
{
"path": "src/naming/beat/BeatReactor.h",
"chars": 2586,
"preview": "#ifndef __BEAT_REACTOR_H_\n#define __BEAT_REACTOR_H_\n\n#include <map>\n#include \"src/naming/NamingProxy.h\"\n#include \"naming"
},
{
"path": "src/naming/beat/BeatTask.cpp",
"chars": 922,
"preview": "#include <map>\r\n#include \"BeatReactor.h\"\r\n#include \"NacosString.h\"\r\n\r\nusing namespace std;\r\n\r\nnamespace nacos{\r\nBeatTask"
},
{
"path": "src/naming/beat/BeatTask.h",
"chars": 991,
"preview": "#ifndef __BEAT_TASK_H_\n#define __BEAT_TASK_H_\n\n#include \"BeatInfo.h\"\n#include \"src/naming/NamingProxy.h\"\n#include \"BeatR"
},
{
"path": "src/naming/cache/ChangeAdvice.cpp",
"chars": 2050,
"preview": "#include \"naming/ChangeAdvice.h\"\n\nusing namespace std;\n\nnamespace nacos{\nChangeAdvice::ChangeAdvice()\n{\n added = fals"
},
{
"path": "src/naming/cache/NamingCache.cpp",
"chars": 1372,
"preview": "#include \"NamingCache.h\"\n\nnamespace nacos{\nServiceInfo NamingCache::getServiceInfo(const NacosString &key) NACOS_THROW(N"
},
{
"path": "src/naming/cache/NamingCache.h",
"chars": 852,
"preview": "#ifndef __NAMING_CACHE_H_\n#define __NAMING_CACHE_H_\n\n#include <map>\n#include \"NacosString.h\"\n#include \"src/naming/subscr"
},
{
"path": "src/naming/selectors/HealthInstanceSelector.cpp",
"chars": 554,
"preview": "#include <list>\n#include \"naming/selectors/HealthInstanceSelector.h\"\n\nnamespace nacos { namespace naming { namespace sel"
},
{
"path": "src/naming/selectors/RandomByWeightSelector.cpp",
"chars": 1682,
"preview": "#include <list>\n#include <vector>\n#include \"naming/selectors/RandomByWeightSelector.h\"\n#include \"src/log/Logger.h\"\n#incl"
},
{
"path": "src/naming/selectors/RandomSelector.cpp",
"chars": 816,
"preview": "#include \"naming/selectors/RandomSelector.h\"\n#include \"src/log/Logger.h\"\n#include \"src/utils/RandomUtils.h\"\n#include \"sr"
},
{
"path": "src/naming/subscribe/EventDispatcher.cpp",
"chars": 7562,
"preview": "//\n// Created by liuhanyu on 2020/9/25.\n//\n\n#include \"EventDispatcher.h\"\n#include \"src/debug/DebugAssertion.h\"\n\nusing na"
},
{
"path": "src/naming/subscribe/EventDispatcher.h",
"chars": 1493,
"preview": "#ifndef __EVT_DISPTCH_H_\n#define __EVT_DISPTCH_H_\n\n#include \"src/thread/Thread.h\"\n#include \"src/thread/RWLock.h\"\n#includ"
},
{
"path": "src/naming/subscribe/EventListener.cpp",
"chars": 190,
"preview": "#include \"naming/subscribe/EventListener.h\"\n#include \"src/debug/DebugAssertion.h\"\n\nnamespace nacos {\n\nEventListener::~Ev"
},
{
"path": "src/naming/subscribe/HostReactor.cpp",
"chars": 2176,
"preview": "//\n// Created by liuhanyu on 2021/1/7.\n//\n\n#include \"HostReactor.h\"\n#include \"src/json/JSON.h\"\n#include \"src/utils/Namin"
},
{
"path": "src/naming/subscribe/HostReactor.h",
"chars": 635,
"preview": "//\n// Created by liuhanyu on 2021/1/7.\n//\n\n#ifndef NACOS_SDK_CPP_HOSTREACTOR_H\n#define NACOS_SDK_CPP_HOSTREACTOR_H\n#incl"
},
{
"path": "src/naming/subscribe/SubscriptionPoller.cpp",
"chars": 5057,
"preview": "#include \"SubscriptionPoller.h\"\n#include \"constant/ConfigConstant.h\"\n#include \"src/utils/NamingUtils.h\"\n#include \"src/js"
},
{
"path": "src/naming/subscribe/SubscriptionPoller.h",
"chars": 1242,
"preview": "//\n// Created by liuhanyu on 2020/9/26.\n//\n\n#ifndef NACOS_SDK_CPP_SUBSCRIPTIONPOLLER_H\n#define NACOS_SDK_CPP_SUBSCRIPTIO"
},
{
"path": "src/naming/subscribe/UdpNamingServiceListener.cpp",
"chars": 6658,
"preview": "#include <errno.h>\n#include <string.h>\n#include <unistd.h>\n\n#include \"UdpNamingServiceListener.h\"\n#include \"src/config/A"
},
{
"path": "src/naming/subscribe/UdpNamingServiceListener.h",
"chars": 1138,
"preview": "//\n// Created by liuhanyu on 2020/9/26.\n//\n\n#ifndef NACOS_SDK_CPP_UDPLSNR_H_\n#define NACOS_SDK_CPP_UDPLSNR_H_\n\n#include "
},
{
"path": "src/security/SecurityManager.cpp",
"chars": 6691,
"preview": "//\n// Created by liuhanyu on 2020/11/28.\n//\n\n#include \"SecurityManager.h\"\n#include \"src/json/JSON.h\"\n#include \"src/utils"
},
{
"path": "src/security/SecurityManager.h",
"chars": 1284,
"preview": "//\n// Created by liuhanyu on 2020/11/28.\n//\n\n#ifndef NACOS_SDK_CPP_SECURITYMANAGER_H\n#define NACOS_SDK_CPP_SECURITYMANAG"
},
{
"path": "src/server/NacosServerInfo.h",
"chars": 2763,
"preview": "//\n// Created by Liu, Hanyu on 2020/9/4.\n//\n\n#ifndef NACOS_SDK_CPP_NACOSSERVERINFO_H\n#define NACOS_SDK_CPP_NACOSSERVERIN"
},
{
"path": "src/server/ServerListManager.cpp",
"chars": 12860,
"preview": "#include <stdlib.h>\n#include <unistd.h>\n#include \"ServerListManager.h\"\n#include \"constant/PropertyKeyConst.h\"\n#include \""
},
{
"path": "src/server/ServerListManager.h",
"chars": 3109,
"preview": "#ifndef __SERVER_LIST_MGR_H_\n#define __SERVER_LIST_MGR_H_\n\n#include <list>\n#include \"NacosString.h\"\n#include \"Properties"
},
{
"path": "src/thread/BlockingQueue.h",
"chars": 1351,
"preview": "#ifndef __BLOCKING_Q_H_\n#define __BLOCKING_Q_H_\n\n#include <deque>\n#include \"src/thread/Mutex.h\"\n/*\n* BlockingQueue.h\n* T"
},
{
"path": "src/thread/DelayedThreadPool.cpp",
"chars": 5855,
"preview": "#include <algorithm>\n#include \"src/thread/DelayedThreadPool.h\"\n#include \"NacosExceptions.h\"\n\nnamespace nacos {\n\n/**\n* A "
},
{
"path": "src/thread/DelayedThreadPool.h",
"chars": 941,
"preview": "#ifndef __DELAYED_THREAD_POOL_H_\n#define __DELAYED_THREAD_POOL_H_\n\n#include <vector>\n#include <utility>\n#include \"src/th"
},
{
"path": "src/thread/Mutex.h",
"chars": 2102,
"preview": "#ifndef __MUTEX_H_\n#define __MUTEX_H_\n\n#include<iostream>\n#include <pthread.h>\n#include \"Tid.h\"\n#include \"src/utils/Time"
},
{
"path": "src/thread/RWLock.h",
"chars": 989,
"preview": "#ifndef __RWLOCK_H_\n#define __RWLOCK_H_\n\n#include <pthread.h>\n#include <unistd.h>\n\n/*\n* Mutex.h\n* Author: Liu, Hanyu\n* A"
},
{
"path": "src/thread/Task.h",
"chars": 366,
"preview": "#ifndef __TASK_H_\n#define __TASK_H_\n\n#include \"NacosString.h\"\n\nnamespace nacos{\nclass Task {\nprivate:\n NacosString _t"
},
{
"path": "src/thread/Thread.cpp",
"chars": 1613,
"preview": "#include \"Thread.h\"\n\nusing namespace nacos;\n\nstruct sigaction Thread::old_action;\n\nvoid Thread::Init() {\n struct siga"
},
{
"path": "src/thread/Thread.h",
"chars": 1647,
"preview": "#ifndef __THREAD_H_\n#define __THREAD_H_\n\n#include <exception>\n#include <stdlib.h>\n#include <signal.h>\n#include <sys/type"
},
{
"path": "src/thread/ThreadLocal.h",
"chars": 2326,
"preview": "#ifndef __THREAD_LOCAL_H_\n#define __THREAD_LOCAL_H_\n\n#include <pthread.h>\n\nnamespace nacos{\ntemplate <typename T>\nclass "
},
{
"path": "src/thread/ThreadPool.cpp",
"chars": 2937,
"preview": "#include <exception>\r\n#include \"ThreadPool.h\"\r\n#include \"Task.h\"\r\n\r\nusing namespace std;\r\n\r\nnamespace nacos{\r\nDummyTask "
},
{
"path": "src/thread/ThreadPool.h",
"chars": 1255,
"preview": "#ifndef __THREAD_POOL_H_\n#define __THREAD_POOL_H_\n\n#include <list>\n#include <deque>\n#include \"Thread.h\"\n#include \"Task.h"
},
{
"path": "src/thread/Tid.cpp",
"chars": 450,
"preview": "#include \"src/thread/Tid.h\"\n\n#if defined(__CYGWIN__) || defined(MS_WINDOWS)\n//TODO:for windows/cygwin\n\n#elif defined(lin"
},
{
"path": "src/thread/Tid.h",
"chars": 749,
"preview": "#ifndef __TID_HELPER_H_\n#define __TID_HELPER_H_\n#if defined(__CYGWIN__) || defined(MS_WINDOWS)\n//TODO:for windows/cygwin"
},
{
"path": "src/utils/ConfigParserUtils.cpp",
"chars": 1698,
"preview": "//\n// Created by liuhanyu on 2021/1/9.\n//\n\n#include <vector>\n#include \"ConfigParserUtils.h\"\n#include \"src/config/IOUtils"
},
{
"path": "src/utils/ConfigParserUtils.h",
"chars": 404,
"preview": "//\n// Created by liuhanyu on 2021/1/9.\n//\n\n#ifndef NACOS_SDK_CPP_CONFIGPARSERUTILS_H\n#define NACOS_SDK_CPP_CONFIGPARSERU"
},
{
"path": "src/utils/DirUtils.cpp",
"chars": 936,
"preview": "#include <unistd.h>\n#include <sys/types.h>\n#include <pwd.h>\n#include \"src/utils/DirUtils.h\"\n\n#if defined(__CYGWIN__) || "
},
{
"path": "src/utils/DirUtils.h",
"chars": 212,
"preview": "#ifndef __DIR_UTILS_H_\n#define __DIR_UTILS_H_\n\n#include \"NacosString.h\"\n\nnamespace nacos{\nclass DirUtils {\npublic:\n s"
},
{
"path": "src/utils/Env.h",
"chars": 155,
"preview": "#include <stdlib.h>\n\nconst char* getEnv(const char* env) {\n if (env == NULL) {\n return NULL;\n }\n char* v"
},
{
"path": "src/utils/GroupKey.h",
"chars": 3791,
"preview": "#ifndef __GROUP_KEY_H_\n#define __GROUP_KEY_H_\n\n#include \"NacosString.h\"\n#include \"src/utils/url.h\"\n\n/*\n * Copyright 1999"
},
{
"path": "src/utils/NamingUtils.h",
"chars": 1311,
"preview": "#ifndef __NAMING_UTILS_H_\n#define __NAMING_UTILS_H_\n\n#include <vector>\n#include \"NacosString.h\"\n#include \"constant/Confi"
},
{
"path": "src/utils/NetUtils.cpp",
"chars": 1824,
"preview": "#include \"NetUtils.h\"\r\n#include <arpa/inet.h>\r\n#include <sys/socket.h>\r\n#include <netdb.h>\r\n#include <errno.h>\r\n#include"
},
{
"path": "src/utils/NetUtils.h",
"chars": 385,
"preview": "#ifndef __NET_UTILS_H_\n#define __NET_UTILS_H_\n\n#include \"NacosString.h\"\n#include \"NacosExceptions.h\"\n#include \"Compatibi"
},
{
"path": "src/utils/ParamUtils.h",
"chars": 7701,
"preview": "#ifndef __PARMUTILS_H_\n#define __PARMUTILS_H_\n\n#include <map>\n#include <list>\n#include <vector>\n#include <assert.h>\n#inc"
},
{
"path": "src/utils/RandomUtils.cpp",
"chars": 1152,
"preview": "#include <unistd.h>\n#include <sys/stat.h>\n#include <fcntl.h>\n#include <stdio.h>\n#include <stdlib.h>\n#include <time.h>\n\n#"
},
{
"path": "src/utils/RandomUtils.h",
"chars": 951,
"preview": "#ifndef __RND_UTILS_H_\n#define __RND_UTILS_H_\n\n#include \"NacosExceptions.h\"\n#include \"src/thread/ThreadLocal.h\"\n#include"
},
{
"path": "src/utils/SequenceProvider.h",
"chars": 2197,
"preview": "#include <sys/stat.h>\n#include <fcntl.h>\n#include <unistd.h>\n#include <errno.h>\n#include \"NacosString.h\"\n#include \"Nacos"
},
{
"path": "src/utils/TimeUtils.cpp",
"chars": 330,
"preview": "#include <stddef.h>\n#include \"src/utils/TimeUtils.h\"\n\nnamespace nacos{\nint64_t TimeUtils::getCurrentTimeInMs() {\n str"
},
{
"path": "src/utils/TimeUtils.h",
"chars": 267,
"preview": "#ifndef __TIME_UTILS_H_\n#define __TIME_UTILS_H_\n\n#include <stdint.h>\n#include <sys/time.h>\n\nnamespace nacos{\nclass TimeU"
},
{
"path": "src/utils/UuidUtils.cpp",
"chars": 739,
"preview": "#include <unistd.h>\r\n#include <sys/stat.h>\r\n#include <fcntl.h>\r\n#include <stdio.h>\r\n\r\n#include \"src/utils/UuidUtils.h\"\r\n"
}
]
// ... and 39 more files (download for full content)
About this extraction
This page contains the full source code of the nacos-group/nacos-sdk-cpp GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 239 files (1.2 MB), approximately 314.6k tokens, and a symbol index with 1120 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.