Showing preview only (1,253K chars total). Download the full file or copy to clipboard to get everything.
Repository: alibaba/sentinel-cpp
Branch: master
Commit: 36871db9cc0c
Files: 305
Total size: 1.1 MB
Directory structure:
gitextract_c4eu14oz/
├── .bazelrc
├── .clang-format
├── .github/
│ ├── ISSUE_TEMPLATE.md
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── workflows/
│ └── main.yml
├── .gitignore
├── BUILD
├── CMakeLists.txt
├── LICENSE
├── README.md
├── WORKSPACE
├── bazel/
│ ├── BUILD
│ ├── copts.bzl
│ ├── fmtlib.BUILD
│ ├── osx.tbb.BUILD
│ ├── spdlog.BUILD
│ ├── tbb.BUILD
│ └── third_party_repositories.bzl
├── cmake/
│ ├── common.cmake
│ └── third_party.cmake
├── examples/
│ ├── CMakeLists.txt
│ ├── abseil/
│ │ ├── BUILD
│ │ └── abseil_string.cc
│ ├── benchmark/
│ │ ├── BUILD
│ │ └── benchamrk_test.cc
│ ├── cache/
│ │ ├── BUILD
│ │ └── cache_test.cc
│ ├── fmt/
│ │ ├── BUILD
│ │ └── fmt_test.cc
│ ├── gtest/
│ │ ├── BUILD
│ │ └── hello_test.cc
│ ├── json/
│ │ ├── BUILD
│ │ └── nlohmann_json_example.cc
│ ├── libevent/
│ │ ├── BUILD
│ │ └── libevent_echosrv1.c
│ ├── log/
│ │ ├── BUILD
│ │ └── log_test.cc
│ ├── sentinel-cpp/
│ │ ├── BUILD
│ │ ├── basic_concurrency_limit.cc
│ │ ├── basic_param_limit.cc
│ │ ├── basic_qps_limit.cc
│ │ └── basic_system_limit.cc
│ └── tbb/
│ ├── BUILD
│ └── tbb_test.cc
├── format.sh
├── sentinel-core/
│ ├── BUILD
│ ├── circuitbreaker/
│ │ ├── BUILD
│ │ ├── circuit_breaker.cc
│ │ ├── circuit_breaker.h
│ │ ├── error_circuit_breaker.cc
│ │ ├── error_circuit_breaker.h
│ │ ├── rt_circuit_breaker.cc
│ │ ├── rt_circuit_breaker.h
│ │ ├── rule.cc
│ │ ├── rule.h
│ │ ├── rule_manager.cc
│ │ ├── rule_manager.h
│ │ ├── slot.cc
│ │ ├── slot.h
│ │ └── slot_test.cc
│ ├── common/
│ │ ├── BUILD
│ │ ├── constants.h
│ │ ├── entry.h
│ │ ├── entry_context.cc
│ │ ├── entry_context.h
│ │ ├── entry_node.h
│ │ ├── entry_result.cc
│ │ ├── entry_result.h
│ │ ├── entry_type.h
│ │ ├── global_status.cc
│ │ ├── global_status.h
│ │ ├── resource_wrapper.h
│ │ ├── rule.h
│ │ ├── string_resource_wrapper.h
│ │ ├── tracer.cc
│ │ ├── tracer.h
│ │ └── tracer_test.cc
│ ├── config/
│ │ ├── BUILD
│ │ ├── config_constants.h
│ │ ├── local_config.cc
│ │ ├── local_config.h
│ │ └── local_config_test.cc
│ ├── flow/
│ │ ├── BUILD
│ │ ├── default_traffic_shaping_calculator.cc
│ │ ├── default_traffic_shaping_calculator.h
│ │ ├── default_traffic_shaping_checker.cc
│ │ ├── default_traffic_shaping_checker.h
│ │ ├── flow_rule.cc
│ │ ├── flow_rule.h
│ │ ├── flow_rule_checker.cc
│ │ ├── flow_rule_checker.h
│ │ ├── flow_rule_constants.h
│ │ ├── flow_rule_manager.cc
│ │ ├── flow_rule_manager.h
│ │ ├── flow_slot.cc
│ │ ├── flow_slot.h
│ │ ├── flow_slot_test.cc
│ │ ├── throttling_traffic_shaping_checker.cc
│ │ ├── throttling_traffic_shaping_checker.h
│ │ ├── traffic_shaping_calculator.h
│ │ ├── traffic_shaping_checker.h
│ │ ├── traffic_shaping_controller.cc
│ │ ├── traffic_shaping_controller.h
│ │ └── traffic_shaping_controller_test.cc
│ ├── init/
│ │ ├── BUILD
│ │ ├── init_target.h
│ │ ├── init_target_registry.h
│ │ └── init_target_registry_test.cc
│ ├── log/
│ │ ├── BUILD
│ │ ├── block/
│ │ │ ├── BUILD
│ │ │ ├── block_log_task.cc
│ │ │ ├── block_log_task.h
│ │ │ └── block_log_task_test.cc
│ │ ├── log_base.cc
│ │ ├── log_base.h
│ │ ├── log_base_test.cc
│ │ ├── logger.cc
│ │ ├── logger.h
│ │ ├── logger_test.cc
│ │ └── metric/
│ │ ├── BUILD
│ │ ├── metric_log_task.cc
│ │ ├── metric_log_task.h
│ │ ├── metric_reader.cc
│ │ ├── metric_reader.h
│ │ ├── metric_reader_test.cc
│ │ ├── metric_searcher.cc
│ │ ├── metric_searcher.h
│ │ ├── metric_searcher_test.cc
│ │ ├── metric_test_utils.h
│ │ ├── metric_writer.cc
│ │ ├── metric_writer.h
│ │ └── metric_writer_test.cc
│ ├── param/
│ │ ├── BUILD
│ │ ├── param_flow_item.cc
│ │ ├── param_flow_item.h
│ │ ├── param_flow_rule.cc
│ │ ├── param_flow_rule.h
│ │ ├── param_flow_rule_checker.cc
│ │ ├── param_flow_rule_checker.h
│ │ ├── param_flow_rule_constants.h
│ │ ├── param_flow_rule_manager.cc
│ │ ├── param_flow_rule_manager.h
│ │ ├── param_flow_slot.cc
│ │ ├── param_flow_slot.h
│ │ ├── param_flow_slot_test.cc
│ │ └── statistic/
│ │ ├── BUILD
│ │ ├── any_cmp.cc
│ │ ├── any_cmp.h
│ │ ├── any_cmp_test.cc
│ │ ├── lru_cache.h
│ │ ├── param_bucket.cc
│ │ ├── param_bucket.h
│ │ ├── param_event.h
│ │ ├── param_leap_array.cc
│ │ ├── param_leap_array.h
│ │ ├── param_leap_array_key.h
│ │ ├── param_metric.cc
│ │ ├── param_metric.h
│ │ ├── param_metric_test.cc
│ │ └── scalable_cache.h
│ ├── property/
│ │ ├── BUILD
│ │ ├── dynamic_sentinel_property.h
│ │ ├── dynamic_sentinel_property_test.cc
│ │ ├── property_listener.h
│ │ └── sentinel_property.h
│ ├── public/
│ │ ├── BUILD
│ │ ├── sph_u.h
│ │ └── sph_u_test.cc
│ ├── slot/
│ │ ├── BUILD
│ │ ├── base/
│ │ │ ├── BUILD
│ │ │ ├── default_slot_chain_impl.cc
│ │ │ ├── default_slot_chain_impl.h
│ │ │ ├── default_slot_chain_impl_test.cc
│ │ │ ├── rule_checker_slot.h
│ │ │ ├── slot.h
│ │ │ ├── slot_base.h
│ │ │ ├── slot_chain.h
│ │ │ ├── stats_slot.h
│ │ │ ├── token_result.cc
│ │ │ └── token_result.h
│ │ ├── global_slot_chain.cc
│ │ ├── global_slot_chain.h
│ │ ├── log_slot.cc
│ │ ├── log_slot.h
│ │ ├── resource_node_builder_slot.cc
│ │ ├── resource_node_builder_slot.h
│ │ ├── resource_node_builder_slot_test.cc
│ │ ├── statistic_slot.cc
│ │ ├── statistic_slot.h
│ │ └── statistic_slot_test.cc
│ ├── statistic/
│ │ ├── base/
│ │ │ ├── BUILD
│ │ │ ├── bucket_leap_array.cc
│ │ │ ├── bucket_leap_array.h
│ │ │ ├── bucket_leap_array_test.cc
│ │ │ ├── leap_array.h
│ │ │ ├── metric.h
│ │ │ ├── metric_bucket.cc
│ │ │ ├── metric_bucket.h
│ │ │ ├── metric_event.h
│ │ │ ├── metric_item.cc
│ │ │ ├── metric_item.h
│ │ │ ├── metric_item_test.cc
│ │ │ ├── sliding_window_metric.cc
│ │ │ ├── sliding_window_metric.h
│ │ │ ├── sliding_window_metric_test.cc
│ │ │ ├── stat_config.h
│ │ │ ├── stat_config_manager.cc
│ │ │ ├── stat_config_manager.h
│ │ │ └── window_wrap.h
│ │ └── node/
│ │ ├── BUILD
│ │ ├── cluster_node.cc
│ │ ├── cluster_node.h
│ │ ├── node.h
│ │ ├── resource_node_storage.cc
│ │ ├── resource_node_storage.h
│ │ ├── statistic_node.cc
│ │ └── statistic_node.h
│ ├── system/
│ │ ├── BUILD
│ │ ├── system_rule.cc
│ │ ├── system_rule.h
│ │ ├── system_rule_manager.cc
│ │ ├── system_rule_manager.h
│ │ ├── system_slot.cc
│ │ ├── system_slot.h
│ │ ├── system_slot_mock.h
│ │ ├── system_slot_test.cc
│ │ ├── system_status_listener.cc
│ │ ├── system_status_listener.h
│ │ └── system_status_listener_test.cc
│ ├── test/
│ │ └── mock/
│ │ ├── common/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ ├── flow/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ ├── init/
│ │ │ ├── BUILD
│ │ │ └── mock.h
│ │ ├── property/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ ├── slot/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ └── statistic/
│ │ ├── base/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ └── node/
│ │ ├── BUILD
│ │ ├── mock.cc
│ │ └── mock.h
│ ├── transport/
│ │ ├── BUILD
│ │ ├── command/
│ │ │ ├── BUILD
│ │ │ ├── command_handler.h
│ │ │ ├── command_request.cc
│ │ │ ├── command_request.h
│ │ │ ├── command_request_test.cc
│ │ │ ├── command_response.h
│ │ │ ├── handler/
│ │ │ │ ├── BUILD
│ │ │ │ ├── fetch_cluster_node_handler.cc
│ │ │ │ ├── fetch_cluster_node_handler.h
│ │ │ │ ├── fetch_cluster_node_handler_test.cc
│ │ │ │ ├── fetch_metric_log_handler.cc
│ │ │ │ ├── fetch_metric_log_handler.h
│ │ │ │ ├── get_switch_status_handler.cc
│ │ │ │ ├── get_switch_status_handler.h
│ │ │ │ ├── set_switch_status_handler.cc
│ │ │ │ ├── set_switch_status_handler.h
│ │ │ │ ├── set_switch_status_handler_test.cc
│ │ │ │ ├── version_handler.cc
│ │ │ │ ├── version_handler.h
│ │ │ │ └── vo/
│ │ │ │ ├── BUILD
│ │ │ │ ├── statistic_node_vo.cc
│ │ │ │ └── statistic_node_vo.h
│ │ │ ├── http_command_center.cc
│ │ │ ├── http_command_center.h
│ │ │ ├── http_command_utils.cc
│ │ │ ├── http_command_utils.h
│ │ │ ├── http_server.cc
│ │ │ ├── http_server.h
│ │ │ ├── http_server_init_target.cc
│ │ │ └── http_server_init_target.h
│ │ ├── common/
│ │ │ ├── BUILD
│ │ │ ├── event_loop_thread.cc
│ │ │ ├── event_loop_thread.h
│ │ │ └── event_loop_thread_test.cc
│ │ └── constants.h
│ └── utils/
│ ├── BUILD
│ ├── file_utils.cc
│ ├── file_utils.h
│ ├── macros.h
│ ├── time_utils.cc
│ ├── time_utils.h
│ ├── utils.cc
│ └── utils.h
├── sentinel-datasource-extension/
│ ├── datasource/
│ │ ├── BUILD
│ │ ├── abstract_readable_data_source.h
│ │ ├── abstract_readable_data_source_unittests.cc
│ │ ├── converter.h
│ │ └── readable_data_source.h
│ └── test/
│ └── mock/
│ └── datasource/
│ ├── BUILD
│ ├── mock.cc
│ └── mock.h
├── tests/
│ ├── BUILD
│ └── tsan-flow.cc
└── third_party/
└── nlohmann/
├── BUILD
└── json.hpp
================================================
FILE CONTENTS
================================================
================================================
FILE: .bazelrc
================================================
# Clang TSAN
build:clang-tsan --copt -fsanitize=thread
build:clang-tsan --linkopt -fsanitize=thread
================================================
FILE: .clang-format
================================================
# Use the Google style in this project.
BasedOnStyle: Google
================================================
FILE: .github/ISSUE_TEMPLATE.md
================================================
<!-- Here is for bug reports and feature requests ONLY!
If you're looking for help, please check our mail list and the Gitter room.
Please try to use English to describe your issue, or at least provide a snippet of English translation.
-->
## Issue Description
Type: *bug report* or *feature request*
### Describe what happened (or what feature you want)
### Describe what you expected to happen
### How to reproduce it (as minimally and precisely as possible)
1.
2.
3.
### Tell us your environment
### Anything else we need to know?
================================================
FILE: .github/PULL_REQUEST_TEMPLATE.md
================================================
<!-- Thanks for submitting a pull request! Here are some tips for you:
1. Please make sure you have read and understood the contributing guidelines: https://github.com/alibaba/Sentinel/blob/master/CONTRIBUTING.md
2. Please make sure the PR has a corresponding issue.
-->
### Describe what this PR does / why we need it
### Does this pull request fix one issue?
<!--If that, add "Fixes #xxxx" below in the next line. For example, Fixes #15. Otherwise, add "NONE" -->
### Describe how you did it
### Describe how to verify it
### Special notes for reviews
================================================
FILE: .github/workflows/main.yml
================================================
name: CI
on:
push:
branches: master
pull_request:
branches: "*"
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
java: [8]
os: [ubuntu-18.04]
steps:
- uses: actions/checkout@v2
- name: Install bazel
run: |
wget https://github.com/bazelbuild/bazel/releases/download/3.7.0/bazel_3.7.0-linux-x86_64.deb
sudo dpkg -i bazel_3.7.0-linux-x86_64.deb
- name: Install clang8
run: |
echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee -a /etc/apt/sources.list
echo "deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee -a /etc/apt/sources.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install clang-8 clang-format-8
- name: Clang format checker
run: |
bash format.sh
- name: Library build
run: |
bazel build //sentinel-core/... && bazel build //sentinel-datasource-extension/...
- name: Sentinel core unit tests
run: |
bazel test --test_filter=*-ParamMetricTest.TestOperateMetric --test_output=errors --strategy=TestRunner=standalone //sentinel-core/...
- name: Sentinel datasource extension tests
run: |
bazel build //sentinel-core/... && bazel build //sentinel-datasource-extension/...
- name: tsan for flow control
run: |
bazel build -c dbg --config=clang-tsan //tests/... && ./bazel-bin/tests/tsan-flow
================================================
FILE: .gitignore
================================================
/bazel-*
BROWSE
/build
/build_*
.cache
/ci/bazel-*
/ci/prebuilt/thirdparty
/ci/prebuilt/thirdparty_build
compile_commands.json
cscope.*
.deps
/docs/landing_source/.bundle
/generated
*.pyc
**/pyformat
SOURCE_VERSION
*.sw*
tags
TAGS
/test/coverage/BUILD
/tools/.aspell.en.pws
.vimrc
.vs
.vscode
.DS_Store
.gdb_history
================================================
FILE: BUILD
================================================
load("@rules_foreign_cc//tools/build_defs:configure.bzl", "configure_make")
# load("@rules_foreign_cc//tools/build_defs:make.bzl", "make")
configure_make(
name = "libevent",
visibility = ["//visibility:public"],
configure_options = [
"--enable-shared=no",
"--disable-libevent-regress",
"--disable-openssl",
],
lib_source = "@com_github_libevent//:all",
out_lib_dir = "lib",
)
# make(
# name = "com_github_libtbb",
# visibility = ["//visibility:public"],
# out_lib_dir = "lib",
# lib_source = "@com_github_libtbb//:all",
# )
================================================
FILE: CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.14)
project(sentinel-cpp VERSION 1.0.1 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 14)
set(SENTINEL_ROOT_DIR "${CMAKE_SOURCE_DIR}")
set(SENTINEL_CORE_ROOT_DIR "${CMAKE_SOURCE_DIR}/sentinel-core")
include( cmake/common.cmake )
================================================
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://user-images.githubusercontent.com/9434884/43697219-3cb4ef3a-9975-11e8-9a9c-73f4f537442d.png" alt="Sentinel Logo" width="50%">
[](https://travis-ci.org/alibaba/sentinel-cpp)
[](https://www.apache.org/licenses/LICENSE-2.0.html)
[](https://gitter.im/alibaba/Sentinel)
# Sentinel: The Sentinel of Your Microservices
## Build
1. Install the latest version of [Bazel](https://bazel.build/versions/master/docs/install.html) in your environment.
2. Build the project.
```sh
bazel build -c opt //...
```
3. Run the [QPS limiting demo](https://github.com/alibaba/sentinel-cpp/blob/master/examples/sentinel-cpp/basic_qps_limit.cc):
```sh
CSP_SENTINEL_APP_NAME=my-demo ./bazel-bin/examples/sentinel-cpp/sentinel_basic_qps_limit
```
================================================
FILE: WORKSPACE
================================================
# Copyright 2019 Alibaba Inc. All rights reserved
#
# 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.
workspace(name = "com_alibaba_sentinel")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Rule repository
http_archive(
name = "rules_foreign_cc",
strip_prefix = "rules_foreign_cc-master",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/master.zip",
)
load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
rules_foreign_cc_dependencies()
# abseil-cpp
http_archive(
name = "com_google_absl",
urls = ["https://github.com/abseil/abseil-cpp/archive/61c9bf3e3e1c28a4aa6d7f1be4b37fd473bb5529.tar.gz"], # 2019-06-05
strip_prefix = "abseil-cpp-61c9bf3e3e1c28a4aa6d7f1be4b37fd473bb5529",
sha256 = "7ddf863ddced6fa5bf7304103f9c7aa619c20a2fcf84475512c8d3834b9d14fa",
)
# Google Test
http_archive(
name = "com_google_googletest",
urls = ["https://github.com/google/googletest/archive/8b6d3f9c4a774bef3081195d422993323b6bb2e0.zip"], # 2019-03-05
strip_prefix = "googletest-8b6d3f9c4a774bef3081195d422993323b6bb2e0",
sha256 = "d21ba93d7f193a9a0ab80b96e8890d520b25704a6fac976fe9da81fffb3392e3",
)
# Google Benchmark
http_archive(
name = "com_google_benchmark",
urls = ["https://github.com/google/benchmark/archive/505be96ab23056580a3a2315abba048f4428b04e.tar.gz"],
strip_prefix = "benchmark-505be96ab23056580a3a2315abba048f4428b04e",
sha256 = "0de43b6eaddd356f1d6cd164f73f37faf2f6c96fd684e1f7ea543ce49c1d144e",
)
load("//bazel:third_party_repositories.bzl", "include_third_party_repositories")
include_third_party_repositories()
================================================
FILE: bazel/BUILD
================================================
licenses(["notice"]) # Apache 2.0
package(default_visibility = ["//visibility:public"])
config_setting(
name = "llvm_compiler",
values = {
"compiler": "llvm",
},
)
config_setting(
name = "windows",
values = {
"cpu": "x64_windows",
},
)
config_setting(
name = "is_osx",
define_values = {"os":"osx"},
)
================================================
FILE: bazel/copts.bzl
================================================
"""
Flags specified here must not impact ABI. Code compiled with and without these
opts will be linked together, and in some cases headers compiled with and
without these options will be part of the same program.
We use the same flags as absl.
"""
load(
"@com_google_absl//absl:copts/GENERATED_copts.bzl",
"ABSL_GCC_EXCEPTIONS_FLAGS",
"ABSL_GCC_FLAGS",
"ABSL_GCC_TEST_FLAGS",
"ABSL_LLVM_EXCEPTIONS_FLAGS",
"ABSL_LLVM_FLAGS",
"ABSL_LLVM_TEST_FLAGS",
"ABSL_MSVC_EXCEPTIONS_FLAGS",
"ABSL_MSVC_FLAGS",
"ABSL_MSVC_LINKOPTS",
"ABSL_MSVC_TEST_FLAGS",
)
WERROR = ["-Werror=return-type", "-Werror=switch"]
DEFAULT_COPTS = select({
"//bazel:windows": ABSL_MSVC_FLAGS,
"//bazel:llvm_compiler": ABSL_LLVM_FLAGS,
"//conditions:default": ABSL_GCC_FLAGS + WERROR + ["-std=c++14"],
})
TEST_COPTS = DEFAULT_COPTS + select({
"//bazel:windows": ABSL_MSVC_TEST_FLAGS,
"//bazel:llvm_compiler": ABSL_LLVM_TEST_FLAGS,
"//conditions:default": ABSL_GCC_TEST_FLAGS + WERROR + ["-std=c++14"],
})
================================================
FILE: bazel/fmtlib.BUILD
================================================
licenses(["notice"]) # Apache 2
cc_library(
name = "fmtlib",
srcs = glob([
"fmt/*.cc",
]),
hdrs = glob([
"include/fmt/*.h",
]),
defines = ["FMT_HEADER_ONLY"],
includes = ["include"],
visibility = ["//visibility:public"],
)
================================================
FILE: bazel/osx.tbb.BUILD
================================================
licenses(["notice"]) # Apache 2
package(default_visibility = ["//visibility:public"])
genrule(
name = "build_tbb_osx",
srcs = glob(["**"]) + [
"@local_config_cc//:toolchain",
],
cmd = """
set -e
set -u
WORK_DIR=$$PWD
DEST_DIR=$$PWD/$(@D)
cd $$(dirname $(location :Makefile))
make
files=build/*/*.dylib;
echo cp $$files $$DEST_DIR
cp $$files $$DEST_DIR
cd $$WORK_DIR
""",
outs = [
"libtbb.dylib",
"libtbbmalloc.dylib",
"libtbbmalloc_proxy.dylib",
],
)
cc_library(
name = "tbb_osx",
hdrs = glob([
"include/serial/**",
"include/tbb/**/**",
]),
srcs = [
"libtbb.dylib",
"libtbbmalloc.dylib",
"libtbbmalloc_proxy.dylib",
],
includes = ["include"],
visibility = ["//visibility:public"],
)
================================================
FILE: bazel/spdlog.BUILD
================================================
licenses(["notice"]) # Apache 2
cc_library(
name = "spdlog",
hdrs = glob([
"include/**/*.cc",
"include/**/*.h",
]),
defines = ["SPDLOG_FMT_EXTERNAL"],
includes = ["include"],
visibility = ["//visibility:public"],
deps = ["@com_github_fmtlib_fmt//:fmtlib"],
)
================================================
FILE: bazel/tbb.BUILD
================================================
licenses(["notice"]) # Apache 2
package(default_visibility = ["//visibility:public"])
genrule(
name = "build_tbb",
srcs = glob(["**"]) + [
"@local_config_cc//:toolchain",
],
cmd = """
set -e
set -u
WORK_DIR=$$PWD
DEST_DIR=$$PWD/$(@D)
cd $$(dirname $(location :Makefile))
make
if [[ $$(echo `uname` | grep 'Dar') != "" ]]; then
files=build/*/*.dylib;
else files=build/*/*.so*;
fi
echo cp $$files $$DEST_DIR
cp $$files $$DEST_DIR
cd $$WORK_DIR
""",
outs = [
"libtbb.so",
"libtbbmalloc.so",
"libtbbmalloc_proxy.so",
"libtbb.so.2",
"libtbbmalloc.so.2",
"libtbbmalloc_proxy.so.2",
],
)
cc_library(
name = "tbb",
hdrs = glob([
"include/serial/**",
"include/tbb/**/**",
]),
srcs = [
"libtbb.so",
"libtbbmalloc.so",
"libtbbmalloc_proxy.so",
"libtbb.so.2",
"libtbbmalloc.so.2",
"libtbbmalloc_proxy.so.2",
],
includes = ["include"],
visibility = ["//visibility:public"],
)
================================================
FILE: bazel/third_party_repositories.bzl
================================================
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive", "http_file")
all_content = """filegroup(name = "all", srcs = glob(["**"]), visibility = ["//visibility:public"])"""
def include_third_party_repositories():
http_archive(
name = "com_github_libevent",
build_file_content = all_content,
strip_prefix = "libevent-2.1.8-stable",
urls = ["https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz"],
)
http_archive(
name = "com_github_libtbb",
build_file = "//bazel:tbb.BUILD",
strip_prefix = "oneTBB-2020.3",
urls = ["https://github.com/oneapi-src/oneTBB/archive/v2020.3.tar.gz"],
sha256 = "ebc4f6aa47972daed1f7bf71d100ae5bf6931c2e3144cf299c8cc7d041dca2f3",
)
http_archive(
name = "com_github_libtbb_osx",
build_file = "//bazel:osx.tbb.BUILD",
strip_prefix = "oneTBB-2020.3",
urls = ["https://github.com/oneapi-src/oneTBB/archive/v2020.3.tar.gz"],
sha256 = "ebc4f6aa47972daed1f7bf71d100ae5bf6931c2e3144cf299c8cc7d041dca2f3",
)
http_archive(
name = "com_github_fmtlib_fmt",
sha256 = "4c0741e10183f75d7d6f730b8708a99b329b2f942dad5a9da3385ab92bb4a15c",
strip_prefix = "fmt-5.3.0",
urls = ["https://github.com/fmtlib/fmt/releases/download/5.3.0/fmt-5.3.0.zip"],
build_file = "//bazel:fmtlib.BUILD",
)
http_archive(
name = "com_github_gabime_spdlog",
build_file = "//bazel:spdlog.BUILD",
sha256 = "160845266e94db1d4922ef755637f6901266731c4cb3b30b45bf41efa0e6ab70",
strip_prefix = "spdlog-1.3.1",
urls = ["https://github.com/gabime/spdlog/archive/v1.3.1.tar.gz"],
)
================================================
FILE: cmake/common.cmake
================================================
cmake_minimum_required( VERSION 3.14 )
find_package(Libevent REQUIRED)
include_directories(${LIBEVENT_INCLUDE_DIR})
include( ${SENTINEL_ROOT_DIR}/cmake/third_party.cmake )
include_directories( ${SENTINEL_ROOT_DIR} )
include_directories(${SENTINEL_CORE_ROOT_DIR}/common)
include_directories(${SENTINEL_CORE_ROOT_DIR}/config)
include_directories(${SENTINEL_CORE_ROOT_DIR}/property)
include_directories(${SENTINEL_CORE_ROOT_DIR}/public)
# common
file(GLOB COMMON_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/common/*.cc")
file(GLOB COMMON_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/common/*_test.cc")
list(REMOVE_ITEM COMMON_SOURCE_FILES ${COMMON_TEST_SOURCE_FILES})
# config
file(GLOB CONFIG_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/config/*.cc")
file(GLOB CONFIG_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/config/*_test.cc")
list(REMOVE_ITEM CONFIG_SOURCE_FILES ${CONFIG_TEST_SOURCE_FILES})
# log
file(GLOB_RECURSE LOG_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/log/*.cc")
file(GLOB_RECURSE LOG_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/log/*_test.cc")
list(REMOVE_ITEM LOG_SOURCE_FILES ${LOG_TEST_SOURCE_FILES})
# utils
file(GLOB UTILS_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/utils/*.cc")
# file(GLOB UTILS_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/utils/*test.cc")
# list(REMOVE_ITEM UTILS_SOURCE_FILES ${UTILS_TEST_SOURCE_FILES})
# slot
file(GLOB_RECURSE SLOT_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/slot/*.cc")
file(GLOB_RECURSE SLOT_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/slot/*_test.cc")
list(REMOVE_ITEM SLOT_SOURCE_FILES ${SLOT_TEST_SOURCE_FILES})
# statistic
file(GLOB_RECURSE STATISTIC_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/statistic/*.cc")
file(GLOB_RECURSE STATISTIC_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/statistic/*_test.cc")
list(REMOVE_ITEM STATISTIC_SOURCE_FILES ${STATISTIC_TEST_SOURCE_FILES})
# transport
file(GLOB_RECURSE TRANSPORT_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/transport/*.cc")
file(GLOB_RECURSE TRANSPORT_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/transport/*_test.cc")
list(REMOVE_ITEM TRANSPORT_SOURCE_FILES ${TRANSPORT_TEST_SOURCE_FILES})
# flow
file(GLOB FLOW_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/flow/*.cc")
file(GLOB FLOW_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/flow/*_test.cc")
list(REMOVE_ITEM FLOW_SOURCE_FILES ${FLOW_TEST_SOURCE_FILES})
# circuitbreaker
file(GLOB CIRCUIT_BREAKER_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/circuitbreaker/*.cc")
file(GLOB CIRCUIT_BREAKER_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/circuitbreaker/*_test.cc")
list(REMOVE_ITEM CIRCUIT_BREAKER_SOURCE_FILES ${CIRCUIT_BREAKER_TEST_SOURCE_FILES})
# param
file(GLOB_RECURSE PARAM_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/param/*.cc")
file(GLOB_RECURSE PARAM_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/param/*_test.cc")
list(REMOVE_ITEM PARAM_SOURCE_FILES ${PARAM_TEST_SOURCE_FILES})
# system
file(GLOB_RECURSE SYSTEM_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/system/*.cc")
file(GLOB_RECURSE SYSTEM_TEST_SOURCE_FILES "${SENTINEL_CORE_ROOT_DIR}/system/*_test.cc")
list(REMOVE_ITEM SYSTEM_SOURCE_FILES ${SYSTEM_TEST_SOURCE_FILES})
list(APPEND
SENTINEL_SOURCE_FILES
${COMMON_SOURCE_FILES}
${CONFIG_SOURCE_FILES}
${LOG_SOURCE_FILES}
${UTILS_SOURCE_FILES}
${SLOT_SOURCE_FILES}
${STATISTIC_SOURCE_FILES}
${TRANSPORT_SOURCE_FILES}
${FLOW_SOURCE_FILES}
${CIRCUIT_BREAKER_SOURCE_FILES}
${PARAM_SOURCE_FILES}
${SYSTEM_SOURCE_FILES})
add_library(sentinel STATIC ${SENTINEL_SOURCE_FILES})
target_link_libraries(sentinel PUBLIC
libevent::core
libevent::extra
libevent::pthreads
TBB::tbb
spdlog
absl::flat_hash_set
absl::str_format
absl::synchronization
absl::strings
absl::any)
================================================
FILE: cmake/third_party.cmake
================================================
cmake_minimum_required( VERSION 3.14 )
include( FetchContent )
#######################################################################
# Declare project dependencies
#######################################################################
FetchContent_Declare( abseil
GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
GIT_TAG 20230125.0
)
FetchContent_Declare( spdlog
GIT_REPOSITORY https://github.com/gabime/spdlog.git
GIT_TAG v1.11.0
)
FetchContent_Declare( onetbb
GIT_REPOSITORY https://github.com/oneapi-src/oneTBB.git
GIT_TAG v2021.9.0
)
FetchContent_MakeAvailable(abseil)
FetchContent_MakeAvailable(spdlog)
FetchContent_MakeAvailable(onetbb)
================================================
FILE: examples/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.14)
project(sentinel-cpp VERSION 1.0.1 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 14)
set(SENTINEL_CORE_ROOT_DIR "${CMAKE_SOURCE_DIR}/../sentinel-core")
set(SENTINEL_ROOT_DIR "${CMAKE_SOURCE_DIR}/..")
include( ${CMAKE_SOURCE_DIR}/../cmake/common.cmake )
# basic_qps_limit
add_executable(basic_qps_limit ${CMAKE_SOURCE_DIR}/../examples/sentinel-cpp/basic_qps_limit.cc)
target_link_libraries(basic_qps_limit sentinel)
# basic_concurrency_limit
add_executable(basic_concurrency_limit ${CMAKE_SOURCE_DIR}/../examples/sentinel-cpp/basic_concurrency_limit.cc)
target_link_libraries(basic_concurrency_limit sentinel)
# basic_param_limit
add_executable(basic_param_limit ${CMAKE_SOURCE_DIR}/../examples/sentinel-cpp/basic_param_limit.cc)
target_link_libraries(basic_param_limit sentinel)
# basic_system_limit
add_executable(basic_system_limit ${CMAKE_SOURCE_DIR}/../examples/sentinel-cpp/basic_system_limit.cc)
target_link_libraries(basic_system_limit sentinel)
================================================
FILE: examples/abseil/BUILD
================================================
cc_binary(
name = "asbeil_string",
srcs = ["abseil_string.cc"],
deps = [
"@com_google_absl//absl/strings",
],
)
================================================
FILE: examples/abseil/abseil_string.cc
================================================
#include <iostream>
#include <string>
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
std::string Greet(absl::string_view person) {
return absl::StrCat("Hello ", person);
}
int main(int argc, char* argv[]) {
std::cout << Greet(argc < 2 ? "world" : argv[1]) << std::endl;
}
================================================
FILE: examples/benchmark/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
cc_binary(
name = "benchmark_test",
srcs = ["benchamrk_test.cc"],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/public:sph_u_lib",
"@com_google_benchmark//:benchmark",
"//sentinel-core/log/metric:metric_log_task_lib",
],
)
================================================
FILE: examples/benchmark/benchamrk_test.cc
================================================
#include <benchmark/benchmark.h>
#include <atomic>
#include <iostream>
#include <thread>
#include <unordered_map>
#include "sentinel-core/log/metric/metric_log_task.h"
#include "sentinel-core/param/param_flow_rule_constants.h"
#include "sentinel-core/param/param_flow_rule_manager.h"
#include "sentinel-core/public/sph_u.h"
static void BM_StringCreation(benchmark::State& state) {
for (auto _ : state) std::string empty_string;
}
// Register the function as a benchmark
// BENCHMARK(BM_StringCreation);
static void ParamRun(benchmark::State& state) {
std::string myResource("some_param_test");
Sentinel::Param::ParamFlowRule rule0, rule1, rule12;
rule0.set_resource(myResource);
rule0.set_metric_type(Sentinel::Param::ParamFlowMetricType::kQps);
rule0.set_threshold(10000);
rule0.set_cache_size(200);
rule0.set_interval_in_ms(1000);
rule0.set_param_idx(0);
rule1.set_resource(myResource);
rule1.set_metric_type(Sentinel::Param::ParamFlowMetricType::kQps);
rule1.set_threshold(INT_MAX);
rule1.set_param_idx(1);
rule1.set_interval_in_ms(1000);
Sentinel::Param::ParamFlowItem item0(std::string("nonexisting-str"),
Sentinel::Param::ParamItemType::kString,
100);
rule1.set_param_flow_item_list({item0});
rule12.set_resource("non-existing-resource"); // should not work
rule12.set_metric_type(Sentinel::Param::ParamFlowMetricType::kQps);
rule12.set_threshold(1);
rule12.set_param_idx(1);
rule12.set_interval_in_ms(1000);
Sentinel::Param::ParamFlowRuleManager::GetInstance().LoadRules(
{rule1, rule0, rule12});
for (auto _ : state) {
int randParam = rand() % 10;
auto r =
Sentinel::SphU::Entry(myResource.c_str(), Sentinel::EntryType::IN, 1, 0,
randParam); //, std::string("example"));
r->Exit();
}
}
static void ParamNotRun(benchmark::State& state) {
std::string myResource("some_param_test");
Sentinel::Log::Logger::InitDefaultLogger();
Sentinel::Log::MetricLogTask metric_log_task;
metric_log_task.Initialize();
for (auto _ : state) {
int randParam = rand() % 10;
auto r =
Sentinel::SphU::Entry(myResource.c_str(), Sentinel::EntryType::IN, 1);
r->Exit();
}
}
static void NoCache(benchmark::State& state) {
std::unordered_map<absl::any, int> m;
int i = 0;
for (auto _ : state) {
m.insert(std::make_pair<>(i, i + 1));
i++;
}
}
enum class ParamItemType { kInt32 = 0, kInt64, kString };
class MyAny : public absl::any {
public:
// std::atomic<ParamItemType> type_;
ParamItemType my_type_;
// MyAny(int v) : absl::any(v), type_(ParamItemType::kInt) {}
MyAny(int32_t v) : absl::any(v), my_type_(ParamItemType::kInt32) {}
MyAny(int64_t v) : absl::any(v), my_type_(ParamItemType::kInt64) {}
MyAny(std::string v) : absl::any(v), my_type_(ParamItemType::kString) {}
ParamItemType my_type() const noexcept { return my_type_; }
operator int32_t() {
assert(my_type_ == ParamItemType::kInt32);
return absl::any_cast<int32_t>(*this);
}
operator int64_t() {
assert(my_type_ == ParamItemType::kInt64);
return absl::any_cast<int64_t>(*this);
}
operator std::string() {
assert(my_type_ == ParamItemType::kString);
return absl::any_cast<std::string>(*this);
}
friend bool operator==(const MyAny& a0, const MyAny& a1) {
std::cout << "==," << std::endl;
if (a0.my_type_ == a1.my_type_) {
switch (a0.my_type_) {
case ParamItemType::kInt32:
return absl::any_cast<int32_t>(a0) == absl::any_cast<int32_t>(a1);
case ParamItemType::kInt64:
return absl::any_cast<int64_t>(a0) == absl::any_cast<int64_t>(a1);
case ParamItemType::kString:
return absl::any_cast<std::string>(a0) ==
absl::any_cast<std::string>(a1);
default:
return false;
}
}
if (a0.my_type_ == ParamItemType::kInt32 &&
a1.my_type_ == ParamItemType::kInt64) {
return absl::any_cast<int32_t>(a0) == absl::any_cast<int64_t>(a1);
} else if (a0.my_type_ == ParamItemType::kInt64 &&
a1.my_type_ == ParamItemType::kInt32) {
return absl::any_cast<int64_t>(a0) == absl::any_cast<int32_t>(a1);
}
return false;
}
};
namespace std {
template <>
struct hash<MyAny> {
size_t operator()(const MyAny& any) const {
// std::cout << "hash of " << static_cast<int>(any.my_type()) << ", " <<
// any.type().name() << ", " << any.has_value() << std::endl;
int val = -1;
switch (any.my_type()) {
case ParamItemType::kInt32:
return hash<int>{}(absl::any_cast<int32_t>(any));
case ParamItemType::kInt64:
return hash<int>{}(absl::any_cast<int64_t>(any));
case ParamItemType::kString:
return hash<string>{}(absl::any_cast<string>(any));
default:
return -1;
}
}
};
} // namespace std
static void WithCache(benchmark::State& state) {
std::unordered_map<MyAny, int> m;
int32_t i = 0;
for (auto _ : state) {
m.insert(std::make_pair<>(i, i + 1));
i++;
}
}
// BENCHMARK(ParamRun)->MinTime(8);
BENCHMARK(NoCache)->MinTime(4);
BENCHMARK(WithCache)->MinTime(4);
BENCHMARK_MAIN();
================================================
FILE: examples/cache/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_binary(
name = "cache_test",
srcs = ["cache_test.cc"],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/param/statistic:scalable_cache_lib",
"//sentinel-core/param/statistic:any_cmp_lib",
"//sentinel-core/log:logger_lib",
],
)
================================================
FILE: examples/cache/cache_test.cc
================================================
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
#include <vector>
#include "sentinel-core/log/logger.h"
#include "sentinel-core/param/statistic/any_cmp.h"
#include "sentinel-core/param/statistic/scalable_cache.h"
using ScalableCache =
Sentinel::Param::ThreadSafeLRUCache<absl::any, Sentinel::Param::AnyCmp>;
using ScalableCacheUniquePtr = std::unique_ptr<ScalableCache>;
ScalableCache cache(100);
std::atomic<int64_t> winStart(0);
std::atomic<bool> stop(false);
constexpr int THREAD_NUM = 10;
int64_t CurrentTimeMillis() {
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
}
void Increase(int id, int cnt) {
while (!stop.load()) {
int64_t curTime = CurrentTimeMillis();
if (curTime - 500 > winStart) {
// int64_t sz = cache.size();
// Sentinel::Log::Logger::Log(Sentinel::Log::Logger::kDefaultFileLogger,
// Sentinel::info, "size={}", sz);
cache.clear();
winStart.store(curTime - curTime % 500);
}
cache.increase(id, cnt);
}
}
void Timer() {
int cnt = 6;
while (!stop.load()) {
std::cout << "[" << cnt << "] " << cache.size() << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
if (cnt-- <= 0) {
stop.store(true);
}
}
}
int main() {
Sentinel::Log::Logger::InitDefaultLogger();
std::thread myThreads[THREAD_NUM];
std::thread t0(Timer);
for (int i = 0; i < THREAD_NUM; i++) {
myThreads[i] = std::thread(Increase, 11000 + 100 * i, 1);
}
t0.join();
for (int i = 0; i < THREAD_NUM; i++) {
myThreads[i].join();
}
// std::vector<std::pair<absl::any, int>> pairs;
// cache.snapshotPairs(pairs);
// for (const auto& pair : pairs) {
// std::cout << pair.second << " ";
// } std::cout << "\n";
return 0;
}
================================================
FILE: examples/fmt/BUILD
================================================
cc_binary(
name = "fmt_test",
srcs = ["fmt_test.cc"],
deps = [
"@com_github_fmtlib_fmt//:fmtlib",
],
)
================================================
FILE: examples/fmt/fmt_test.cc
================================================
#include <iostream>
#include <string>
#include "fmt/format.h"
int main() {
std::string s = fmt::format("I'd rather be {1} than {0}.", "right", "happy");
std::cout << s << std::endl;
return 0;
}
================================================
FILE: examples/gtest/BUILD
================================================
cc_test(
name = "hello_test",
srcs = ["hello_test.cc"],
deps = [
"@com_google_googletest//:gtest_main",
],
)
================================================
FILE: examples/gtest/hello_test.cc
================================================
#include <string>
#include "gtest/gtest.h"
TEST(HelloTest, Basic) { EXPECT_EQ("Hello tester", "Hello tester"); }
================================================
FILE: examples/json/BUILD
================================================
cc_binary(
name = "nlohmann_json_example",
srcs = ["nlohmann_json_example.cc"],
deps = [
"//third_party/nlohmann:nlohmann_json_lib",
],
)
================================================
FILE: examples/json/nlohmann_json_example.cc
================================================
#include <iostream>
#include <typeinfo>
#include "third_party/nlohmann/json.hpp"
int main() {
try {
auto j2 = nlohmann::json::parse("sa");
} catch (std::exception& ex) {
std::cerr << "Exception: " << ex.what() << std::endl;
}
// create a JSON array
auto j3 = nlohmann::json::parse("{ \"happy\": true, \"pi\": 3.141 }");
auto c = j3["pi"];
if (c.is_number()) {
int d = static_cast<int>(c);
std::cout << d << std::endl;
}
std::cout << typeid(c).name() << std::endl;
return 0;
}
================================================
FILE: examples/libevent/BUILD
================================================
cc_binary(
name = "libevent_echosrv1",
srcs = ["libevent_echosrv1.c"],
deps = [
"//:libevent",
],
)
================================================
FILE: examples/libevent/libevent_echosrv1.c
================================================
// Copied from
// https://github.com/jasonish/libevent-examples/blob/6d20f0d86c2cd263f5edff28862bc09ce4a3220f/echo-server/libevent_echosrv1.c
// for testing purposes only.
/*
* Copyright (c) 2011, Jason Ish
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* libevent echo server example.
*/
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
/* For inet_ntoa. */
#include <arpa/inet.h>
/* Required by event.h. */
#include <sys/time.h>
#include <err.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
/* Libevent. */
#include <event.h>
/* Port to listen on. */
#define SERVER_PORT 5555
/**
* A struct for client specific data, in this simple case the only
* client specific data is the read event.
*/
struct client {
struct event ev_read;
};
/**
* Set a socket to non-blocking mode.
*/
int setnonblock(int fd) {
int flags;
flags = fcntl(fd, F_GETFL);
if (flags < 0) return flags;
flags |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) < 0) return -1;
return 0;
}
/**
* This function will be called by libevent when the client socket is
* ready for reading.
*/
void on_read(int fd, short ev, void *arg) {
struct client *client = (struct client *)arg;
u_char buf[8196];
int len, wlen;
len = read(fd, buf, sizeof(buf));
if (len == 0) {
/* Client disconnected, remove the read event and the
* free the client structure. */
printf("Client disconnected.\n");
close(fd);
event_del(&client->ev_read);
free(client);
return;
} else if (len < 0) {
/* Some other error occurred, close the socket, remove
* the event and free the client structure. */
printf("Socket failure, disconnecting client: %s", strerror(errno));
close(fd);
event_del(&client->ev_read);
free(client);
return;
}
/* XXX For the sake of simplicity we'll echo the data write
* back to the client. Normally we shouldn't do this in a
* non-blocking app, we should queue the data and wait to be
* told that we can write.
*/
wlen = write(fd, buf, len);
if (wlen < len) {
/* We didn't write all our data. If we had proper
* queueing/buffering setup, we'd finish off the write
* when told we can write again. For this simple case
* we'll just lose the data that didn't make it in the
* write.
*/
printf("Short write, not all data echoed back to client.\n");
}
}
/**
* This function will be called by libevent when there is a connection
* ready to be accepted.
*/
void on_accept(int fd, short ev, void *arg) {
int client_fd;
struct sockaddr_in client_addr;
socklen_t client_len = sizeof(client_addr);
struct client *client;
/* Accept the new connection. */
client_fd = accept(fd, (struct sockaddr *)&client_addr, &client_len);
if (client_fd == -1) {
warn("accept failed");
return;
}
/* Set the client socket to non-blocking mode. */
if (setnonblock(client_fd) < 0)
warn("failed to set client socket non-blocking");
/* We've accepted a new client, allocate a client object to
* maintain the state of this client. */
client = calloc(1, sizeof(*client));
if (client == NULL) err(1, "malloc failed");
/* Setup the read event, libevent will call on_read() whenever
* the clients socket becomes read ready. We also make the
* read event persistent so we don't have to re-add after each
* read. */
event_set(&client->ev_read, client_fd, EV_READ | EV_PERSIST, on_read, client);
/* Setting up the event does not activate, add the event so it
* becomes active. */
event_add(&client->ev_read, NULL);
printf("Accepted connection from %s\n", inet_ntoa(client_addr.sin_addr));
}
int main(int argc, char **argv) {
int listen_fd;
struct sockaddr_in listen_addr;
int reuseaddr_on = 1;
/* The socket accept event. */
struct event ev_accept;
/* Initialize libevent. */
event_init();
// comment out since it is called from test and should terminate
// /* Create our listening socket. This is largely boiler plate
// * code that I'll abstract away in the future. */
// listen_fd = socket(AF_INET, SOCK_STREAM, 0);
// if (listen_fd < 0)
// err(1, "listen failed");
// if (setsockopt(listen_fd, SOL_SOCKET, SO_REUSEADDR, &reuseaddr_on,
// sizeof(reuseaddr_on)) == -1)
// err(1, "setsockopt failed");
// memset(&listen_addr, 0, sizeof(listen_addr));
// listen_addr.sin_family = AF_INET;
// listen_addr.sin_addr.s_addr = INADDR_ANY;
// listen_addr.sin_port = htons(SERVER_PORT);
// if (bind(listen_fd, (struct sockaddr *)&listen_addr, sizeof(listen_addr))
// < 0)
// err(1, "bind failed");
// if (listen(listen_fd, 5) < 0)
// err(1, "listen failed");
//
// /* Set the socket to non-blocking, this is essential in event
// * based programming with libevent. */
// if (setnonblock(listen_fd) < 0)
// err(1, "failed to set server socket to non-blocking");
//
// /* We now have a listening socket, we create a read event to
// * be notified when a client connects. */
// event_set(&ev_accept, listen_fd, EV_READ | EV_PERSIST, on_accept, NULL);
// event_add(&ev_accept, NULL);
//
// /* Start the libevent event loop. */
// event_dispatch();
return 0;
}
================================================
FILE: examples/log/BUILD
================================================
cc_binary(
name = "log_test",
srcs = ["log_test.cc"],
deps = [
"@com_github_gabime_spdlog//:spdlog",
],
)
================================================
FILE: examples/log/log_test.cc
================================================
#include "spdlog/spdlog.h"
int main() {
spdlog::info("Welcome to spdlog!");
spdlog::error("Some error message with arg: {}", 1);
spdlog::warn("Easy padding in numbers like {:08d}", 12);
spdlog::critical(
"Support for int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
spdlog::info("Support for floats {:03.2f}", 1.23456);
spdlog::info("Positional args are {1} {0}..", "too", "supported");
spdlog::info("{:<30}", "left aligned");
spdlog::set_level(spdlog::level::debug); // Set global log level to debug
spdlog::debug("This message should be displayed..");
// change log pattern
spdlog::set_pattern("[%H:%M:%S %z] [%n] [%^---%L---%$] [thread %t] %v");
// Compile time log levels
// define SPDLOG_ACTIVE_LEVEL to desired level
SPDLOG_TRACE("Some trace message with param {}", {});
SPDLOG_DEBUG("Some debug message");
// Set the default logger to file logger
// auto file_logger = spdlog::basic_logger_mt("basic_logger",
// "logs/basic.txt"); spdlog::set_default_logger(file_logger);
}
================================================
FILE: examples/sentinel-cpp/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
# https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary
cc_binary(
name = "sentinel_basic_qps_limit",
srcs = ["basic_qps_limit.cc"],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/public:sph_u_lib",
"//sentinel-core/log/metric:metric_log_task_lib",
"//sentinel-core/transport/command:http_command_center_init_target",
],
)
cc_binary(
name = "sentinel_basic_concurrency_limit",
srcs = ["basic_concurrency_limit.cc"],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/public:sph_u_lib",
"//sentinel-core/log/metric:metric_log_task_lib",
"//sentinel-core/transport/command:http_command_center_init_target",
],
)
# https://docs.bazel.build/versions/master/be/c-cpp.html#cc_binary
cc_binary(
name = "sentinel_basic_system_limit",
srcs = ["basic_system_limit.cc"],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/public:sph_u_lib",
"//sentinel-core/log/metric:metric_log_task_lib",
"//sentinel-core/transport/command:http_command_center_init_target",
],
)
cc_binary(
name = "sentinel_basic_param_limit",
srcs = ["basic_param_limit.cc"],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/public:sph_u_lib",
"//sentinel-core/log/metric:metric_log_task_lib",
"//sentinel-core/transport/command:http_command_center_init_target",
],
)
================================================
FILE: examples/sentinel-cpp/basic_concurrency_limit.cc
================================================
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <string>
#include <thread>
#include "sentinel-core/flow/flow_rule_manager.h"
#include "sentinel-core/init/init_target_registry.h"
#include "sentinel-core/log/metric/metric_log_task.h"
#include "sentinel-core/public/sph_u.h"
#include "sentinel-core/transport/command/http_server_init_target.h"
Sentinel::Init::InitTargetRegister<
Sentinel::Transport::HttpCommandCenterInitTarget>
HCCIT_registered;
void doEntry(const char* resource) {
while (true) {
auto r = Sentinel::SphU::Entry(resource);
if (r->IsBlocked()) {
std::cout << "b";
std::this_thread::sleep_for(std::chrono::milliseconds(10));
} else {
std::cout << "\n~~passed~~\n";
std::this_thread::sleep_for(std::chrono::milliseconds(10));
r->Exit();
}
}
}
void doOneEntry() { doEntry("my_open_api_abc"); }
void doAnotherEntry() { doEntry("big_brother_service:foo()"); }
/*
* Run the demo: CSP_SENTINEL_APP_NAME=your-app-name
* ./bazel-bin/examples/sentinel-cpp/sentinel_basic_concurrency_limit
*/
int main() {
// Initialize for Sentinel.
Sentinel::Log::Logger::InitDefaultLogger();
Sentinel::Transport::HttpCommandCenterInitTarget command_center_init;
command_center_init.Initialize();
Sentinel::Log::MetricLogTask metric_log_task;
metric_log_task.Initialize();
Sentinel::Flow::FlowRule rule1{"my_open_api_abc"};
rule1.set_metric_type(Sentinel::Flow::FlowMetricType::kThreadCount);
rule1.set_count(2);
Sentinel::Flow::FlowRuleManager::GetInstance().LoadRules({rule1});
std::thread t1(doOneEntry);
std::thread t2(doOneEntry);
std::this_thread::sleep_for(std::chrono::milliseconds(5));
std::thread t3(doOneEntry);
std::thread t4(doAnotherEntry);
std::thread t5(doOneEntry);
std::thread t6(doOneEntry);
t1.join();
t2.join();
t3.join();
t4.join();
t5.join();
t6.join();
return 0;
}
================================================
FILE: examples/sentinel-cpp/basic_param_limit.cc
================================================
#include <math.h>
#include <atomic>
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <mutex>
#include <string>
#include <thread>
#include "sentinel-core/init/init_target_registry.h"
#include "sentinel-core/log/metric/metric_log_task.h"
#include "sentinel-core/param/param_flow_rule_constants.h"
#include "sentinel-core/param/param_flow_rule_manager.h"
#include "sentinel-core/public/sph_u.h"
#include "sentinel-core/transport/command/http_server_init_target.h"
std::mutex mtx;
std::atomic<bool> stop(false);
constexpr int SECONDS = 60, THREAD_NUM = 8;
std::atomic<int> pass, block, seconds(SECONDS);
std::vector<std::atomic<int>> pPassCnt(10);
std::vector<std::atomic<int>> pBlockCnt(10);
std::thread myThreads[THREAD_NUM];
int threadCnt = 0;
int64_t CurrentTimeMillis() {
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
}
void RunTask() {
double ans = 1.001;
for (int i = 0; i < 3000; i++) {
double index = (rand() % 5) * ((CurrentTimeMillis() / 1000) % 3);
ans = pow(ans, index);
}
}
void DoEntry(const char* resource) {
int cnt = 0;
while (!stop.load()) {
int32_t randParam = (rand() + (CurrentTimeMillis() / 10)) % 10;
randParam = ((cnt++)) % 50;
auto r = Sentinel::SphU::Entry(resource, Sentinel::EntryType::IN, 1, 0,
randParam, std::string("example"));
if (r->IsBlocked()) {
// pBlockCnt[randParam].fetch_add(1);
block.fetch_add(1);
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
} else {
pass.fetch_add(1);
// pPassCnt[randParam].fetch_add(1);
RunTask();
// std::this_thread::sleep_for(std::chrono::milliseconds(100));
r->Exit();
}
}
}
void TimerTask() {
int oldTotal = 0, oldPass = 0, oldBlock = 0;
int oldPTotal[10] = {0}, oldPPass[10] = {0}, oldPBlock[10] = {0};
std::cerr << "Begin to statistic!!!" << std::endl;
int cnt = 0;
while (true) {
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
int globalPass = pass.load();
int globalBlock = block.load();
int globalTotal = globalBlock + globalPass;
int oneSecondPass = globalPass - oldPass;
int oneSecondBlock = globalBlock - oldBlock;
int oneSecondTotal = globalTotal - oldTotal;
oldPass = globalPass;
oldBlock = globalBlock;
oldTotal = globalTotal;
std::cerr << "[" << seconds.load() << "] total=" << oneSecondTotal
<< ", pass=" << oneSecondPass << ", block=" << oneSecondBlock
<< std::endl;
int leftSec = seconds.fetch_sub(1);
if (leftSec <= 0) {
stop.store(true);
break;
}
}
}
/*
* Run the demo: CSP_SENTINEL_APP_NAME=your-app-name
* ./bazel-bin/examples/sentinel-cpp/sentinel_basic_param_limit
*/
int main() {
// Initialize for Sentinel.
Sentinel::Log::Logger::InitDefaultLogger();
Sentinel::Transport::HttpCommandCenterInitTarget command_center_init;
command_center_init.Initialize();
Sentinel::Log::MetricLogTask metric_log_task;
metric_log_task.Initialize();
std::string myResource("some_param_test");
Sentinel::Param::ParamFlowRule rule0, rule1, rule12, rule11;
rule0.set_resource(myResource);
rule0.set_metric_type(Sentinel::Param::ParamFlowMetricType::kQps);
rule0.set_threshold(2000);
rule0.set_cache_size(200);
rule0.set_interval_in_ms(1000);
rule0.set_param_idx(0);
rule1.set_resource(myResource);
rule1.set_metric_type(Sentinel::Param::ParamFlowMetricType::kQps);
rule1.set_threshold(6000);
rule1.set_param_idx(1);
rule1.set_interval_in_ms(1000);
Sentinel::Param::ParamFlowItem item0(std::string("nonexisting-str"),
Sentinel::Param::ParamItemType::kString,
100);
rule1.set_param_flow_item_list({item0});
rule12.set_resource("non-existing-resource"); // should not work
rule12.set_metric_type(Sentinel::Param::ParamFlowMetricType::kQps);
rule12.set_threshold(1);
rule12.set_param_idx(1);
rule12.set_interval_in_ms(1000);
Sentinel::Param::ParamFlowRuleManager::GetInstance().LoadRules(
{rule1, rule0, rule12});
std::thread t0(TimerTask);
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
std::cerr << "Thread num is " << THREAD_NUM << std::endl;
for (int i = 0; i < THREAD_NUM; i++) {
myThreads[i] = std::thread(DoEntry, myResource.c_str());
}
for (int i = 0; i < THREAD_NUM; i++) {
myThreads[i].join();
}
t0.join();
return 0;
}
================================================
FILE: examples/sentinel-cpp/basic_qps_limit.cc
================================================
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <string>
#include <thread>
#include "sentinel-core/flow/flow_rule_manager.h"
#include "sentinel-core/init/init_target_registry.h"
#include "sentinel-core/log/metric/metric_log_task.h"
#include "sentinel-core/public/sph_u.h"
#include "sentinel-core/transport/command/http_server_init_target.h"
void DoEntry(const char* resource) {
while (true) {
auto r = Sentinel::SphU::Entry(resource);
if (r->IsBlocked()) {
// Indicating the request is blocked. We can do something for this.
std::cout << "b";
std::this_thread::sleep_for(std::chrono::milliseconds(8));
} else {
std::cout << "\n~~passed~~\n";
std::this_thread::sleep_for(std::chrono::milliseconds(8));
r->Exit();
}
std::cout.flush();
}
}
void DoOneEntry() { DoEntry("my_open_api_abc"); }
void DoAnotherEntry() { DoEntry("m1:my_another_api_233"); }
/*
* Run the demo: CSP_SENTINEL_APP_NAME=your-app-name
* ./bazel-bin/examples/sentinel-cpp/sentinel_basic_qps_limit
*/
int main() {
// Initialize for Sentinel.
Sentinel::Log::Logger::InitDefaultLogger();
Sentinel::Transport::HttpCommandCenterInitTarget command_center_init;
command_center_init.Initialize();
Sentinel::Log::MetricLogTask metric_log_task;
metric_log_task.Initialize();
Sentinel::Flow::FlowRule rule1{"my_open_api_abc"};
rule1.set_count(10);
rule1.set_control_behavior(Sentinel::Flow::FlowControlBehavior::kThrotting);
Sentinel::Flow::FlowRule rule2{"m1:my_another_api_233"};
rule2.set_count(5);
Sentinel::Flow::FlowRuleManager::GetInstance().LoadRules({rule1, rule2});
std::thread t1(DoOneEntry);
std::thread t2(DoOneEntry);
std::thread t21(DoOneEntry);
std::thread t22(DoOneEntry);
std::thread t23(DoOneEntry);
std::this_thread::sleep_for(std::chrono::milliseconds(5));
std::thread t3(DoOneEntry);
std::thread t4(DoAnotherEntry);
std::this_thread::sleep_for(std::chrono::milliseconds(9));
std::thread t5(DoOneEntry);
std::thread t6(DoOneEntry);
t1.join();
t2.join();
t3.join();
t4.join();
t5.join();
t6.join();
return 0;
}
================================================
FILE: examples/sentinel-cpp/basic_system_limit.cc
================================================
#include <math.h>
#include <atomic>
#include <chrono>
#include <cstdlib>
#include <iostream>
#include <string>
#include <thread>
#include "sentinel-core/init/init_target_registry.h"
#include "sentinel-core/log/metric/metric_log_task.h"
#include "sentinel-core/public/sph_u.h"
#include "sentinel-core/system/system_rule_manager.h"
#include "sentinel-core/transport/command/http_server_init_target.h"
std::atomic<int> pass, block, seconds(1200);
std::atomic<bool> stop(false);
int64_t CurrentTimeMillis() {
return std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
}
void RunTask() {
double ans = 1.001;
for (int i = 0; i < 400; i++) {
double index = (rand() % 5) * ((CurrentTimeMillis() / 1000) % 3);
ans = pow(ans, index);
}
}
void DoEntry(const char* resource, Sentinel::EntryType trafficType) {
while (true) {
auto r = Sentinel::SphU::Entry(resource, trafficType);
if (r->IsBlocked()) {
// Indicating the request is blocked. We can do something for this.
block.fetch_add(1);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
} else {
pass.fetch_add(1);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
r->Exit();
}
std::cout.flush();
}
}
void TimerTask() {
int oldTotal = 0, oldPass = 0, oldBlock = 0;
std::cout << "Begin to statistic!!!" << std::endl;
while (true) {
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
int globalPass = pass.load();
int globalBlock = block.load();
int globalTotal = globalBlock + globalPass;
int oneSecondPass = globalPass - oldPass;
int oneSecondBlock = globalBlock - oldBlock;
int oneSecondTotal = globalTotal - oldTotal;
oldPass = globalPass;
oldBlock = globalBlock;
oldTotal = globalTotal;
std::cout << "[" << seconds.load() << "] total=" << oneSecondTotal
<< ", pass=" << oneSecondPass << ", block=" << oneSecondBlock
<< std::endl;
int leftSec = seconds.fetch_sub(1);
if (leftSec <= 0) {
stop.store(true);
break;
}
}
}
/*
* Run the demo: CSP_SENTINEL_APP_NAME=your-app-name
* ./bazel-bin/examples/sentinel-cpp/sentinel_basic_qps_limit
*/
int main() {
// Initialize for Sentinel.
Sentinel::Log::Logger::InitDefaultLogger();
Sentinel::Transport::HttpCommandCenterInitTarget command_center_init;
command_center_init.Initialize();
Sentinel::Log::MetricLogTask metric_log_task;
metric_log_task.Initialize();
Sentinel::System::SystemStatusListener::GetInstance().Initialize();
Sentinel::System::SystemRule rule1, rule2, rule3;
rule1.set_rule_type(Sentinel::System::MetricType::kQps);
rule1.set_threshold(static_cast<double>(250));
rule2.set_rule_type(Sentinel::System::MetricType::kConcurrency);
rule2.set_threshold(4);
rule3.set_rule_type(Sentinel::System::MetricType::kCpuUsage);
rule3.set_threshold(static_cast<double>(0.8));
Sentinel::System::SystemRule rule4{Sentinel::System::MetricType::kCpuUsage,
0.7};
Sentinel::System::SystemRule badRule{Sentinel::System::MetricType::kRt, -2};
Sentinel::System::SystemRuleManager::GetInstance().LoadRules(
{rule1, rule2, rule3, rule4, badRule});
std::thread t0(TimerTask);
std::thread t1(DoEntry, "my_open_api_abc", Sentinel::EntryType::IN);
std::this_thread::sleep_for(std::chrono::milliseconds(47));
std::thread t2(DoEntry, "my_open_api_abc", Sentinel::EntryType::IN);
std::this_thread::sleep_for(std::chrono::milliseconds(23));
std::thread t3(DoEntry, "my_open_api_abc", Sentinel::EntryType::IN);
// std::this_thread::sleep_for(std::chrono::milliseconds(19));
std::thread t4(DoEntry, "my_open_api_abc", Sentinel::EntryType::IN);
// std::thread t5(DoEntry, "foo", Sentinel::EntryType::OUT);
t0.join();
t1.join();
t2.join();
t3.join();
t4.join();
// t5.join();
return 0;
}
================================================
FILE: examples/tbb/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_binary(
name = "tbb_test",
srcs = ["tbb_test.cc"],
# srcs = select({
# "//bazel:is_android": [],
# "//bazel:is_wsl": [ "tbb_test.cc" ],
# "//conditions:default": [ "tbb_test.cc" ],
# }),
copts = DEFAULT_COPTS,
deps = select({
"//bazel:is_osx": [
"//sentinel-core/log:logger_lib",
"@com_github_libtbb_osx//:tbb_osx",
],
"//conditions:default": [
"//sentinel-core/log:logger_lib",
"@com_github_libtbb//:tbb",
],
}),
)
================================================
FILE: examples/tbb/tbb_test.cc
================================================
#include <chrono>
#include <iostream>
#include <thread>
#include "sentinel-core/log/logger.h"
#include "tbb/concurrent_hash_map.h"
constexpr int NUM_THREADS = 10000;
class Stu {
public:
int id;
std::string name;
~Stu() { std::cout << "Destructor" << std::endl; }
};
tbb::concurrent_hash_map<int, std::unique_ptr<Stu>> stuMap;
int main() {
Sentinel::Log::Logger::InitDefaultLogger();
std::cout << "loop begin\n";
decltype(stuMap)::accessor ac;
if (stuMap.insert(ac, std::make_pair<>(1, nullptr))) {
ac->second = std::make_unique<Stu>();
std::cout << stuMap.size() << std::endl;
}
ac.release();
decltype(stuMap)::accessor ac2;
stuMap.insert(ac2, std::make_pair<>(1, std::make_unique<Stu>()));
std::cout << "===== END =====" << stuMap.size() << std::endl;
return 0;
}
================================================
FILE: format.sh
================================================
#!/usr/bin/env bash
CMD=clang-format-8
$CMD -version
$CMD -i -style=Google $(git ls-files|grep -E ".*\.(cc|h)$")
CHANGED="$(git ls-files --modified)"
if [[ ! -z "$CHANGED" ]]; then
echo "The following files have changes due to incrrect format:"
echo "$CHANGED"
echo "please use format.sh script fix it"
exit 1
else
echo "No changes."
fi
================================================
FILE: sentinel-core/BUILD
================================================
================================================
FILE: sentinel-core/circuitbreaker/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "rule_lib",
srcs = [
"rule.h",
"rule.cc",
],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/common:rule_lib",
"@com_google_absl//absl/strings:str_format",
]
)
cc_library(
name = "circuit_breaker_interface",
srcs = [
"circuit_breaker.h",
"circuit_breaker.cc",
],
copts = DEFAULT_COPTS,
deps = [
":rule_lib",
"//sentinel-core/statistic/node:node_interface",
"//sentinel-core/utils:utils_lib",
]
)
cc_library(
name = "rt_circuit_breaker_lib",
srcs = [
"rt_circuit_breaker.h",
"rt_circuit_breaker.cc",
],
copts = DEFAULT_COPTS,
deps = [
":circuit_breaker_interface",
":rule_lib",
"//sentinel-core/statistic/base:leap_array_lib",
]
)
cc_library(
name = "error_circuit_breaker_lib",
srcs = [
"error_circuit_breaker.h",
"error_circuit_breaker.cc",
],
copts = DEFAULT_COPTS,
deps = [
":circuit_breaker_interface",
":rule_lib",
"//sentinel-core/statistic/base:leap_array_lib",
]
)
cc_library(
name = "rule_manager_lib",
srcs = [
"rule_manager.h",
"rule_manager.cc",
],
copts = DEFAULT_COPTS,
deps = [
":error_circuit_breaker_lib",
":rt_circuit_breaker_lib",
":rule_lib",
"//sentinel-core/log:logger_lib",
"//sentinel-core/property:dynamic_sentinel_property_lib",
"//sentinel-core/property:property_listener_interface",
"//sentinel-core/property:sentinel_property_interface",
"@com_google_absl//absl/synchronization",
]
)
cc_library(
name = "rule_slot_lib",
srcs = [
"slot.h",
"slot.cc",
],
copts = DEFAULT_COPTS,
deps = [
":rule_manager_lib",
"//sentinel-core/slot/base:rule_checker_slot_interface",
"//sentinel-core/slot/base:stats_slot_interface",
]
)
cc_test(
name = "slot_unittests",
srcs = [
"slot_test.cc",
],
copts = TEST_COPTS,
deps = [
":rule_slot_lib",
"//sentinel-core/common:string_resource_wrapper_lib",
"//sentinel-core/test/mock/statistic/node:mock_lib",
"@com_google_googletest//:gtest_main",
]
)
# cc_library(
# name = "flow_rule_manager_lib",
# srcs = [
# "flow_rule_manager.h",
# "flow_rule_manager.cc",
# ],
# copts = DEFAULT_COPTS,
# deps = [
# ":flow_rule_constants_lib",
# ":flow_rule_lib",
# ":traffic_shaping_controller_lib",
# ":default_traffic_shaping_calculator_lib",
# ":default_traffic_shaping_checker_lib",
# "//sentinel-core/property:property_listener_interface",
# "//sentinel-core/log:logger_lib",
# "//sentinel-core/property:sentinel_property_interface",
# "//sentinel-core/property:dynamic_sentinel_property_lib",
# "@com_google_absl//absl/synchronization",
# ]
# )
# cc_test(
# name = "flow_slot_unittests",
# srcs = [
# "flow_slot_test.cc",
# ],
# copts = TEST_COPTS,
# deps = [
# ":flow_slot_lib",
# "//sentinel-core/common:string_resource_wrapper_lib",
# "//sentinel-core/test/mock/statistic/node:mock_lib",
# "@com_google_googletest//:gtest_main",
# ]
# )
================================================
FILE: sentinel-core/circuitbreaker/circuit_breaker.cc
================================================
#include <atomic>
#include <memory>
#include "sentinel-core/circuitbreaker/circuit_breaker.h"
#include "sentinel-core/utils/time_utils.h"
namespace Sentinel {
namespace CircuitBreaker {
State AbstractCircuitBreaker::CurrentState() { return current_state_.load(); }
const Rule& AbstractCircuitBreaker::GetRule() const { return rule_; }
bool AbstractCircuitBreaker::RetryTimeoutArrived() {
return Utils::TimeUtils::CurrentTimeMillis().count() >= next_retry_timestamp_;
}
void AbstractCircuitBreaker::UpdateNextRetryTimestamp() {
this->next_retry_timestamp_ =
Utils::TimeUtils::CurrentTimeMillis().count() + retry_timeout_ms_;
}
bool AbstractCircuitBreaker::FromCloseToOpen(double snapshot) {
auto expected = State::kClosed;
if (current_state_.compare_exchange_strong(expected, State::kOpen)) {
UpdateNextRetryTimestamp();
return true;
}
return false;
}
bool AbstractCircuitBreaker::FromOpenToHalfOpen() {
auto expected = State::kOpen;
return current_state_.compare_exchange_strong(expected, State::kHalfOpen);
}
bool AbstractCircuitBreaker::FromHalfOpenToOpen(double snapshot) {
auto expected = State::kHalfOpen;
if (current_state_.compare_exchange_strong(expected, State::kOpen)) {
UpdateNextRetryTimestamp();
return true;
}
return false;
}
bool AbstractCircuitBreaker::FromHalfOpenToClose() {
auto expected = State::kHalfOpen;
if (current_state_.compare_exchange_strong(expected, State::kClosed)) {
Reset();
return true;
}
return false;
}
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/circuit_breaker.h
================================================
#pragma once
#include <atomic>
#include <memory>
#include "sentinel-core/circuitbreaker/rule.h"
#include "sentinel-core/statistic/node/node.h"
namespace Sentinel {
namespace CircuitBreaker {
enum class State { kClosed = 0, kOpen = 1, kHalfOpen = 2 };
class CircuitBreaker {
public:
CircuitBreaker() = default;
virtual ~CircuitBreaker() = default;
virtual const Rule& GetRule() const = 0;
virtual State CurrentState() = 0;
virtual bool TryPass(Stat::NodeSharedPtr& node) = 0;
virtual void Reset() = 0;
virtual void RecordComplete(int64_t rt, const std::string& error) = 0;
};
using CircuitBreakerSharedPtr = std::shared_ptr<CircuitBreaker>;
class AbstractCircuitBreaker : public CircuitBreaker {
public:
explicit AbstractCircuitBreaker(const Rule& rule)
: rule_(rule), retry_timeout_ms_(rule.retry_timeout_sec() * 1000) {}
virtual ~AbstractCircuitBreaker() = default;
State CurrentState() override;
const Rule& GetRule() const override;
protected:
bool RetryTimeoutArrived();
void UpdateNextRetryTimestamp();
bool FromCloseToOpen(double snapshot);
bool FromOpenToHalfOpen();
bool FromHalfOpenToOpen(double snapshot);
bool FromHalfOpenToClose();
const Rule rule_;
const int32_t retry_timeout_ms_;
std::atomic<State> current_state_{State::kClosed};
int64_t next_retry_timestamp_ = 0;
};
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/error_circuit_breaker.cc
================================================
#include <memory>
#include "sentinel-core/circuitbreaker/error_circuit_breaker.h"
namespace Sentinel {
namespace CircuitBreaker {
std::shared_ptr<SimpleErrorCounter> SimpleErrorCounterLeapArray::NewEmptyBucket(
int64_t) {
return std::make_shared<SimpleErrorCounter>();
}
void SimpleErrorCounterLeapArray::ResetWindowTo(
const Stat::WindowWrapSharedPtr<SimpleErrorCounter>& w,
int64_t start_time) {
// Update the start time and reset value.
w->ResetTo(start_time);
w->Value()->Reset();
}
bool ErrorCircuitBreaker::TryPass(Stat::NodeSharedPtr&) {
State state = current_state_.load();
if (state == State::kClosed) {
return true;
}
if (state == State::kOpen) {
return RetryTimeoutArrived() && FromOpenToHalfOpen();
}
return false;
}
void ErrorCircuitBreaker::Reset() {
// NOTE: only reset the current bucket as the sampleCount=1
sliding_counter_->CurrentWindow()->Value()->Reset();
}
void ErrorCircuitBreaker::RecordComplete(int64_t, const std::string& err) {
auto counter = sliding_counter_->CurrentWindow()->Value();
if (!err.empty()) {
counter->AddErrorCount(1);
}
counter->AddTotalCount(1);
RecordAndHandleStateChange(err);
}
void ErrorCircuitBreaker::RecordAndHandleStateChange(const std::string& err) {
if (current_state_.load() == State::kOpen) {
return;
}
if (current_state_.load() == State::kHalfOpen) {
if (!err.empty()) {
FromHalfOpenToOpen(1);
} else {
FromHalfOpenToClose();
}
return;
}
auto counters = sliding_counter_->Values();
int64_t err_count = 0, total_count = 0;
for (auto& c : counters) {
err_count += c->error_count();
total_count += c->total_count();
}
if (total_count < rule_.min_request_amount()) {
return;
}
double cur_value = strategy_ == Strategy::kErrorRatio
? err_count * 1.0 / total_count
: err_count;
if (cur_value > threshold_) {
auto cs = current_state_.load();
switch (cs) {
case State::kClosed:
FromCloseToOpen(cur_value);
break;
case State::kHalfOpen:
FromHalfOpenToOpen(cur_value);
break;
default:
break;
}
}
}
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/error_circuit_breaker.h
================================================
#pragma once
#include <atomic>
#include <memory>
#include "sentinel-core/circuitbreaker/circuit_breaker.h"
#include "sentinel-core/circuitbreaker/rule.h"
#include "sentinel-core/statistic/base/leap_array.h"
namespace Sentinel {
namespace CircuitBreaker {
class SimpleErrorCounter {
public:
explicit SimpleErrorCounter() = default;
virtual ~SimpleErrorCounter() = default;
int64_t AddErrorCount(int64_t count) {
return error_count_.fetch_add(count) + count;
};
int64_t AddTotalCount(int64_t count) {
return total_count_.fetch_add(count) + count;
};
void Reset() {
error_count_ = 0;
total_count_ = 0;
};
int64_t error_count() { return error_count_.load(); };
int64_t total_count() { return total_count_.load(); };
private:
std::atomic<int64_t> error_count_{0};
std::atomic<int64_t> total_count_{0};
};
class SimpleErrorCounterLeapArray : public Stat::LeapArray<SimpleErrorCounter> {
public:
explicit SimpleErrorCounterLeapArray(int32_t sample_count,
int32_t interval_ms)
: LeapArray(sample_count, interval_ms) {}
virtual ~SimpleErrorCounterLeapArray() {}
std::shared_ptr<SimpleErrorCounter> NewEmptyBucket(
int64_t time_millis) override;
void ResetWindowTo(const Stat::WindowWrapSharedPtr<SimpleErrorCounter>& wrap,
int64_t start_time) override;
};
class ErrorCircuitBreaker : public AbstractCircuitBreaker {
public:
explicit ErrorCircuitBreaker(const Rule& rule)
: AbstractCircuitBreaker(rule),
sliding_counter_(std::make_unique<SimpleErrorCounterLeapArray>(
1, rule.stat_interval_ms())) {
this->strategy_ = rule.strategy();
this->threshold_ = rule.threshold();
}
virtual ~ErrorCircuitBreaker() = default;
bool TryPass(Stat::NodeSharedPtr& node) override;
void Reset() override;
void RecordComplete(int64_t rt, const std::string& error) override;
private:
void RecordAndHandleStateChange(const std::string& err);
Strategy strategy_;
double threshold_;
const std::unique_ptr<SimpleErrorCounterLeapArray> sliding_counter_;
};
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/rt_circuit_breaker.cc
================================================
#include <memory>
#include "sentinel-core/circuitbreaker/rt_circuit_breaker.h"
namespace Sentinel {
namespace CircuitBreaker {
std::shared_ptr<SlowRequestCounter> SlowRequestLeapArray::NewEmptyBucket(
int64_t) {
return std::make_shared<SlowRequestCounter>();
}
void SlowRequestLeapArray::ResetWindowTo(
const Stat::WindowWrapSharedPtr<SlowRequestCounter>& w,
int64_t start_time) {
// Update the start time and reset value.
w->ResetTo(start_time);
w->Value()->Reset();
}
bool ResponseTimeCircuitBreaker::TryPass(Stat::NodeSharedPtr&) {
State state = current_state_.load();
if (state == State::kClosed) {
return true;
}
if (state == State::kOpen) {
return RetryTimeoutArrived() && FromOpenToHalfOpen();
}
return false;
}
void ResponseTimeCircuitBreaker::Reset() {
sliding_counter_->CurrentWindow()->Value()->Reset();
}
void ResponseTimeCircuitBreaker::RecordComplete(int64_t rt,
const std::string&) {
auto counter = sliding_counter_->CurrentWindow()->Value();
if (rt > max_allowed_rt_) {
counter->AddSlowCount(1);
}
counter->AddTotalCount(1);
RecordAndHandleStateChange(rt);
}
void ResponseTimeCircuitBreaker::RecordAndHandleStateChange(int64_t rt) {
if (current_state_.load() == State::kOpen) {
return;
}
if (current_state_.load() == State::kHalfOpen) {
if (rt > max_allowed_rt_) {
FromHalfOpenToOpen(1.0);
} else {
FromHalfOpenToClose();
}
return;
}
auto counters = sliding_counter_->Values();
int64_t slow_count = 0, total_count = 0;
for (auto& c : counters) {
slow_count += c->slow_count();
total_count += c->total_count();
}
if (total_count < rule_.min_request_amount()) {
return;
}
double current_ratio = slow_count * 1.0 / total_count;
if (current_ratio > max_slow_request_ratio_) {
auto cs = current_state_.load();
switch (cs) {
case State::kClosed:
FromCloseToOpen(current_ratio);
break;
case State::kHalfOpen:
FromHalfOpenToOpen(current_ratio);
break;
default:
break;
}
}
}
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/rt_circuit_breaker.h
================================================
#pragma once
#include <atomic>
#include <memory>
#include "sentinel-core/circuitbreaker/circuit_breaker.h"
#include "sentinel-core/circuitbreaker/rule.h"
#include "sentinel-core/statistic/base/leap_array.h"
namespace Sentinel {
namespace CircuitBreaker {
class SlowRequestCounter {
public:
explicit SlowRequestCounter() = default;
virtual ~SlowRequestCounter() = default;
int64_t AddSlowCount(int64_t count) {
return slow_count_.fetch_add(count) + count;
};
int64_t AddTotalCount(int64_t count) {
return total_count_.fetch_add(count) + count;
};
void Reset() {
slow_count_ = 0;
total_count_ = 0;
};
int64_t slow_count() { return slow_count_.load(); };
int64_t total_count() { return total_count_.load(); };
private:
std::atomic<int64_t> slow_count_{0};
std::atomic<int64_t> total_count_{0};
};
class SlowRequestLeapArray : public Stat::LeapArray<SlowRequestCounter> {
public:
explicit SlowRequestLeapArray(int32_t sample_count, int32_t interval_ms)
: LeapArray(sample_count, interval_ms) {}
virtual ~SlowRequestLeapArray() {}
std::shared_ptr<SlowRequestCounter> NewEmptyBucket(
int64_t time_millis) override;
void ResetWindowTo(const Stat::WindowWrapSharedPtr<SlowRequestCounter>& wrap,
int64_t start_time) override;
};
class ResponseTimeCircuitBreaker : public AbstractCircuitBreaker {
public:
explicit ResponseTimeCircuitBreaker(const Rule& rule)
: AbstractCircuitBreaker(rule),
sliding_counter_(std::make_unique<SlowRequestLeapArray>(
1, rule.stat_interval_ms())) {
this->max_allowed_rt_ = rule.max_allowed_rt();
this->max_slow_request_ratio_ = rule.threshold();
}
virtual ~ResponseTimeCircuitBreaker() = default;
bool TryPass(Stat::NodeSharedPtr& node) override;
void Reset() override;
void RecordComplete(int64_t rt, const std::string& error) override;
private:
void RecordAndHandleStateChange(int64_t rt);
int32_t max_allowed_rt_;
double max_slow_request_ratio_;
const std::unique_ptr<SlowRequestLeapArray> sliding_counter_;
};
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/rule.cc
================================================
#include <string>
#include "sentinel-core/circuitbreaker/rule.h"
#include "absl/strings/str_format.h"
namespace Sentinel {
namespace CircuitBreaker {
bool CircuitBreaker::Rule::operator==(const CircuitBreaker::Rule& rule) const {
return resource_ == rule.resource() && threshold_ == rule.threshold() &&
strategy_ == rule.strategy() &&
retry_timeout_sec_ == rule.retry_timeout_sec() &&
min_request_amount_ == rule.min_request_amount() &&
stat_interval_ms_ == rule.stat_interval_ms() &&
max_allowed_rt_ == rule.max_allowed_rt();
}
std::string CircuitBreaker::Rule::ToString() const {
return absl::StrFormat(
"CircuitBreakerRule{resource=%s, strategy=%d, threshold=%.2f, "
"retry_timeout_sec=%d, min_request_amount=%d, stat_interval_ms=%d, "
"max_allowed_rt=%d}",
resource_, static_cast<int>(strategy_), threshold_, retry_timeout_sec_,
min_request_amount_, stat_interval_ms_, max_allowed_rt_);
}
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/rule.h
================================================
#pragma once
#include <functional>
#include <memory>
#include <string>
#include <unordered_set>
#include <vector>
#include "sentinel-core/common/rule.h"
namespace Sentinel {
namespace CircuitBreaker {
enum class MetricType { kResponseTime = 0, kException = 1 };
enum class Strategy { kSlowRtRatio = 0, kErrorRatio = 1, kErrorCount = 2 };
struct Rule : public Sentinel::Rule {
public:
Rule() = default;
virtual ~Rule() = default;
explicit Rule(const std::string& resource) : resource_(resource) {}
const std::string& resource() const { return resource_; }
Strategy strategy() const { return strategy_; }
double threshold() const { return threshold_; }
int32_t retry_timeout_sec() const { return retry_timeout_sec_; }
int32_t min_request_amount() const { return min_request_amount_; }
int32_t stat_interval_ms() const { return stat_interval_ms_; }
int32_t max_allowed_rt() const { return max_allowed_rt_; }
void set_resource(const std::string& resource) { resource_ = resource; }
void set_strategy(Strategy s) { strategy_ = s; }
void set_threshold(double threshold) { threshold_ = threshold; }
void set_retry_timeout_sec(int32_t retry_timeout_sec) {
retry_timeout_sec_ = retry_timeout_sec;
}
void set_min_request_amount(int32_t min_request_amount) {
min_request_amount_ = min_request_amount;
}
void set_stat_interval_ms(int32_t stat_interval_ms) {
stat_interval_ms_ = stat_interval_ms;
}
void set_max_allowed_rt(int32_t max_allowed_rt) {
max_allowed_rt_ = max_allowed_rt;
}
bool operator==(const CircuitBreaker::Rule& rule) const;
std::string ToString() const;
private:
std::string resource_;
Strategy strategy_{Strategy::kSlowRtRatio};
double threshold_ = 0;
int32_t retry_timeout_sec_ = 0;
int32_t min_request_amount_{10};
int32_t stat_interval_ms_{1000};
int32_t max_allowed_rt_{0};
};
struct RuleHash {
std::size_t operator()(const CircuitBreaker::Rule& rule) const noexcept {
std::size_t result = std::hash<std::string>{}(rule.resource());
result = 31 * result + static_cast<int>(rule.strategy());
result = 31 * result + std::hash<double>{}(rule.threshold());
result = 31 * result + rule.retry_timeout_sec();
result = 31 * result + rule.min_request_amount();
result = 31 * result + rule.stat_interval_ms();
result = 31 * result + rule.max_allowed_rt();
return result;
}
};
using RuleList = std::vector<CircuitBreaker::Rule>;
using RuleSet = std::unordered_set<CircuitBreaker::Rule, RuleHash>;
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/rule_manager.cc
================================================
#include <memory>
#include <mutex>
#include <unordered_map>
#include <unordered_set>
#include "sentinel-core/circuitbreaker/error_circuit_breaker.h"
#include "sentinel-core/circuitbreaker/rt_circuit_breaker.h"
#include "sentinel-core/circuitbreaker/rule_manager.h"
#include "sentinel-core/log/logger.h"
#include "sentinel-core/property/dynamic_sentinel_property.h"
namespace Sentinel {
namespace CircuitBreaker {
constexpr auto kPropertyListenerName = "CircuitBreakerRulePropertyListener";
bool IsValidRule(const Rule& rule) {
auto threshold = rule.threshold();
bool base_valid = !rule.resource().empty() && threshold >= 0;
if (!base_valid) {
return false;
}
if (rule.retry_timeout_sec() <= 0 || rule.stat_interval_ms() <= 0 ||
rule.min_request_amount() < 0) {
return false;
}
switch (rule.strategy()) {
case Strategy::kSlowRtRatio:
return rule.max_allowed_rt() >= 0 && threshold <= 1;
case Strategy::kErrorRatio:
return threshold <= 1;
case Strategy::kErrorCount:
return true;
default:
return false;
}
}
// RuleManager
RuleManager::RuleManager() {
cur_property_ =
std::make_shared<Property::DynamicSentinelProperty<std::vector<Rule>>>();
cur_property_->AddListener(std::make_unique<RulePropertyListener>());
}
bool RuleManager::LoadRules(const RuleList& rules) {
return cur_property_->UpdateValue(rules);
}
bool RuleManager::HasRules(const std::string& resource) {
absl::ReaderMutexLock lck(&update_mtx_);
return cb_map_.find(resource) != cb_map_.end();
}
RuleList RuleManager::GetRules() const {
absl::ReaderMutexLock lck(&update_mtx_);
RuleList list{};
for (const auto& e : rule_map_) {
list.insert(std::end(list), std::begin(e.second), std::end(e.second));
}
return list;
}
RuleSet RuleManager::GetRulesOfResource(const std::string& resource) const {
absl::ReaderMutexLock lck(&update_mtx_);
auto it = rule_map_.find(resource);
if (it == rule_map_.end()) {
return {};
}
return it->second;
}
std::vector<CircuitBreakerSharedPtr> RuleManager::GetCircuitBreakers(
const std::string& resource) const {
absl::ReaderMutexLock lck(&update_mtx_);
auto it = cb_map_.find(resource);
if (it == cb_map_.end()) {
return {};
}
return it->second;
}
void RuleManager::RegisterToProperty(const RulePropertySharedPtr& property) {
if (property == nullptr) {
return;
}
std::lock_guard<std::mutex> lck(property_mtx_);
SENTINEL_LOG(info, "Registering new property to CircuitBreakerRuleManager");
cur_property_->RemoveListener(kPropertyListenerName);
cur_property_ = property;
cur_property_->AddListener(std::make_unique<RulePropertyListener>());
}
// If the rule already exists, reuse the circuit breaker instance directly,
// otherwise generate a new instance.
CircuitBreakerSharedPtr RuleManager::GetExistingSameCbOrNew(const Rule& rule) {
auto it = cb_map_.find(rule.resource());
if (it == cb_map_.end()) {
return NewCircuitBreaker(rule);
}
auto cbs = it->second;
if (cbs.empty()) {
return NewCircuitBreaker(rule);
}
for (auto& cb : cbs) {
if (rule == cb->GetRule()) {
// Reuse the circuit breaker if the rule remains unchanged.
return cb;
}
}
return NewCircuitBreaker(rule);
}
CircuitBreakerSharedPtr RuleManager::NewCircuitBreaker(const Rule& rule) {
switch (rule.strategy()) {
case Strategy::kSlowRtRatio:
return std::make_shared<ResponseTimeCircuitBreaker>(rule);
case Strategy::kErrorRatio:
return std::make_shared<ErrorCircuitBreaker>(rule);
default:
return nullptr;
}
}
void LogRuleMap(const std::unordered_map<std::string, RuleSet>& map) {
std::string s("[");
for (const auto& e : map) {
for (const auto& rule : e.second) {
s += rule.ToString();
s += ",";
}
}
s[s.size() - 1] = ']';
SENTINEL_LOG(info, "[CircuitBreakerRuleManager] Rules received: {}", s);
}
// RulePropertyListener
CircuitBreakerMap RulePropertyListener::BuildCircuitBreakerMap(
const RuleList& list) {
CircuitBreakerMap m{};
if (list.empty()) {
return m;
}
for (auto& rule : list) {
if (!IsValidRule(rule)) {
SENTINEL_LOG(warn,
"[CircuitBreakerRuleManager] Ignoring invalid rule when "
"loading new circuit breaker rules: {}",
rule.ToString());
continue;
}
CircuitBreakerSharedPtr cb =
RuleManager::GetInstance().GetExistingSameCbOrNew(rule);
if (cb == nullptr) {
SENTINEL_LOG(warn,
"[CircuitBreakerRuleManager] Unknown circuit breaking "
"strategy, ignoring: {}",
rule.ToString());
continue;
}
auto it = m.find(rule.resource());
if (it == m.end()) {
m.insert({rule.resource(), {cb}});
} else {
auto& vec = it->second;
vec.push_back(std::move(cb));
}
}
return m;
}
void RulePropertyListener::ConfigUpdate(const RuleList& value, bool) {
RuleManager& m = RuleManager::GetInstance();
if (value.empty()) {
absl::WriterMutexLock lck(&(m.update_mtx_));
m.rule_map_.clear();
m.cb_map_.clear();
SENTINEL_LOG(info, "[CircuitBreakerRuleManager] Rules received: []");
return;
}
absl::WriterMutexLock lck(&(m.update_mtx_));
auto cbs = BuildCircuitBreakerMap(value);
std::unordered_map<std::string, RuleSet> rule_map;
for (const auto& kv : cbs) {
if (kv.second.empty()) {
continue;
}
RuleSet rules{};
for (const auto& cb : kv.second) {
rules.insert(cb->GetRule());
}
rule_map.insert({kv.first, rules});
}
m.rule_map_ = std::move(rule_map);
m.cb_map_ = std::move(cbs);
LogRuleMap(m.rule_map_);
}
const std::string RulePropertyListener::Name() const {
return kPropertyListenerName;
}
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/rule_manager.h
================================================
#pragma once
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include "absl/synchronization/mutex.h"
#include "sentinel-core/circuitbreaker/circuit_breaker.h"
#include "sentinel-core/circuitbreaker/rule.h"
#include "sentinel-core/property/property_listener.h"
#include "sentinel-core/property/sentinel_property.h"
namespace Sentinel {
namespace CircuitBreaker {
using CircuitBreakerMap =
std::unordered_map<std::string, std::vector<CircuitBreakerSharedPtr>>;
using RulePropertySharedPtr = Property::SentinelPropertySharedPtr<RuleList>;
class RuleManager {
public:
static RuleManager& GetInstance() {
static RuleManager* instance = new RuleManager();
return *instance;
}
friend class RulePropertyListener;
void RegisterToProperty(const RulePropertySharedPtr& property);
bool LoadRules(const RuleList& rules);
bool HasRules(const std::string& resource);
RuleList GetRules() const;
RuleSet GetRulesOfResource(const std::string& resource) const;
std::vector<CircuitBreakerSharedPtr> GetCircuitBreakers(
const std::string& resource) const;
private:
RuleManager();
virtual ~RuleManager() = default;
RulePropertySharedPtr cur_property_;
std::unordered_map<std::string, RuleSet> rule_map_{};
CircuitBreakerMap cb_map_{};
mutable std::mutex property_mtx_;
mutable absl::Mutex update_mtx_;
CircuitBreakerSharedPtr GetExistingSameCbOrNew(const Rule& rule);
CircuitBreakerSharedPtr NewCircuitBreaker(const Rule& rule);
};
class RulePropertyListener : public Property::PropertyListener<RuleList> {
public:
RulePropertyListener() = default;
~RulePropertyListener() = default;
void ConfigUpdate(const RuleList& value, bool first_load) override;
const std::string Name() const override;
private:
CircuitBreakerMap BuildCircuitBreakerMap(const RuleList& list);
};
bool IsValidRule(const Rule& rule);
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/slot.cc
================================================
#include "sentinel-core/circuitbreaker/slot.h"
#include "sentinel-core/circuitbreaker/rule_manager.h"
#include "sentinel-core/utils/time_utils.h"
namespace Sentinel {
namespace CircuitBreaker {
// CheckerSlot
Sentinel::Slot::TokenResultSharedPtr CheckerSlot::Entry(
const EntrySharedPtr& entry, Stat::NodeSharedPtr& node, int count, int flag,
const std::vector<absl::any>& params) {
auto cbs =
RuleManager::GetInstance().GetCircuitBreakers(entry->resource()->name());
if (cbs.empty()) {
return Sentinel::Slot::TokenResult::Ok();
}
for (auto& cb : cbs) {
if (!cb->TryPass(node)) {
return Sentinel::Slot::TokenResult::Blocked("DegradeException");
}
}
return Sentinel::Slot::TokenResult::Ok();
}
void CheckerSlot::Exit(const EntrySharedPtr& entry, int count,
const std::vector<absl::any>& params) {}
// CompleteStatSlot
Sentinel::Slot::TokenResultSharedPtr CompleteStatSlot::Entry(
const EntrySharedPtr& entry,
/*const*/ Stat::NodeSharedPtr& node, int count, int flag,
const std::vector<absl::any>& params) {
if (entry == nullptr || entry->context() == nullptr) {
return Sentinel::Slot::TokenResult::Ok();
}
auto prev_result = entry->context()->last_token_result();
if (prev_result == nullptr) {
return Sentinel::Slot::TokenResult::Ok();
}
return prev_result;
}
void CompleteStatSlot::Exit(const EntrySharedPtr& entry, int count,
const std::vector<absl::any>& params) {
if (entry == nullptr || entry->HasBlockError()) {
return;
}
auto cbs =
RuleManager::GetInstance().GetCircuitBreakers(entry->resource()->name());
if (cbs.empty()) {
return;
}
auto rt = entry->rt();
if (rt < 0) {
rt = std::max(int64_t(0), Utils::TimeUtils::CurrentTimeMillis().count() -
entry->create_time().count());
}
for (auto& cb : cbs) {
cb->RecordComplete(rt, entry->error());
}
}
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/slot.h
================================================
#pragma once
#include "sentinel-core/slot/base/rule_checker_slot.h"
#include "sentinel-core/slot/base/stats_slot.h"
namespace Sentinel {
namespace CircuitBreaker {
constexpr auto kCheckerSlotName = "CircuitBreakerCheckerSlot";
constexpr auto kCompleteStatSlotName = "CircuitBreakerCompleteStatSlot";
class CheckerSlot : public Slot::RuleCheckerSlot {
public:
CheckerSlot() = default;
virtual ~CheckerSlot() = default;
Sentinel::Slot::TokenResultSharedPtr Entry(
const EntrySharedPtr& entry, Stat::NodeSharedPtr& node, int count,
int flag, const std::vector<absl::any>& params) override;
void Exit(const EntrySharedPtr& entry, int count,
const std::vector<absl::any>& params) override;
const std::string& Name() const override { return name_; };
private:
const std::string name_{kCheckerSlotName};
};
class CompleteStatSlot : public Slot::StatsSlot {
public:
CompleteStatSlot() = default;
virtual ~CompleteStatSlot() = default;
const std::string& Name() const override { return name_; };
Sentinel::Slot::TokenResultSharedPtr Entry(
const EntrySharedPtr& entry,
/*const*/ Stat::NodeSharedPtr& node, int count, int flag,
const std::vector<absl::any>& params) override;
void Exit(const EntrySharedPtr& entry, int count,
const std::vector<absl::any>& params) override;
private:
const std::string name_{kCompleteStatSlotName};
};
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/circuitbreaker/slot_test.cc
================================================
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sentinel-core/test/mock/statistic/node/mock.h"
#include "sentinel-core/circuitbreaker/rule.h"
#include "sentinel-core/circuitbreaker/rule_manager.h"
#include "sentinel-core/circuitbreaker/slot.h"
#include "sentinel-core/common/string_resource_wrapper.h"
using testing::_;
using testing::InSequence;
using testing::Mock;
using testing::Return;
namespace Sentinel {
namespace CircuitBreaker {
Sentinel::Slot::TokenResultSharedPtr Entry_And_Exit(
CheckerSlot& slot_checker, CompleteStatSlot& slot_complete,
const EntrySharedPtr& entry, const ResourceWrapperSharedPtr& resource,
Stat::NodeSharedPtr& node, int count, int flag,
const std::vector<absl::any>& params) {
auto result = slot_checker.Entry(entry, node, count, flag, params);
EXPECT_EQ(Sentinel::Slot::TokenStatus::RESULT_STATUS_OK, result->status());
slot_complete.Entry(entry, node, count, flag, params);
slot_complete.Exit(entry, count, params);
return result;
}
TEST(CircuitBreakerSlotTest, CircuitBreakerErrorRatioTest) {
std::string resource_name{"test_resource"};
EntryContextSharedPtr context =
std::make_shared<EntryContext>("test_context");
Stat::NodeSharedPtr node = std::make_shared<Stat::MockNode>();
auto resource =
std::make_shared<StringResourceWrapper>(resource_name, EntryType::OUT);
auto entry = std::make_shared<Entry>(resource, context);
entry->set_cur_node(node);
auto entry_error = std::make_shared<Entry>(resource, context);
entry_error->set_cur_node(node);
entry_error->set_error("test_error");
const std::vector<absl::any> myParams;
CheckerSlot slot_checker;
CompleteStatSlot slot_complete;
// Test breaker checking when no rule exists.
for (int i = 0; i < 10; i++) {
Entry_And_Exit(slot_checker, slot_complete, entry, resource, node, 1, 0,
myParams);
}
Rule rule{resource_name};
rule.set_strategy(Strategy::kErrorRatio);
rule.set_threshold(0.5);
rule.set_retry_timeout_sec(1);
rule.set_stat_interval_ms(2000);
rule.set_min_request_amount(10);
RuleList rules{rule};
RuleManager& m = RuleManager::GetInstance();
m.LoadRules(rules);
auto cbs = m.GetCircuitBreakers(resource->name());
EXPECT_EQ(cbs[0]->CurrentState(), State::kClosed);
// Test breaker checking when error entry happens.
for (int i = 0; i < 10; i++) {
Entry_And_Exit(slot_checker, slot_complete, entry_error, resource, node, 1,
0, myParams);
}
EXPECT_EQ(cbs[0]->CurrentState(), State::kOpen);
// skip break time span
sleep(1);
// Switch state to kHalfOpen
auto result = slot_checker.Entry(entry, node, 1, 0, myParams);
EXPECT_EQ(Sentinel::Slot::TokenStatus::RESULT_STATUS_OK, result->status());
EXPECT_EQ(cbs[0]->CurrentState(), State::kHalfOpen);
// Switch state to kClosed
slot_complete.Entry(entry, node, 1, 0, myParams);
slot_complete.Exit(entry, 1, myParams);
EXPECT_EQ(cbs[0]->CurrentState(), State::kClosed);
m.LoadRules({});
}
TEST(CircuitBreakerSlotTest, CircuitBreakerSlowRatioTest) {
std::string resource_name{"test_resource"};
EntryContextSharedPtr context =
std::make_shared<EntryContext>("test_context");
Stat::NodeSharedPtr node = std::make_shared<Stat::MockNode>();
auto resource =
std::make_shared<StringResourceWrapper>(resource_name, EntryType::OUT);
auto entry = std::make_shared<Entry>(resource, context);
entry->set_cur_node(node);
entry->set_rt(10);
auto entry_slow = std::make_shared<Entry>(resource, context);
entry_slow->set_cur_node(node);
entry_slow->set_rt(500);
const std::vector<absl::any> myParams;
CheckerSlot slot_checker;
CompleteStatSlot slot_complete;
// Test breaker checking when no rule exists.
for (int i = 0; i < 10; i++) {
Entry_And_Exit(slot_checker, slot_complete, entry, resource, node, 1, 0,
myParams);
}
Rule rule{resource_name};
rule.set_strategy(Strategy::kSlowRtRatio);
rule.set_threshold(0.5);
rule.set_retry_timeout_sec(1);
rule.set_stat_interval_ms(10000);
rule.set_min_request_amount(10);
rule.set_max_allowed_rt(200);
RuleList rules{rule};
RuleManager& m = RuleManager::GetInstance();
m.LoadRules(rules);
auto cbs = m.GetCircuitBreakers(resource->name());
EXPECT_EQ(cbs[0]->CurrentState(), State::kClosed);
// Test breaker checking when slow entry happens.
for (int i = 0; i < 10; i++) {
Entry_And_Exit(slot_checker, slot_complete, entry_slow, resource, node, 1,
0, myParams);
}
EXPECT_EQ(cbs[0]->CurrentState(), State::kOpen);
// skip break time span
sleep(1);
// Switch state to kHalfOpen
auto result = slot_checker.Entry(entry, node, 1, 0, myParams);
EXPECT_EQ(Sentinel::Slot::TokenStatus::RESULT_STATUS_OK, result->status());
EXPECT_EQ(cbs[0]->CurrentState(), State::kHalfOpen);
// Switch state to kClosed
slot_complete.Entry(entry, node, 1, 0, myParams);
slot_complete.Exit(entry, 1, myParams);
EXPECT_EQ(cbs[0]->CurrentState(), State::kClosed);
m.LoadRules({});
}
} // namespace CircuitBreaker
} // namespace Sentinel
================================================
FILE: sentinel-core/common/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "constants",
srcs = [
"constants.h",
],
copts = DEFAULT_COPTS,
)
cc_library(
name = "global_status",
srcs = [
"global_status.h",
"global_status.cc",
],
copts = DEFAULT_COPTS,
)
cc_library(
name = "entry_type_enum",
srcs = [
"entry_type.h",
],
copts = DEFAULT_COPTS,
)
cc_library(
name = "resource_wrapper_interface",
srcs = [
"resource_wrapper.h",
],
copts = DEFAULT_COPTS,
deps = [
":entry_type_enum",
"@com_google_absl//absl/types:any",
]
)
cc_library(
name = "string_resource_wrapper_lib",
srcs = [
"string_resource_wrapper.h",
],
copts = DEFAULT_COPTS,
deps = [
":resource_wrapper_interface",
"@com_google_absl//absl/types:any",
]
)
cc_library(
name = "entry_context_lib",
srcs = [
"entry_context.h",
"entry_context.cc",
],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/statistic/node:node_interface",
"//sentinel-core/slot/base:token_result_lib",
]
)
cc_library(
name = "entry_lib",
srcs = [
"entry.h",
],
copts = DEFAULT_COPTS,
deps = [
":entry_context_lib",
":resource_wrapper_interface",
"//sentinel-core/utils:utils_lib",
]
)
cc_library(
name = "rule_lib",
srcs = [
"rule.h",
],
copts = DEFAULT_COPTS,
deps = [
":constants",
]
)
cc_library(
name = "entry_result_lib",
srcs = [
"entry_result.h",
"entry_result.cc",
],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/slot:global_slot_chain_header",
"@com_google_absl//absl/types:optional",
]
)
cc_library(
name = "tracer_lib",
srcs = [
"tracer.h",
"tracer.cc",
],
copts = DEFAULT_COPTS,
deps = [
":entry_lib",
]
)
cc_test(
name = "tracer_lib_unittests",
srcs = [
"tracer_test.cc",
],
copts = TEST_COPTS,
deps = [
":tracer_lib",
":entry_lib",
":string_resource_wrapper_lib",
"//sentinel-core/test/mock/statistic/node:mock_lib",
"@com_google_googletest//:gtest_main",
]
)
================================================
FILE: sentinel-core/common/constants.h
================================================
#pragma once
namespace Sentinel {
namespace Constants {
static constexpr int kDefaultSampleCount = 2;
static constexpr int kDefaultIntervalMs = 1000;
static constexpr const char* kLimitOriginDefault = "default";
static constexpr const char* kLimitOriginOther = "other";
static constexpr const char* kDefaultContextName = "sentinel_default_context";
static constexpr int kMaxAllowedRt = 4900;
static constexpr int kMaxResourceSize = 10000;
static constexpr int kMaxTagSize = 1000;
}; // namespace Constants
} // namespace Sentinel
================================================
FILE: sentinel-core/common/entry.h
================================================
#pragma once
#include <chrono>
#include <memory>
#include <vector>
#include "sentinel-core/common/entry_context.h"
#include "sentinel-core/common/resource_wrapper.h"
#include "sentinel-core/utils/time_utils.h"
namespace Sentinel {
class Entry {
public:
explicit Entry(const ResourceWrapperSharedPtr& resource,
const EntryContextSharedPtr& context)
: resource_(resource),
context_(context),
create_time_(Utils::TimeUtils::CurrentTimeMillis()) {}
virtual ~Entry() = default;
friend class EntryResult;
friend class SphU;
ResourceWrapperSharedPtr resource() const { return resource_; }
std::chrono::milliseconds create_time() const { return create_time_; }
EntryContextSharedPtr context() const { return context_; }
Stat::NodeSharedPtr cur_node() const { return cur_node_; }
int64_t rt() const { return rt_; }
std::vector<absl::any> params() const { return params_; }
bool exited() const { return exited_; }
std::string error() const { return error_; }
bool HasError() const { return !error_.empty(); };
bool HasBlockError() const { return !block_error_.empty(); };
void set_rt(int64_t rt) { rt_ = rt; }
void set_error(const std::string& message) { error_ = message; }
void set_block_error(const std::string& message) { block_error_ = message; }
void set_cur_node(const Stat::NodeSharedPtr& node) { cur_node_ = node; }
void set_params(const std::vector<absl::any>&& params) { params_ = params; }
private:
const ResourceWrapperSharedPtr resource_;
EntryContextSharedPtr context_;
const std::chrono::milliseconds create_time_;
bool exited_{false};
int64_t rt_{-1};
std::string error_{};
std::string block_error_{};
Stat::NodeSharedPtr cur_node_;
std::vector<absl::any> params_;
};
using EntrySharedPtr = std::shared_ptr<Entry>;
} // namespace Sentinel
================================================
FILE: sentinel-core/common/entry_context.cc
================================================
#include <string>
#include "sentinel-core/common/entry_context.h"
namespace Sentinel {} // namespace Sentinel
================================================
FILE: sentinel-core/common/entry_context.h
================================================
#pragma once
#include <memory>
#include <string>
#include "sentinel-core/slot/base/token_result.h"
#include "sentinel-core/statistic/node/node.h"
namespace Sentinel {
class EntryContext {
public:
explicit EntryContext(const std::string& name) : EntryContext(name, "") {}
EntryContext(const std::string& name, const std::string& tag)
: name_(name), tag_(tag) {}
const std::string& name() const { return name_; };
const std::string& tag() const { return tag_; };
Stat::NodeSharedPtr tag_node() { return tag_node_; }
const Slot::TokenResultSharedPtr& last_token_result() const {
return last_token_result_;
}
/**
* Users should not invoke this.
*/
void set_last_token_result(const Slot::TokenResultSharedPtr& r) {
last_token_result_ = r;
}
void set_tag_node(Stat::NodeSharedPtr& node) { tag_node_ = node; }
private:
const std::string name_;
// Maybe multiple tags in the future, using vector instead of string.
const std::string tag_;
Stat::NodeSharedPtr tag_node_;
Slot::TokenResultSharedPtr last_token_result_;
};
using EntryContextSharedPtr = std::shared_ptr<EntryContext>;
} // namespace Sentinel
================================================
FILE: sentinel-core/common/entry_node.h
================================================
================================================
FILE: sentinel-core/common/entry_result.cc
================================================
#include "sentinel-core/common/entry_result.h"
#include "sentinel-core/slot/global_slot_chain.h"
namespace Sentinel {
bool EntryResult::IsBlocked() const { return blocked_reason_.has_value(); }
bool EntryResult::Exit() { return Exit(1); }
bool EntryResult::Exit(int count) {
if (entry_ == nullptr) {
return false;
}
const std::vector<absl::any> params = entry_->params();
if (!entry_->exited()) {
Slot::SlotChainSharedPtr chain = Slot::GetGlobalSlotChain();
if (chain != nullptr) {
// NOTE: keep consistent with exit operation in SphU::Entry when blocked.
chain->Exit(entry_, count, params);
}
entry_->exited_ = true;
return true;
}
return false;
}
void EntryResult::SetError(const std::string& err) {
if (entry_ != nullptr) {
entry_->set_error(err);
}
}
} // namespace Sentinel
================================================
FILE: sentinel-core/common/entry_result.h
================================================
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "absl/types/optional.h"
#include "sentinel-core/common/entry_result.h"
#include "sentinel-core/slot/global_slot_chain.h"
namespace Sentinel {
class EntryResult {
public:
explicit EntryResult(const EntrySharedPtr& entry) : entry_(entry) {}
explicit EntryResult(const std::string& reason)
: entry_(nullptr), blocked_reason_(reason) {}
~EntryResult() = default;
EntrySharedPtr entry() const { return entry_; };
absl::optional<std::string> blocked_reason() const {
return blocked_reason_;
};
bool IsBlocked() const;
bool Exit();
bool Exit(int count);
bool Exit(int count, const std::vector<absl::any>& params);
void SetError(const std::string& err);
private:
const EntrySharedPtr entry_;
const absl::optional<std::string> blocked_reason_;
};
using EntryResultPtr = std::unique_ptr<EntryResult>;
} // namespace Sentinel
================================================
FILE: sentinel-core/common/entry_type.h
================================================
#pragma once
namespace Sentinel {
enum class EntryType { IN, OUT };
} // namespace Sentinel
================================================
FILE: sentinel-core/common/global_status.cc
================================================
namespace Sentinel {
namespace GlobalStatus {
bool activated = true;
}; // namespace GlobalStatus
} // namespace Sentinel
================================================
FILE: sentinel-core/common/global_status.h
================================================
#pragma once
namespace Sentinel {
namespace GlobalStatus {
extern bool activated;
}; // namespace GlobalStatus
} // namespace Sentinel
================================================
FILE: sentinel-core/common/resource_wrapper.h
================================================
#pragma once
#include <memory>
#include <string>
#include "absl/types/any.h"
#include "sentinel-core/common/entry_type.h"
namespace Sentinel {
class ResourceWrapper;
using ResourceWrapperSharedPtr = std::shared_ptr<ResourceWrapper>;
class ResourceWrapper {
public:
virtual ~ResourceWrapper() = default;
virtual const std::string& name() const = 0;
virtual EntryType entry_type() const = 0;
};
} // namespace Sentinel
================================================
FILE: sentinel-core/common/rule.h
================================================
#pragma once
#include <string>
#include "sentinel-core/common/constants.h"
namespace Sentinel {
class Rule {
public:
Rule() = default;
virtual ~Rule() = default;
static bool LimitOriginEquals(const std::string& lhs,
const std::string& rhs) {
if (lhs.empty()) {
return rhs.empty() || rhs == Constants::kLimitOriginDefault;
} else if (lhs == Constants::kLimitOriginDefault) {
return rhs.empty() || rhs == Constants::kLimitOriginDefault;
}
return lhs == rhs;
}
};
} // namespace Sentinel
================================================
FILE: sentinel-core/common/string_resource_wrapper.h
================================================
#pragma once
#include <string>
#include "sentinel-core/common/resource_wrapper.h"
namespace Sentinel {
class StringResourceWrapper : public ResourceWrapper {
public:
StringResourceWrapper(const std::string& name, EntryType type)
: name_(name), entry_type_(type) {}
virtual ~StringResourceWrapper() = default;
const std::string& name() const override { return name_; }
EntryType entry_type() const override { return entry_type_; }
private:
std::string name_;
EntryType entry_type_;
};
} // namespace Sentinel
================================================
FILE: sentinel-core/common/tracer.cc
================================================
#include <string>
#include "sentinel-core/common/tracer.h"
#include "sentinel-core/statistic/node/node.h"
namespace Sentinel {
void Tracer::Trace(const EntrySharedPtr entry, const std::string&, int count) {
if (entry == nullptr || count <= 0) {
return;
}
// TODO: check BlockException?
Stat::NodeSharedPtr node = entry->cur_node();
if (node != nullptr) {
node->AddExceptionRequest(count);
}
}
void Tracer::Trace(const EntrySharedPtr entry, const std::string& message) {
Tracer::Trace(entry, message, 1);
}
} // namespace Sentinel
================================================
FILE: sentinel-core/common/tracer.h
================================================
#pragma once
#include <string>
#include "sentinel-core/common/entry.h"
namespace Sentinel {
class Tracer {
public:
Tracer() = delete;
static void Trace(const EntrySharedPtr entry, const std::string& message);
static void Trace(const EntrySharedPtr entry, const std::string& message,
int count);
};
} // namespace Sentinel
================================================
FILE: sentinel-core/common/tracer_test.cc
================================================
#include <memory>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sentinel-core/common/entry.h"
#include "sentinel-core/common/string_resource_wrapper.h"
#include "sentinel-core/common/tracer.h"
#include "sentinel-core/test/mock/statistic/node/mock.h"
using testing::_;
using testing::InSequence;
using testing::Return;
namespace Sentinel {
TEST(TracerTest, TraceExceptionTest) {
{
auto node = std::make_shared<Stat::MockNode>();
int n = 10;
EXPECT_CALL(*node.get(), AddExceptionRequest(n)).Times(1);
EntrySharedPtr entry = std::make_shared<Entry>(
std::make_shared<StringResourceWrapper>("abc", EntryType::IN), nullptr);
entry->set_cur_node(node);
Tracer::Trace(entry, "some_exception", n);
}
}
} // namespace Sentinel
================================================
FILE: sentinel-core/config/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "config_constants",
srcs = [
"config_constants.h",
],
copts = DEFAULT_COPTS,
)
cc_library(
name = "local_config_lib",
srcs = [
"local_config.h",
"local_config.cc",
],
copts = DEFAULT_COPTS,
deps = [
":config_constants",
"//sentinel-core/init:init_target_interface",
"//sentinel-core/log:logger_lib",
"@com_google_absl//absl/strings",
]
)
cc_test(
name = "local_config_unittests",
srcs = [
"local_config_test.cc",
],
copts = TEST_COPTS,
deps = [
":local_config_lib",
"@com_google_googletest//:gtest_main",
]
)
================================================
FILE: sentinel-core/config/config_constants.h
================================================
#pragma once
#include <cstdint>
namespace Sentinel {
namespace Config {
const auto kUnknownAppName = "unknown_cpp_service";
constexpr uint32_t kDefaultAppType = 0;
constexpr auto kDefaultCharset = "UTF-8";
constexpr uint32_t kDefaultSingleMetricFileSize = 1024 * 1024 * 50;
const uint32_t kDefaultTotalMetricFileCount = 6;
const uint32_t kDefaultWarmUpColdFactor = 3;
const uint32_t kDefaultStatisticMaxRt = 4900;
namespace Env {
constexpr auto kAppNameKey = "CSP_SENTINEL_APP_NAME";
constexpr auto kAppTypeKey = "CSP_SENTINEL_APP_TYPE";
constexpr auto kCharsetKey = "CSP_SENTINEL_CHARSET";
constexpr auto kSingleMetricFileSizeKey =
"CSP_SENTINEL_METRIC_FILE_SINGLE_SIZE";
constexpr auto kTotalMetricFileCountKey =
"CSP_SENTINEL_METRIC_FILE_TOTAL_COUNT";
constexpr auto kWarmUpColdFactorKey = "CSP_SENTINEL_FLOW_WARMUP_COLD_FACTOR";
constexpr auto kStatisticMaxRtKey = "CSP_SENTINEL_STATISTIC_MAX_RT";
} // namespace Env
namespace Args {
constexpr auto kAppNameKey = "project.name";
constexpr auto kAppTypeKey = "csp.sentinel.app.type";
constexpr auto kCharsetKey = "csp.sentinel.charset";
constexpr auto kSingleMetricFileSizeKey =
"csp.sentinel.metric.file.single.size";
constexpr auto kTotalMetricFileCountKey =
"csp.sentinel.metric.file.total.count";
constexpr auto kWarmUpColdFactorKey = "csp.sentinel.flow.cold.factor";
constexpr auto kStatisticMaxRtKey = "csp.sentinel.statistic.max.rt";
} // namespace Args
} // namespace Config
} // namespace Sentinel
================================================
FILE: sentinel-core/config/local_config.cc
================================================
#include <cstdint>
#include "absl/strings/numbers.h"
#include "sentinel-core/config/config_constants.h"
#include "sentinel-core/config/local_config.h"
#include "sentinel-core/log/logger.h"
namespace Sentinel {
namespace Config {
LocalConfig::LocalConfig() {
// Initialize on create.
this->Initialize();
}
void LocalConfig::SetConfig(const std::string& key, const std::string& value) {
config_map_.emplace(std::make_pair(key, value));
}
void LocalConfig::SetConfigIfNotExists(const std::string& key,
const std::string& value) {
auto iter = config_map_.find(key);
if (iter != config_map_.end()) {
return;
}
SetConfig(key, value);
}
void LocalConfig::RemoveConfig(const std::string& key) {
config_map_.erase(key);
}
const std::string LocalConfig::GetConfig(const std::string& key) const {
auto iter = config_map_.find(key);
if (iter == config_map_.end()) {
return std::string();
}
return iter->second;
}
int32_t LocalConfig::GetInt32(const std::string& key,
int32_t default_value) const {
auto v = GetConfig(key);
if (v.empty()) {
return default_value;
}
int32_t x;
if (!absl::SimpleAtoi(v, &x)) {
x = default_value;
}
return x;
}
int64_t LocalConfig::GetInt64(const std::string& key,
int64_t default_value) const {
auto v = GetConfig(key);
if (v.empty()) {
return default_value;
}
int64_t x;
if (!absl::SimpleAtoi(v, &x)) {
x = default_value;
}
return x;
}
int32_t LocalConfig::WarmUpColdFactor() const {
int cold_factor =
GetInt32(Env::kWarmUpColdFactorKey, kDefaultWarmUpColdFactor);
if (cold_factor <= 1) {
SENTINEL_LOG(
info,
"Invalid cold_factor <{}>, fallback with the default cold factor <{}>",
cold_factor, kDefaultWarmUpColdFactor);
cold_factor = kDefaultWarmUpColdFactor;
}
return cold_factor;
}
int32_t LocalConfig::StatisticMaxRt() const {
int max_rt = GetInt32(Env::kStatisticMaxRtKey, kDefaultStatisticMaxRt);
if (max_rt < 0) {
max_rt = kDefaultStatisticMaxRt;
}
return max_rt;
}
int32_t LocalConfig::TotalMetricFileCount() const {
return GetInt32(Env::kTotalMetricFileCountKey, kDefaultTotalMetricFileCount);
}
int64_t LocalConfig::SingleMetricFileSize() const {
return GetInt64(Env::kSingleMetricFileSizeKey, kDefaultSingleMetricFileSize);
}
const std::string LocalConfig::Charset() const {
return GetConfig(Env::kCharsetKey);
}
void LocalConfig::ResolveAppName() {
const char* app_name_env = std::getenv(Env::kAppNameKey);
if (app_name_env) {
app_name_ = app_name_env;
SENTINEL_LOG(info, "App name resolved: {}", app_name_);
} else {
app_name_ = kUnknownAppName;
SENTINEL_LOG(warn, "No {} configured, using the fallback app name: {}",
Env::kAppNameKey, kUnknownAppName);
}
}
void LocalConfig::Initialize() {
ResolveAppName();
config_map_.emplace(std::make_pair(Env::kCharsetKey, kDefaultCharset));
config_map_.emplace(
std::make_pair(Env::kSingleMetricFileSizeKey,
std::to_string(kDefaultSingleMetricFileSize)));
config_map_.emplace(
std::make_pair(Env::kTotalMetricFileCountKey,
std::to_string(kDefaultTotalMetricFileCount)));
config_map_.emplace(std::make_pair(Env::kWarmUpColdFactorKey,
std::to_string(kDefaultWarmUpColdFactor)));
config_map_.emplace(std::make_pair(Env::kStatisticMaxRtKey,
std::to_string(kDefaultStatisticMaxRt)));
}
} // namespace Config
} // namespace Sentinel
================================================
FILE: sentinel-core/config/local_config.h
================================================
#pragma once
#include <string>
#include <unordered_map>
#include "sentinel-core/init/init_target.h"
namespace Sentinel {
namespace Config {
class LocalConfig {
public:
~LocalConfig() = default;
static LocalConfig& GetInstance() {
static LocalConfig* instance = new LocalConfig();
return *instance;
}
const std::string GetConfig(const std::string& key) const;
void SetConfig(const std::string& key, const std::string& value);
void SetConfigIfNotExists(const std::string& key, const std::string& value);
void RemoveConfig(const std::string& key);
int32_t GetInt32(const std::string& key, int32_t default_value) const;
int64_t GetInt64(const std::string& key, int64_t default_value) const;
const std::string& app_name() const { return app_name_; }
void set_app_name(const std::string& app_name) { app_name_ = app_name; }
int32_t WarmUpColdFactor() const;
int32_t StatisticMaxRt() const;
int32_t TotalMetricFileCount() const;
int64_t SingleMetricFileSize() const;
const std::string Charset() const;
private:
std::unordered_map<std::string, std::string> config_map_;
std::string app_name_;
LocalConfig();
void ResolveAppName();
void Initialize();
};
} // namespace Config
} // namespace Sentinel
================================================
FILE: sentinel-core/config/local_config_test.cc
================================================
#include <cstdint>
#include <string>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sentinel-core/config/config_constants.h"
#include "sentinel-core/config/local_config.h"
namespace Sentinel {
namespace Config {
TEST(LocalConfigTest, TestResolveNormalAppName) {
auto app_name = "test_app";
setenv(Env::kAppNameKey, app_name, 1);
LocalConfig config = LocalConfig::GetInstance();
EXPECT_EQ(app_name, config.app_name());
unsetenv(Env::kAppNameKey);
}
TEST(LocalConfigTest, TestGetIntOfInvalidValue) {
LocalConfig config = LocalConfig::GetInstance();
constexpr auto key = "some_key_bad";
config.SetConfig(key, "a32");
constexpr int32_t d = 32;
EXPECT_EQ(d, config.GetInt32(key, d));
}
TEST(LocalConfigTest, TestGetIntOfNormalValue) {
LocalConfig config = LocalConfig::GetInstance();
constexpr auto key = "some_key_good";
config.SetConfig(key, "64");
constexpr int32_t d = 32;
EXPECT_EQ(64, config.GetInt32(key, d));
}
} // namespace Config
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "flow_rule_constants_lib",
srcs = [
"flow_rule_constants.h",
],
copts = DEFAULT_COPTS
)
cc_library(
name = "flow_rule_lib",
srcs = [
"flow_rule.h",
"flow_rule.cc",
],
copts = DEFAULT_COPTS,
deps = [
"@com_google_absl//absl/strings:str_format",
":flow_rule_constants_lib",
"//sentinel-core/common:rule_lib",
]
)
cc_library(
name = "flow_rule_manager_lib",
srcs = [
"flow_rule_manager.h",
"flow_rule_manager.cc",
],
copts = DEFAULT_COPTS,
deps = [
":flow_rule_constants_lib",
":flow_rule_lib",
":traffic_shaping_controller_lib",
":default_traffic_shaping_calculator_lib",
":default_traffic_shaping_checker_lib",
"//sentinel-core/property:property_listener_interface",
"//sentinel-core/property:dynamic_sentinel_property_lib",
"@com_google_absl//absl/synchronization",
]
)
cc_library(
name = "flow_rule_checker_lib",
srcs = [
"flow_rule_checker.h",
"flow_rule_checker.cc",
],
copts = DEFAULT_COPTS,
deps = [
":flow_rule_manager_lib",
"//sentinel-core/common:entry_lib",
"//sentinel-core/statistic/node:resource_node_storage_lib",
]
)
cc_library(
name = "flow_slot_lib",
srcs = [
"flow_slot.h",
"flow_slot.cc",
],
copts = DEFAULT_COPTS,
deps = [
":flow_rule_checker_lib",
"//sentinel-core/slot/base:rule_checker_slot_interface",
]
)
cc_library(
name = "traffic_shaping_calculator_interface",
srcs = [
"traffic_shaping_calculator.h",
],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/statistic/node:node_interface",
]
)
cc_library(
name = "traffic_shaping_checker_interface",
srcs = [
"traffic_shaping_checker.h",
],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/statistic/node:node_interface",
"//sentinel-core/slot/base:token_result_lib"
]
)
cc_library(
name = "default_traffic_shaping_calculator_lib",
srcs = [
"default_traffic_shaping_calculator.h",
"default_traffic_shaping_calculator.cc",
],
copts = DEFAULT_COPTS,
deps = [
":traffic_shaping_calculator_interface",
]
)
cc_library(
name = "default_traffic_shaping_checker_lib",
srcs = [
"default_traffic_shaping_checker.h",
"default_traffic_shaping_checker.cc",
],
copts = DEFAULT_COPTS,
deps = [
":flow_rule_constants_lib",
":traffic_shaping_checker_interface",
]
)
cc_library(
name = "throttling_traffic_shaping_checker_lib",
srcs = [
"throttling_traffic_shaping_checker.h",
"throttling_traffic_shaping_checker.cc",
],
copts = DEFAULT_COPTS,
deps = [
":flow_rule_constants_lib",
":traffic_shaping_checker_interface",
"//sentinel-core/utils:utils_lib",
]
)
cc_library(
name = "traffic_shaping_controller_lib",
srcs = [
"traffic_shaping_controller.h",
"traffic_shaping_controller.cc",
],
copts = DEFAULT_COPTS,
deps = [
":flow_rule_constants_lib",
":traffic_shaping_checker_interface",
":traffic_shaping_calculator_interface",
]
)
cc_test(
name = "traffic_shaping_controller_unittests",
srcs = [
"traffic_shaping_controller_test.cc",
],
copts = TEST_COPTS,
deps = [
":default_traffic_shaping_calculator_lib",
":default_traffic_shaping_checker_lib",
":traffic_shaping_controller_lib",
"//sentinel-core/test/mock/flow:flow_mock_lib",
"//sentinel-core/test/mock/statistic/node:mock_lib",
"@com_google_googletest//:gtest_main",
]
)
cc_test(
name = "flow_slot_unittests",
srcs = [
"flow_slot_test.cc",
],
copts = TEST_COPTS,
deps = [
":flow_slot_lib",
"//sentinel-core/common:string_resource_wrapper_lib",
"//sentinel-core/test/mock/statistic/node:mock_lib",
"@com_google_googletest//:gtest_main",
]
)
================================================
FILE: sentinel-core/flow/default_traffic_shaping_calculator.cc
================================================
#include "sentinel-core/flow/default_traffic_shaping_calculator.h"
namespace Sentinel {
namespace Flow {
double DefaultTrafficShapingCalculator::CalculateAllowedTokens(
const Stat::NodeSharedPtr&, int, int) {
return threshold_;
}
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/default_traffic_shaping_calculator.h
================================================
#pragma once
#include "sentinel-core/flow/traffic_shaping_calculator.h"
namespace Sentinel {
namespace Flow {
class DefaultTrafficShapingCalculator : public TrafficShapingCalculator {
public:
DefaultTrafficShapingCalculator(double t) : threshold_(t) {}
virtual ~DefaultTrafficShapingCalculator() = default;
double CalculateAllowedTokens(const Stat::NodeSharedPtr& node,
int acquire_count, int flag) override;
private:
const double threshold_;
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/default_traffic_shaping_checker.cc
================================================
#include "sentinel-core/flow/default_traffic_shaping_checker.h"
#include "sentinel-core/flow/flow_rule_constants.h"
namespace Sentinel {
namespace Flow {
Slot::TokenResultSharedPtr DefaultTrafficShapingChecker::DoCheck(
const Stat::NodeSharedPtr& node, int acquire_count, double threshold) {
double cur_pass = 0;
if (node != nullptr) {
cur_pass = mode_ == (int)FlowMetricType::kThreadCount ? node->CurThreadNum()
: node->PassQps();
}
if (cur_pass + acquire_count > threshold) {
return Slot::TokenResult::Blocked("FlowException");
}
return Slot::TokenResult::Ok();
}
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/default_traffic_shaping_checker.h
================================================
#pragma once
#include "sentinel-core/flow/flow_rule_constants.h"
#include "sentinel-core/flow/traffic_shaping_checker.h"
namespace Sentinel {
namespace Flow {
class DefaultTrafficShapingChecker : public TrafficShapingChecker {
public:
explicit DefaultTrafficShapingChecker(int mode) : mode_(mode) {}
explicit DefaultTrafficShapingChecker(FlowMetricType mode)
: mode_((int)mode) {}
virtual ~DefaultTrafficShapingChecker() = default;
Slot::TokenResultSharedPtr DoCheck(const Stat::NodeSharedPtr& node,
int acquire_count,
double threshold) override;
private:
const int mode_;
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_rule.cc
================================================
#include <string>
#include "sentinel-core/flow/flow_rule.h"
#include "absl/strings/str_format.h"
namespace Sentinel {
namespace Flow {
bool FlowRule::operator==(const FlowRule& rule) const {
return resource_ == rule.resource() &&
Rule::LimitOriginEquals(limit_origin_, rule.limit_origin()) &&
metric_type_ == rule.metric_type() && count_ == rule.count() &&
strategy_ == rule.strategy() && ref_resource_ == rule.ref_resource() &&
control_behavior_ == rule.control_behavior() &&
warm_up_period_sec_ == rule.warm_up_period_sec() &&
max_queueing_time_ms_ == rule.max_queueing_time_ms() &&
cluster_mode_ == rule.cluster_mode();
}
std::string FlowRule::ToString() const {
return absl::StrFormat(
"FlowRule{resource=%s, limit_origin=%s, metric_type=%d, count=%.2f, "
"strategy=%d, ref_resource=%s, control_behavior=%d, "
"warm_up_period_sec=%d, max_queueing_time_ms=%d, cluster_mode=%d}",
resource_, limit_origin_, static_cast<int>(metric_type_), count_,
static_cast<int>(strategy_), ref_resource_,
static_cast<int>(control_behavior_), warm_up_period_sec_,
max_queueing_time_ms_, cluster_mode_);
}
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_rule.h
================================================
#pragma once
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include "sentinel-core/common/constants.h"
#include "sentinel-core/common/rule.h"
#include "sentinel-core/flow/flow_rule_constants.h"
namespace Sentinel {
namespace Flow {
struct FlowRule : public Rule {
public:
FlowRule() = default;
virtual ~FlowRule() = default;
explicit FlowRule(const std::string& resource)
: resource_(resource), limit_origin_(Constants::kLimitOriginDefault) {}
FlowRule(const std::string& resource, const std::string& limit_origin)
: resource_(resource), limit_origin_(limit_origin) {}
const std::string& resource() const { return resource_; }
const std::string& limit_origin() const { return limit_origin_; }
FlowMetricType metric_type() const { return metric_type_; }
double count() const { return count_; }
FlowRelationStrategy strategy() const { return strategy_; }
const std::string& ref_resource() const { return ref_resource_; }
FlowControlBehavior control_behavior() const { return control_behavior_; }
int32_t warm_up_period_sec() const { return warm_up_period_sec_; }
int32_t max_queueing_time_ms() const { return max_queueing_time_ms_; }
bool cluster_mode() const { return cluster_mode_; }
void set_resource(const std::string& resource) { resource_ = resource; }
void set_limit_origin(const std::string& limit_origin) {
limit_origin_ = limit_origin;
}
void set_limit_origin(const char* limit_origin) {
if (limit_origin != nullptr) {
limit_origin_ = limit_origin;
}
}
void set_metric_type(FlowMetricType metric_type) {
metric_type_ = metric_type;
}
void set_count(double count) { count_ = count; }
void set_strategy(FlowRelationStrategy strategy) { strategy_ = strategy; }
void set_ref_resource(const std::string& r) { ref_resource_ = r; }
void set_control_behavior(FlowControlBehavior cb) { control_behavior_ = cb; }
void set_warm_up_period_sec(int32_t w) { warm_up_period_sec_ = w; }
void set_max_queueing_time_ms(int32_t q) { max_queueing_time_ms_ = q; }
void set_cluster_mode(bool cluster_mode) { cluster_mode_ = cluster_mode; }
bool operator==(const FlowRule& rule) const;
std::string ToString() const;
private:
std::string resource_; // resource
std::string limit_origin_{Constants::kLimitOriginDefault}; // limitApp
FlowMetricType metric_type_{FlowMetricType::kQps}; // grade
double count_ = 0; // count
FlowRelationStrategy strategy_{FlowRelationStrategy::kDirect}; // strategy
FlowControlBehavior control_behavior_{
FlowControlBehavior::kReject}; // controlBehavior
std::string ref_resource_{}; // refResource
int32_t warm_up_period_sec_ = 10; // warmUpPeriodSec
int32_t max_queueing_time_ms_ = 500; // maxQueueingTimeMs
bool cluster_mode_ = false; // clusterMode
};
using FlowRulePtr = std::shared_ptr<FlowRule>;
using FlowRuleList = std::vector<FlowRule>;
struct FlowRuleHash {
std::size_t operator()(const FlowRule& rule) const noexcept {
std::size_t result = std::hash<std::string>{}(rule.resource());
const std::string& limit_origin = rule.limit_origin();
if (!limit_origin.empty() &&
limit_origin != Constants::kLimitOriginDefault) {
result = 31 * result + std::hash<std::string>{}(limit_origin);
}
result = 31 * result + static_cast<int>(rule.metric_type());
result = 31 * result + std::hash<double>{}(rule.count());
result = 31 * result + static_cast<int>(rule.strategy());
result = 31 * result + static_cast<int>(rule.control_behavior());
result = 31 * result + std::hash<std::string>{}(rule.ref_resource());
result = 31 * result + rule.warm_up_period_sec();
result = 31 * result + rule.max_queueing_time_ms();
result = 31 * result + std::hash<bool>{}(rule.cluster_mode());
return result;
}
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_rule_checker.cc
================================================
#include "sentinel-core/flow/flow_rule_checker.h"
#include "sentinel-core/flow/flow_rule_constants.h"
#include "sentinel-core/flow/flow_rule_manager.h"
#include "sentinel-core/statistic/node/resource_node_storage.h"
namespace Sentinel {
namespace Flow {
Slot::TokenResultSharedPtr FlowRuleChecker::CanPassCheck(
const FlowRule& rule, const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node, int count, int flag) {
if (rule.limit_origin().empty()) {
return Slot::TokenResult::Ok();
}
// if (rule.cluster_mode()) {
// return PassClusterCheck();
// }
return PassLocalCheck(rule, entry, node, count, flag);
}
Slot::TokenResultSharedPtr FlowRuleChecker::CanPassCheck(
const FlowRule& rule, const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node, int count) {
return CanPassCheck(rule, entry, node, count, 0);
}
Slot::TokenResultSharedPtr FlowRuleChecker::PassLocalCheck(
const FlowRule& rule, const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node, int count, int flag) {
Stat::NodeSharedPtr selected_node =
selectNodeByRequesterAndStrategy(rule, entry, node);
if (selected_node == nullptr) {
return Slot::TokenResult::Ok();
}
auto controller =
FlowRuleManager::GetInstance().GetTrafficControllerFor(rule);
if (controller == nullptr) {
return Slot::TokenResult::Ok();
}
return controller->CanPass(selected_node, count, flag);
}
Stat::NodeSharedPtr FlowRuleChecker::selectNodeByRequesterAndStrategy(
const FlowRule& rule, const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node) {
FlowRuleManager& m = FlowRuleManager::GetInstance();
std::string tag = entry->context()->tag();
std::string limit_origin = rule.limit_origin();
FlowRelationStrategy strategy = rule.strategy();
Stat::NodeSharedPtr tag_node = entry->context()->tag_node();
if ((tag == limit_origin) && IsValidTag(tag)) {
if (strategy == FlowRelationStrategy::kDirect) {
// When tag matches, return tag node.
return tag_node;
}
return SelectNodeByRelStrategy(rule, entry, node);
} else if (limit_origin == Constants::kLimitOriginDefault) {
if (strategy == FlowRelationStrategy::kDirect) {
// When rule contains default tag, which means all request should follow
// rule's limit count.
return node;
}
return SelectNodeByRelStrategy(rule, entry, node);
} else if ((limit_origin == Constants::kLimitOriginOther) &&
m.IsTagNotInFlowRuleList(rule.resource(), tag)) {
if (strategy == FlowRelationStrategy::kDirect) {
// When rule contains other tag, which means all request except this tag
// should follow this rule.
return tag_node;
}
return SelectNodeByRelStrategy(rule, entry, node);
}
return nullptr;
}
Stat::NodeSharedPtr FlowRuleChecker::SelectNodeByRelStrategy(
const FlowRule& rule, const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node) {
const std::string& ref_resource = rule.ref_resource();
auto rel_strategy = rule.strategy();
if (!ref_resource.empty() &&
rel_strategy == FlowRelationStrategy::kAssociatedResource) {
return Stat::ResourceNodeStorage::GetInstance().GetClusterNode(
ref_resource);
}
return node;
}
bool FlowRuleChecker::IsValidTag(const std::string& tag) {
return !tag.empty() && (tag != Constants::kLimitOriginDefault) &&
(tag != Constants::kLimitOriginOther);
}
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_rule_checker.h
================================================
#pragma once
#include "sentinel-core/common/entry.h"
#include "sentinel-core/flow/flow_rule.h"
#include "sentinel-core/slot/base/token_result.h"
namespace Sentinel {
namespace Flow {
class FlowRuleChecker {
public:
FlowRuleChecker() = default;
~FlowRuleChecker() = default;
Slot::TokenResultSharedPtr CanPassCheck(const FlowRule& rule,
const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node,
int count);
Slot::TokenResultSharedPtr CanPassCheck(const FlowRule& rule,
const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node,
int count, int flag);
private:
Slot::TokenResultSharedPtr PassLocalCheck(const FlowRule& rule,
const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node,
int count, int flag);
Stat::NodeSharedPtr selectNodeByRequesterAndStrategy(
const FlowRule& rule, const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node);
Stat::NodeSharedPtr SelectNodeByRelStrategy(const FlowRule& rule,
const EntrySharedPtr& entry,
const Stat::NodeSharedPtr& node);
bool IsValidTag(const std::string& tag);
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_rule_constants.h
================================================
#pragma once
namespace Sentinel {
namespace Flow {
enum class FlowMetricType {
kThreadCount = 0,
kQps = 1 // default mode
};
enum class FlowRelationStrategy {
kDirect = 0, // default relation strategy
kAssociatedResource = 1,
kInvocationChainEntrance = 2
};
enum class FlowControlBehavior {
kReject = 0, // default behavior
kWarmUp = 1,
kThrotting = 2,
kWarmUpThrottling = 3
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_rule_manager.cc
================================================
#include <memory>
#include <mutex>
#include <unordered_map>
#include <unordered_set>
#include "sentinel-core/flow/default_traffic_shaping_calculator.h"
#include "sentinel-core/flow/default_traffic_shaping_checker.h"
#include "sentinel-core/flow/flow_rule_manager.h"
#include "sentinel-core/log/logger.h"
#include "sentinel-core/property/dynamic_sentinel_property.h"
namespace Sentinel {
namespace Flow {
constexpr auto kFlowPropertyListenerName = "FlowPropertyListener";
bool IsValidRule(const FlowRule& rule) {
bool base_valid = !rule.resource().empty() && rule.count() >= 0;
if (!base_valid) {
return false;
}
// Check rel strategy.
bool rel = rule.strategy() == FlowRelationStrategy::kAssociatedResource ||
rule.strategy() == FlowRelationStrategy::kInvocationChainEntrance;
bool rel_valid = !rel || !rule.ref_resource().empty();
// Check control behavior.
bool cb_valid;
switch (rule.control_behavior()) {
case FlowControlBehavior::kWarmUp:
cb_valid = rule.warm_up_period_sec() > 0;
break;
case FlowControlBehavior::kThrotting:
cb_valid = rule.max_queueing_time_ms() > 0;
break;
default:
cb_valid = true;
}
return rel_valid && cb_valid;
}
std::shared_ptr<TrafficShapingController> CreateDefaultController(
const FlowRule& rule) {
return std::make_shared<TrafficShapingController>(
std::make_unique<DefaultTrafficShapingCalculator>(rule.count()),
std::make_unique<DefaultTrafficShapingChecker>(rule.metric_type()));
}
// FlowRuleManager
FlowRuleManager::FlowRuleManager() {
cur_property_ = std::make_shared<
Property::DynamicSentinelProperty<std::vector<FlowRule>>>();
cur_property_->AddListener(std::make_unique<FlowPropertyListener>());
}
bool FlowRuleManager::LoadRules(const FlowRuleList& rules) {
return cur_property_->UpdateValue(rules);
}
bool FlowRuleManager::HasRules(const std::string& resource) {
absl::ReaderMutexLock lck(&update_mtx_);
return rule_map_.find(resource) != rule_map_.end();
}
FlowRuleList FlowRuleManager::GetRules() const {
absl::ReaderMutexLock lck(&update_mtx_);
FlowRuleList list{};
for (const auto& e : rule_map_) {
list.insert(std::end(list), std::begin(e.second), std::end(e.second));
}
return list;
}
FlowRuleList FlowRuleManager::GetRulesForResource(
const std::string& resource) const {
absl::ReaderMutexLock lck(&update_mtx_);
auto it = rule_map_.find(resource);
if (it == rule_map_.end()) {
return {};
}
return it->second;
}
std::shared_ptr<TrafficShapingController>
FlowRuleManager::GetTrafficControllerFor(const FlowRule& rule) const {
absl::ReaderMutexLock lck(&update_mtx_);
auto it = traffic_controller_map_.find(rule);
if (it == traffic_controller_map_.end()) {
return nullptr;
}
return it->second;
}
void FlowRuleManager::RegisterToProperty(
const FlowRulePropertySharedPtr& property) {
if (property == nullptr) {
return;
}
std::lock_guard<std::mutex> lck(property_mtx_);
SENTINEL_LOG(info, "Registering new property to FlowRuleManager");
cur_property_->RemoveListener(kFlowPropertyListenerName);
cur_property_ = property;
cur_property_->AddListener(std::make_unique<FlowPropertyListener>());
}
std::shared_ptr<TrafficShapingController> FlowRuleManager::GenerateController(
const FlowRule& rule) {
if (rule.metric_type() == FlowMetricType::kQps) {
switch (rule.control_behavior()) {
case FlowControlBehavior::kWarmUp:
// return (WarmUpCalculator, DefaultChecker);
case FlowControlBehavior::kThrotting:
// return (DefaultCalculator, ThrottlingChecker);
default:
// Default mode or unknown mode: default traffic shaping controller
return CreateDefaultController(rule);
}
}
return CreateDefaultController(rule);
}
bool FlowRuleManager::IsTagNotInFlowRuleList(const std::string& resource_name,
const std::string& tag) {
if (tag.empty()) {
return false;
}
absl::ReaderMutexLock lck(&update_mtx_);
auto got = rule_map_.find(resource_name);
if (got == rule_map_.end()) {
return true;
}
for (const auto rule : got->second) {
if (rule.limit_origin() == tag) {
return false;
}
}
return true;
}
// FlowPropertyListener
void LogFlowMap(const std::unordered_map<std::string, FlowRuleList>& map) {
std::string s("[");
for (const auto& e : map) {
for (const auto& rule : e.second) {
s += rule.ToString();
s += ",";
}
}
s[s.size() - 1] = ']';
SENTINEL_LOG(info, "[FlowRuleManager] Flow rules received: {}", s);
}
void FlowPropertyListener::ConfigUpdate(const FlowRuleList& value, bool) {
FlowRuleManager& m = FlowRuleManager::GetInstance();
if (value.empty()) {
absl::WriterMutexLock lck(&(m.update_mtx_));
m.rule_map_.clear();
m.traffic_controller_map_.clear();
SENTINEL_LOG(info, "[FlowRuleManager] Flow rules received: []");
return;
}
std::unordered_set<FlowRule, FlowRuleHash> tmp_set;
for (const auto& rule : value) {
if (!IsValidRule(rule)) {
SENTINEL_LOG(
info,
"[FlowRuleManager] Ignoring invalid flow rule when loading new flow "
"rules: {}",
rule.ToString());
continue;
}
FlowRule f_rule = rule;
if (f_rule.limit_origin().empty()) {
f_rule.set_limit_origin(Constants::kLimitOriginDefault);
}
tmp_set.insert(std::move(f_rule));
}
std::unordered_map<std::string, FlowRuleList> new_rule_map;
TrafficControllerMap new_controller_map;
for (const auto& rule : tmp_set) {
new_controller_map.insert({rule, m.GenerateController(rule)});
auto it = new_rule_map.find(rule.resource());
if (it == new_rule_map.end()) {
new_rule_map.insert({rule.resource(), {rule}});
} else {
auto& vec = it->second;
vec.push_back(std::move(rule));
}
}
absl::WriterMutexLock lck(&(m.update_mtx_));
m.rule_map_ = std::move(new_rule_map);
m.traffic_controller_map_ = std::move(new_controller_map);
LogFlowMap(m.rule_map_);
}
const std::string FlowPropertyListener::Name() const {
return kFlowPropertyListenerName;
}
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_rule_manager.h
================================================
#pragma once
#include <mutex>
#include <string>
#include <unordered_map>
#include <vector>
#include "absl/synchronization/mutex.h"
#include "sentinel-core/flow/flow_rule.h"
#include "sentinel-core/flow/traffic_shaping_controller.h"
#include "sentinel-core/property/property_listener.h"
#include "sentinel-core/property/sentinel_property.h"
namespace Sentinel {
namespace Flow {
using TrafficControllerMap =
std::unordered_map<FlowRule, std::shared_ptr<TrafficShapingController>,
FlowRuleHash>;
using FlowRulePropertySharedPtr =
Property::SentinelPropertySharedPtr<FlowRuleList>;
class FlowRuleManager {
public:
static FlowRuleManager& GetInstance() {
static FlowRuleManager* instance = new FlowRuleManager();
return *instance;
}
friend class FlowPropertyListener;
void RegisterToProperty(const FlowRulePropertySharedPtr& property);
bool LoadRules(const FlowRuleList& rules);
bool HasRules(const std::string& resource);
FlowRuleList GetRules() const;
FlowRuleList GetRulesForResource(const std::string& resource) const;
std::shared_ptr<TrafficShapingController> GetTrafficControllerFor(
const FlowRule& rule) const;
bool IsTagNotInFlowRuleList(const std::string& resource_name,
const std::string& tag);
private:
FlowRuleManager();
FlowRulePropertySharedPtr cur_property_;
std::unordered_map<std::string, FlowRuleList> rule_map_{};
TrafficControllerMap traffic_controller_map_{};
mutable std::mutex property_mtx_;
mutable absl::Mutex update_mtx_;
std::shared_ptr<TrafficShapingController> GenerateController(
const FlowRule& rule);
};
class FlowPropertyListener : public Property::PropertyListener<FlowRuleList> {
public:
FlowPropertyListener() = default;
~FlowPropertyListener() = default;
void ConfigUpdate(const FlowRuleList& value, bool first_load) override;
const std::string Name() const override;
};
bool IsValidRule(const FlowRule& rule);
std::shared_ptr<TrafficShapingController> CreateDefaultController(
const FlowRule& rule);
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_slot.cc
================================================
#include <thread>
#include "sentinel-core/flow/flow_rule_manager.h"
#include "sentinel-core/flow/flow_slot.h"
namespace Sentinel {
namespace Slot {
const std::string& FlowSlot::Name() const { return name_; }
TokenResultSharedPtr FlowSlot::Entry(const EntrySharedPtr& entry,
Stat::NodeSharedPtr& node, int count,
int flag,
const std::vector<absl::any>& params) {
std::vector<Flow::FlowRule> rules =
Flow::FlowRuleManager::GetInstance().GetRulesForResource(
entry->resource()->name());
if (!rules.empty()) {
for (const auto& rule : rules) {
// check in order
const TokenResultSharedPtr res =
checker_.CanPassCheck(rule, entry, node, count, flag);
if (res->status() == TokenStatus::RESULT_STATUS_BLOCKED) {
return res;
}
if (res->status() == TokenStatus::RESULT_STATUS_SHOULD_WAIT) {
if (res->wait_ms().has_value() && res->wait_ms().value().count() > 0) {
std::this_thread::sleep_for(res->wait_ms().value());
continue;
}
}
}
}
return TokenResult::Ok();
}
void FlowSlot::Exit(const EntrySharedPtr&, int,
const std::vector<absl::any>& params) {
// Do nothing
}
} // namespace Slot
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_slot.h
================================================
#pragma once
#include <thread>
#include "sentinel-core/flow/flow_rule_checker.h"
#include "sentinel-core/slot/base/rule_checker_slot.h"
namespace Sentinel {
namespace Slot {
constexpr auto kFlowSlotName = "FlowSlot";
class FlowSlot : public RuleCheckerSlot {
public:
FlowSlot() = default;
virtual ~FlowSlot() = default;
TokenResultSharedPtr Entry(const EntrySharedPtr& entry,
Stat::NodeSharedPtr& node, int count, int flag,
const std::vector<absl::any>& params) override;
void Exit(const EntrySharedPtr& entry, int count,
const std::vector<absl::any>& params) override;
const std::string& Name() const override;
private:
const std::string name_{kFlowSlotName};
Flow::FlowRuleChecker checker_{};
};
} // namespace Slot
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/flow_slot_test.cc
================================================
#include <memory>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sentinel-core/test/mock/statistic/node/mock.h"
#include "sentinel-core/common/string_resource_wrapper.h"
#include "sentinel-core/flow/flow_rule.h"
#include "sentinel-core/flow/flow_rule_manager.h"
#include "sentinel-core/flow/flow_slot.h"
using testing::_;
using testing::InSequence;
using testing::Mock;
using testing::Return;
namespace Sentinel {
namespace Slot {
TEST(FlowSlotTest, FlowControlSingleThreadIntegrationTest) {
std::string resource_name{"test_resource"};
EntryContextSharedPtr context =
std::make_shared<EntryContext>("test_context");
Stat::NodeSharedPtr node = std::make_shared<Stat::MockNode>();
auto resource =
std::make_shared<StringResourceWrapper>(resource_name, EntryType::OUT);
auto entry = std::make_shared<Entry>(resource, context);
entry->set_cur_node(node);
const std::vector<absl::any> myParams;
FlowSlot slot;
{
// Test flow checking when no rule exists.
auto result = slot.Entry(entry, node, 1000, 0, myParams);
EXPECT_EQ(TokenStatus::RESULT_STATUS_OK, result->status());
}
Flow::FlowRule rule{resource_name};
rule.set_count(1);
Flow::FlowRuleList rules{rule};
Flow::FlowRuleManager& m = Flow::FlowRuleManager::GetInstance();
m.LoadRules(rules);
{
InSequence s;
EXPECT_CALL(*(static_cast<Stat::MockNode*>(node.get())), PassQps())
.WillOnce(Return(0));
EXPECT_EQ(TokenStatus::RESULT_STATUS_OK,
slot.Entry(entry, node, 1, 0, myParams)->status());
Mock::VerifyAndClearExpectations(node.get());
}
{
EXPECT_CALL(*(static_cast<Stat::MockNode*>(node.get())), PassQps())
.WillOnce(Return(0));
EXPECT_EQ(TokenStatus::RESULT_STATUS_BLOCKED,
slot.Entry(entry, node, 2, 0, myParams)->status());
Mock::VerifyAndClearExpectations(node.get());
}
{
EXPECT_CALL(*(static_cast<Stat::MockNode*>(node.get())), PassQps())
.WillOnce(Return(1));
EXPECT_EQ(TokenStatus::RESULT_STATUS_BLOCKED,
slot.Entry(entry, node, 1, 0, myParams)->status());
Mock::VerifyAndClearExpectations(node.get());
}
m.LoadRules({});
}
} // namespace Slot
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/throttling_traffic_shaping_checker.cc
================================================
#include <cmath>
#include "sentinel-core/flow/throttling_traffic_shaping_checker.h"
#include "sentinel-core/utils/time_utils.h"
namespace Sentinel {
namespace Flow {
Slot::TokenResultSharedPtr ThrottlingTrafficShapingChecker::DoCheck(
const Stat::NodeSharedPtr&, int acquire_count, double threshold) {
if (acquire_count < 0) {
return Slot::TokenResult::Ok();
}
if (threshold <= 0) {
return Slot::TokenResult::Blocked("blocked");
}
int64_t cur_time = Utils::TimeUtils::CurrentTimeMillis().count();
// Calculate the interval between every two requests.
int64_t cost_time = std::round(acquire_count / threshold * 1000);
// Expected pass time of this request.
int64_t expected_time = cost_time + last_passed_time_.load();
if (expected_time <= cur_time) {
last_passed_time_.store(cur_time);
return Slot::TokenResult::Ok();
}
int64_t wait_time = cost_time + last_passed_time_.load() -
Utils::TimeUtils::CurrentTimeMillis().count();
if (wait_time > max_timeout_) {
return Slot::TokenResult::Blocked("timeout");
}
int64_t old_time = cost_time + last_passed_time_.fetch_add(cost_time);
wait_time = old_time - Utils::TimeUtils::CurrentTimeMillis().count();
if (wait_time > max_timeout_) {
last_passed_time_.fetch_sub(cost_time);
return Slot::TokenResult::Blocked("timeout");
}
if (wait_time > 0) {
return Slot::TokenResult::ShouldWait(std::chrono::milliseconds(wait_time));
}
return Slot::TokenResult::Ok();
}
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/throttling_traffic_shaping_checker.h
================================================
#pragma once
#include <atomic>
#include "sentinel-core/flow/flow_rule_constants.h"
#include "sentinel-core/flow/traffic_shaping_checker.h"
namespace Sentinel {
namespace Flow {
class ThrottlingTrafficShapingChecker : public TrafficShapingChecker {
public:
explicit ThrottlingTrafficShapingChecker(int32_t timeout)
: max_timeout_(timeout) {}
virtual ~ThrottlingTrafficShapingChecker() = default;
Slot::TokenResultSharedPtr DoCheck(const Stat::NodeSharedPtr& node,
int acquire_count,
double threshold) override;
private:
const int32_t max_timeout_;
std::atomic<int64_t> last_passed_time_;
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/traffic_shaping_calculator.h
================================================
#pragma once
#include "sentinel-core/statistic/node/node.h"
namespace Sentinel {
namespace Flow {
class TrafficShapingCalculator {
public:
TrafficShapingCalculator() = default;
virtual ~TrafficShapingCalculator() = default;
virtual double CalculateAllowedTokens(const Stat::NodeSharedPtr& node,
int acquire_count, int flag) = 0;
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/traffic_shaping_checker.h
================================================
#pragma once
#include "sentinel-core/slot/base/token_result.h"
#include "sentinel-core/statistic/node/node.h"
namespace Sentinel {
namespace Flow {
class TrafficShapingChecker {
public:
TrafficShapingChecker() = default;
virtual ~TrafficShapingChecker() = default;
virtual Slot::TokenResultSharedPtr DoCheck(const Stat::NodeSharedPtr& node,
int acquire_count,
double threshold) = 0;
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/traffic_shaping_controller.cc
================================================
#include <memory>
#include "sentinel-core/flow/traffic_shaping_controller.h"
namespace Sentinel {
namespace Flow {
Slot::TokenResultSharedPtr TrafficShapingController::CanPass(
const Stat::NodeSharedPtr& node, int acquire_count, int flag) {
double allowed_tokens =
calculator_->CalculateAllowedTokens(node, acquire_count, flag);
return action_checker_->DoCheck(node, acquire_count, allowed_tokens);
}
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/traffic_shaping_controller.h
================================================
#pragma once
#include <memory>
#include "sentinel-core/flow/traffic_shaping_calculator.h"
#include "sentinel-core/flow/traffic_shaping_checker.h"
#include "sentinel-core/statistic/node/node.h"
namespace Sentinel {
namespace Flow {
class TrafficShapingController {
public:
TrafficShapingController(
std::unique_ptr<TrafficShapingCalculator>&& calculator,
std::unique_ptr<TrafficShapingChecker>&& checker)
: calculator_(std::move(calculator)),
action_checker_(std::move(checker)) {}
~TrafficShapingController() = default;
Slot::TokenResultSharedPtr CanPass(const Stat::NodeSharedPtr& node,
int acquire_count, int flag);
private:
const std::unique_ptr<TrafficShapingCalculator> calculator_;
const std::unique_ptr<TrafficShapingChecker> action_checker_;
};
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/flow/traffic_shaping_controller_test.cc
================================================
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sentinel-core/test/mock/flow/mock.h"
#include "sentinel-core/test/mock/statistic/node/mock.h"
#include "sentinel-core/flow/default_traffic_shaping_calculator.h"
#include "sentinel-core/flow/default_traffic_shaping_checker.h"
#include "sentinel-core/flow/flow_rule_constants.h"
#include "sentinel-core/flow/traffic_shaping_controller.h"
using testing::_;
using testing::InSequence;
using testing::Return;
namespace Sentinel {
namespace Flow {
TEST(TrafficShapingControllerTest, TestBasicPassCheck) {
auto node = std::make_shared<Stat::MockNode>();
TrafficShapingController always_pass_controller{
std::make_unique<MockTrafficShapingCalculator>(),
std::make_unique<AlwaysPassChecker>()};
TrafficShapingController always_block_controller{
std::make_unique<MockTrafficShapingCalculator>(),
std::make_unique<AlwaysBlockChecker>()};
auto pass_result = always_pass_controller.CanPass(node, 1, 0);
auto block_result = always_block_controller.CanPass(node, 1, 0);
EXPECT_EQ(Slot::TokenStatus::RESULT_STATUS_OK, pass_result->status());
EXPECT_EQ(Slot::TokenStatus::RESULT_STATUS_BLOCKED, block_result->status());
EXPECT_TRUE(block_result->blocked_reason().has_value());
double threshold = 10;
TrafficShapingController default_qps_controller{
std::make_unique<DefaultTrafficShapingCalculator>(threshold),
std::make_unique<DefaultTrafficShapingChecker>(FlowMetricType::kQps)};
ON_CALL(*node.get(), PassQps()).WillByDefault(Return(9));
EXPECT_EQ(Slot::TokenStatus::RESULT_STATUS_OK,
default_qps_controller.CanPass(node, 1, 0)->status());
ON_CALL(*node.get(), PassQps()).WillByDefault(Return(9));
EXPECT_EQ(Slot::TokenStatus::RESULT_STATUS_BLOCKED,
default_qps_controller.CanPass(node, 2, 0)->status());
ON_CALL(*node.get(), PassQps()).WillByDefault(Return(10));
EXPECT_EQ(Slot::TokenStatus::RESULT_STATUS_BLOCKED,
default_qps_controller.CanPass(node, 1, 0)->status());
}
} // namespace Flow
} // namespace Sentinel
================================================
FILE: sentinel-core/init/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "init_target_interface",
srcs = [
"init_target.h",
],
copts = DEFAULT_COPTS,
)
cc_library(
name = "init_target_registry_lib",
srcs = [
"init_target_registry.h",
],
copts = DEFAULT_COPTS,
deps = [
"//sentinel-core/utils:utils_lib",
]
)
cc_test(
name = "init_target_registry_unittests",
srcs = [
"init_target_registry_test.cc",
],
copts = TEST_COPTS,
deps = [
":init_target_interface",
":init_target_registry_lib",
"//sentinel-core/test/mock/init:mock_lib",
"@com_google_googletest//:gtest_main",
]
)
================================================
FILE: sentinel-core/init/init_target.h
================================================
#pragma once
namespace Sentinel {
namespace Init {
class Target {
public:
virtual ~Target() = default;
virtual void Initialize() = 0;
};
} // namespace Init
} // namespace Sentinel
================================================
FILE: sentinel-core/init/init_target_registry.h
================================================
#pragma once
#include "sentinel-core/utils/utils.h"
namespace Sentinel {
namespace Init {
template <typename T>
class InitTargetRegister {
public:
InitTargetRegister() { instance_.Initialize(); }
T& GetInstance() { return instance_; }
private:
T instance_{};
};
template <typename T>
class InitTargetRegister<Utils::Singleton<T>> {
public:
InitTargetRegister(const Utils::Singleton<T>& s) { s.get().Initialize(); }
};
/**
* Macro used for static registration.
* Static variable initialization does not guarantee order, so each target here
* cannot have mutual dependencies.
*/
#ifndef REGISTER_INIT_TARGET
#define REGISTER_INIT_TARGET(TARGET_OBJ_TYPE) \
static Sentinel::Init::InitTargetRegister<TARGET_OBJ_TYPE> \
TARGET_OBJ_TYPE##_registered
#endif
#ifndef REGISTER_SINGLETON_INIT_TARGET
#define REGISTER_SINGLETON_INIT_TARGET(TARGET_OBJ_TYPE, o) \
static Sentinel::Init::InitTargetRegister<Utils::Singleton<TARGET_OBJ_TYPE>> \
TARGET_OBJ_TYPE##_sgt_registered(o)
#endif
} // namespace Init
} // namespace Sentinel
================================================
FILE: sentinel-core/init/init_target_registry_test.cc
================================================
#include <iostream>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sentinel-core/test/mock/init/mock.h"
#include "sentinel-core/init/init_target.h"
#include "sentinel-core/init/init_target_registry.h"
namespace Sentinel {
namespace Init {
TEST(InitTargetRegisterTest, TestCommonInitTargetInvoked) {
REGISTER_INIT_TARGET(FakeInitTarget);
EXPECT_EQ(1, FakeInitTarget_registered.GetInstance().count());
}
} // namespace Init
} // namespace Sentinel
================================================
FILE: sentinel-core/log/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "logger_lib",
srcs = [
"logger.h",
"logger.cc",
],
copts = DEFAULT_COPTS,
deps = [
":log_base_impl_lib",
"//sentinel-core/utils:macros_lib",
"@com_github_gabime_spdlog//:spdlog"
]
)
cc_library(
name = "log_base_interface",
srcs = [
"log_base.h",
],
copts = DEFAULT_COPTS,
deps = [
]
)
cc_library(
name = "log_base_impl_lib",
srcs = [
"log_base.h",
"log_base.cc",
],
copts = DEFAULT_COPTS,
deps = [
"@com_google_absl//absl/strings",
"//sentinel-core/utils:file_utils_lib",
"//sentinel-core/init:init_target_registry_lib",
]
)
cc_test(
name = "log_base_unittests",
srcs = [
"log_base_test.cc",
],
copts = TEST_COPTS,
deps = [
":log_base_impl_lib",
"@com_google_googletest//:gtest_main",
]
)
cc_test(
name = "logger_unittests",
srcs = [
"logger_unittests.cc",
],
copts = TEST_COPTS,
deps = [
":logger_lib",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
]
)
================================================
FILE: sentinel-core/log/block/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "block_log_task_lib",
srcs = [
"block_log_task.h",
"block_log_task.cc",
],
copts = DEFAULT_COPTS,
deps = [
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/time",
"@com_github_gabime_spdlog//:spdlog",
"//sentinel-core/log:logger_lib",
]
)
cc_test(
name = "block_log_task_unittests",
srcs = [
"block_log_task_test.cc",
],
copts = TEST_COPTS,
deps = [
":block_log_task_lib",
"@com_google_googletest//:gtest_main",
]
)
================================================
FILE: sentinel-core/log/block/block_log_task.cc
================================================
#include "sentinel-core/log/block/block_log_task.h"
#include <iostream>
#include <memory>
#include <thread>
#include "sentinel-core/log/logger.h"
#include "sentinel-core/utils/time_utils.h"
#include "absl/strings/str_format.h"
#include "absl/time/time.h"
#include "spdlog/sinks/rotating_file_sink.h"
using namespace Sentinel::Utils;
namespace Sentinel {
namespace Log {
BlockLogTask::BlockLogTask(const std::string& log_path) {
try {
logger_ = spdlog::rotating_logger_mt(kBlockLoggerName, log_path,
kDefaultBlockLogMaxSize, 3);
logger_->set_pattern("%v");
} catch (const spdlog::spdlog_ex& ex) {
std::cerr << "Sentinel block log initialization failed: " << ex.what()
<< std::endl;
}
}
BlockLogTask::~BlockLogTask() {
Stop();
spdlog::drop(kBlockLoggerName);
}
void BlockLogTask::LoopWriteBlockLog() {
while (started()) {
if (logger_ != nullptr) {
absl::WriterMutexLock lck(&mtx_);
for (auto& e : map_) {
if (e.second.last_block_ - e.second.last_write_ > 0) {
int64_t cur_time = TimeUtils::CurrentTimeMillis().count();
auto time_str = absl::FormatTime("%Y-%m-%d %H:%M:%S",
absl::FromUnixMillis(cur_time),
absl::LocalTimeZone());
// format: time|resource|exception
logger_->info("{}|{}", time_str, e.first);
e.second.last_write_ = cur_time;
}
}
logger_->flush();
map_.clear();
}
// sleep for 1s
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}
void BlockLogTask::Start() {
if (logger_ == nullptr) {
SENTINEL_LOG(
error,
"Block logger failed to initialize, the block log task won't start");
return;
}
bool expected = false;
if (started_.compare_exchange_strong(expected, true)) {
thd_.reset(new std::thread(&BlockLogTask::LoopWriteBlockLog, this));
}
}
void BlockLogTask::Stop() {
started_.store(false);
thd_->join();
}
void BlockLogTask::Log(const std::string& resource, const std::string& cause) {
if (logger_ == nullptr) {
return;
}
auto key = absl::StrFormat("%s|%s", resource, cause);
{
absl::ReaderMutexLock lck(&mtx_);
auto it = map_.find(key);
if (it != map_.end()) {
it->second.last_block_ = TimeUtils::CurrentTimeMillis().count();
return;
}
}
absl::WriterMutexLock lck(&mtx_);
map_.emplace(std::make_pair(
key, BlockLogRecord{0, TimeUtils::CurrentTimeMillis().count()}));
}
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/block/block_log_task.h
================================================
#pragma once
#include <atomic>
#include <memory>
#include <string>
#include "absl/container/flat_hash_map.h"
#include "spdlog/spdlog.h"
#include "sentinel-core/log/log_base.h"
namespace Sentinel {
namespace Log {
static constexpr const char* kBlockLoggerName = "sentinel_block_logger";
static constexpr const char* kBlockLogFilename = "sentinel-block.log";
static constexpr uint32_t kDefaultBlockLogMaxSize = 1024 * 1024 * 300;
struct BlockLogRecord {
BlockLogRecord() = default;
BlockLogRecord(int64_t lw, int64_t lb) : last_write_(lw), last_block_(lb) {}
int64_t last_write_{0};
int64_t last_block_{0};
};
class BlockLogTask {
public:
BlockLogTask() : BlockLogTask(LogBase::GetLogBaseDir() + kBlockLogFilename) {}
explicit BlockLogTask(const std::string& log_path);
~BlockLogTask();
void Start();
void Stop();
void Log(const std::string& resource, const std::string& cause);
bool started() const { return started_.load(); }
private:
std::atomic_bool started_{false};
std::unique_ptr<std::thread> thd_;
std::shared_ptr<spdlog::logger> logger_;
absl::flat_hash_map<std::string, BlockLogRecord> map_;
mutable absl::Mutex mtx_;
void LoopWriteBlockLog();
};
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/block/block_log_task_test.cc
================================================
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string>
#include <thread>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "sentinel-core/log/block/block_log_task.h"
namespace Sentinel {
namespace Log {
namespace {
size_t GetLineNumberFromFilePath(const std::string& filename) {
std::ifstream inFile(filename);
return std::count(std::istreambuf_iterator<char>(inFile),
std::istreambuf_iterator<char>(), '\n');
}
} // namespace
TEST(BlockLogTaskTest, TestWriteBlockLog) {
std::string log_file_name = std::tmpnam(nullptr);
ASSERT_TRUE(!log_file_name.empty());
BlockLogTask task(log_file_name);
task.Start();
EXPECT_TRUE(task.started());
auto res1 = "some_resource";
auto res2 = "another_resource";
auto flow_exception = "FlowException";
task.Log(res1, flow_exception);
task.Log(res2, flow_exception);
std::this_thread::sleep_for(std::chrono::milliseconds(1100));
EXPECT_EQ(2, GetLineNumberFromFilePath(log_file_name));
task.Log(res1, flow_exception);
std::this_thread::sleep_for(std::chrono::milliseconds(1100));
EXPECT_EQ(3, GetLineNumberFromFilePath(log_file_name));
}
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/log_base.cc
================================================
#include "sentinel-core/log/log_base.h"
#include <cstdlib>
#include <iostream>
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "sentinel-core/utils/file_utils.h"
using namespace Sentinel::Utils;
namespace Sentinel {
namespace Log {
static constexpr auto kFileSeparator = "/";
LogBase::LogBase() { InitializeInternal(); }
void LogBase::InitializeInternal() {
// First use config from ENV.
// If absent, then use `~/logs/csp/`.
std::string str_log_dir;
auto log_dir = std::getenv(kEnvLogDir);
if (log_dir == nullptr) {
auto home_dir = std::getenv("HOME");
if (home_dir != nullptr) {
str_log_dir = std::string(home_dir);
str_log_dir = AddSeparator(str_log_dir) + kDirName;
} else {
std::cout << "INFO: home_dir is null" << std::endl;
str_log_dir = "./";
}
}
log_base_dir_ = AddSeparator(str_log_dir);
if (!FileUtils::DirExists(str_log_dir)) {
auto ret = FileUtils::CreateDir(str_log_dir);
if (!ret) {
// log error
}
}
const char *use_pid = std::getenv(kEnvLogNameUsrPid);
if (use_pid != nullptr && std::string(use_pid) == "true") {
log_name_use_pid_ = true;
} else {
log_name_use_pid_ = false;
}
std::cout << "INFO: log base dir is: " << log_base_dir_ << std::endl;
std::cout << "INFO: log name use pid is: " << log_name_use_pid_ << std::endl;
}
std::string LogBase::AddSeparator(const std::string &dir) {
if (!absl::EndsWith(dir, kFileSeparator)) {
return dir + kFileSeparator;
}
return dir;
}
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/log_base.h
================================================
#pragma once
#include <string>
namespace Sentinel {
namespace Log {
static constexpr auto kEnvLogDir = "CSP_SENTINEL_LOG_DIR";
static constexpr auto kEnvLogNameUsrPid = "CSP_SENTINEL_LOG_USE_PID";
static constexpr auto kDirName = "logs/csp";
class LogBase {
public:
~LogBase() = default;
static LogBase& GetInstance() {
static LogBase* instance = new LogBase();
return *instance;
}
static bool IsLogNameUsePid() { return GetInstance().log_name_use_pid_; }
static std::string GetLogBaseDir() { return GetInstance().log_base_dir_; }
private:
LogBase();
void InitializeInternal();
static std::string AddSeparator(const std::string& dir);
std::string log_base_dir_{};
bool log_name_use_pid_{false};
};
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/log_base_test.cc
================================================
#include "gtest/gtest.h"
#define private public
#include "sentinel-core/log/log_base.h"
namespace Sentinel {
namespace Log {
TEST(LogBaseTest, TestAddSeparator) {
auto ret = LogBase::AddSeparator("test_path");
EXPECT_EQ(ret, "test_path/");
ret = LogBase::AddSeparator("test_path/");
EXPECT_EQ(ret, "test_path/");
}
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/logger.cc
================================================
#include "logger.h"
#include <iostream>
#include <spdlog/async.h>
#include <spdlog/sinks/daily_file_sink.h>
namespace Sentinel {
namespace Log {
static constexpr const char* kDefaultRecordLogFormat = "[%H:%M:%S] [%l] %v";
const char Logger::kDefaultFileLogger[] = "default_sentinel_logger";
bool Logger::InitDefaultLogger() {
return Logger::InitDefaultLogger(Logger::GetDefaultLogPath());
}
bool Logger::InitDefaultLogger(const std::string& file_path) {
return Logger::InitDefaultLogger(file_path, kDefaultRecordLogFormat);
}
bool Logger::InitDefaultLogger(const std::string& file_path,
const std::string& log_format) {
try {
auto logger = spdlog::daily_logger_mt<spdlog::async_factory>(
kDefaultFileLogger, file_path);
if (!logger) {
return false;
}
// https://github.com/gabime/spdlog/wiki/3.-Custom-formatting
if (!log_format.empty()) {
logger->set_pattern(log_format);
}
logger->set_level(spdlog::level::info);
logger->flush_on(spdlog::level::info);
} catch (const spdlog::spdlog_ex& ex) {
std::cerr << "Log initialization failed: " << ex.what() << std::endl;
return false;
}
return true;
}
void Logger::Uninitialization() { spdlog::drop(kDefaultFileLogger); }
void Logger::SetAllLoggerLevel(levels level) {
spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) {
l->set_level(static_cast<spdlog::level::level_enum>(level));
});
}
void Logger::FlushAllLogger() {
spdlog::apply_all([&](std::shared_ptr<spdlog::logger> l) { l->flush(); });
}
std::string Logger::GetDefaultLogPath() {
return LogBase::GetLogBaseDir() + kRecordLogFilename;
}
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/logger.h
================================================
#pragma once
#include <string>
#include "sentinel-core/log/log_base.h"
#include "sentinel-core/utils/macros.h"
#include "spdlog/spdlog.h"
namespace Sentinel {
typedef enum {
trace = spdlog::level::trace,
debug = spdlog::level::debug,
info = spdlog::level::info,
warn = spdlog::level::warn,
error = spdlog::level::err,
critical = spdlog::level::critical,
} levels;
namespace Log {
static constexpr const char* kRecordLogFilename = "sentinel-record.log";
class Logger {
public:
Logger() = delete;
static bool InitDefaultLogger();
static bool InitDefaultLogger(const std::string& file_path);
static bool InitDefaultLogger(const std::string& file_path,
const std::string& log_format);
static void Uninitialization();
static void SetAllLoggerLevel(levels level);
static void FlushAllLogger();
static std::string GetDefaultLogPath();
template <typename... Args>
static void Log(const std::string& logger_name, levels level,
const char* format, const Args&... args) {
auto logger = spdlog::get(logger_name);
if (!logger) {
return;
}
switch (level) {
case trace: {
logger->trace(format, args...);
break;
}
case debug: {
logger->debug(format, args...);
break;
}
case info: {
logger->info(format, args...);
break;
}
case warn: {
logger->warn(format, args...);
break;
}
case error: {
logger->error(format, args...);
break;
}
case critical: {
logger->critical(format, args...);
break;
}
default: {
SENTINEL_NOT_REACHED_GCOVR_EXCL_LINE
}
}
}
static const char kDefaultFileLogger[];
};
#define SENTINEL_LOG(LEVEL, ...) \
Log::Logger::Log(Log::Logger::kDefaultFileLogger, LEVEL, ##__VA_ARGS__)
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/logger_test.cc
================================================
#include <stdio.h>
#include <memory>
#include <string>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <algorithm>
#include <fstream>
#include <iostream>
#include "sentinel-core/log/logger.h"
#include "sentinel-core/utils/time_utils.h"
#include "absl/strings/str_format.h"
#include "absl/time/clock.h"
#include "absl/time/time.h"
using namespace Sentinel::Utils;
namespace Sentinel {
namespace Log {
namespace {
size_t GetLineNumberFromFilePathWithDate(const std::string& filename) {
auto real_filename = absl::StrFormat(
"%s_%s", filename,
absl::FormatTime("%Y-%m-%d", absl::Now(), absl::LocalTimeZone()));
std::ifstream inFile(real_filename);
return std::count(std::istreambuf_iterator<char>(inFile),
std::istreambuf_iterator<char>(), '\n');
}
} // namespace
TEST(LoggerTest, BasicConstruct) {
std::string log_file_name = std::tmpnam(nullptr);
ASSERT_TRUE(!log_file_name.empty());
EXPECT_TRUE(Logger::InitDefaultLogger(log_file_name, ""));
}
TEST(LoggerTest, BasicLogger) {
Logger::Uninitialization();
std::string log_file_name =
absl::StrFormat("./test-%d", TimeUtils::CurrentTimeMillis().count());
ASSERT_TRUE(!log_file_name.empty());
ASSERT_TRUE(Logger::InitDefaultLogger(log_file_name, ""));
SENTINEL_LOG(info, "test one");
SENTINEL_LOG(info, "test two");
Logger::FlushAllLogger();
sync();
EXPECT_EQ(2, GetLineNumberFromFilePathWithDate(log_file_name));
SENTINEL_LOG(warn, "test one");
SENTINEL_LOG(warn, "test two");
Logger::FlushAllLogger();
sync();
EXPECT_EQ(4, GetLineNumberFromFilePathWithDate(log_file_name));
// Default log level is warn
SENTINEL_LOG(debug, "test one");
SENTINEL_LOG(debug, "test two");
Logger::FlushAllLogger();
sync();
EXPECT_EQ(4, GetLineNumberFromFilePathWithDate(log_file_name));
Logger::SetAllLoggerLevel(trace);
SENTINEL_LOG(trace, "test one");
SENTINEL_LOG(trace, "test two");
Logger::FlushAllLogger();
sync();
EXPECT_EQ(6, GetLineNumberFromFilePathWithDate(log_file_name));
remove(log_file_name.c_str());
}
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/metric/BUILD
================================================
load("//bazel:copts.bzl", "DEFAULT_COPTS", "TEST_COPTS")
package(default_visibility = ["//visibility:public"])
cc_library(
name = "metric_log_lib",
srcs = [
"metric_writer.h",
"metric_writer.cc",
"metric_reader.h",
"metric_reader.cc",
"metric_searcher.h",
"metric_searcher.cc",
],
copts = DEFAULT_COPTS,
deps = [
"@com_google_absl//absl/strings",
"@com_google_absl//absl/time",
"//sentinel-core/statistic/base:metric_item_lib",
"//sentinel-core/config:local_config_lib",
],
)
cc_library(
name = "metric_log_task_lib",
srcs = [
"metric_log_task.h",
"metric_log_task.cc",
],
copts = DEFAULT_COPTS,
deps = [
":metric_log_lib",
"//sentinel-core/init:init_target_interface",
"//sentinel-core/statistic/node:resource_node_storage_lib",
]
)
cc_test(
name = "metric_writer_unittests",
srcs = [
"metric_test_utils.h",
"metric_writer_test.cc",
],
copts = TEST_COPTS,
deps = [
":metric_log_lib",
"@com_google_googletest//:gtest_main",
]
)
cc_test(
name = "metric_reader_unittests",
srcs = [
"metric_test_utils.h",
"metric_reader_test.cc",
],
copts = TEST_COPTS,
deps = [
":metric_log_lib",
"@com_google_absl//absl/time",
"@com_google_googletest//:gtest_main",
],
linkstatic = 1,
)
cc_test(
name = "metric_searcher_unittests",
srcs = [
"metric_test_utils.h",
"metric_searcher_test.cc",
],
copts = TEST_COPTS,
deps = [
":metric_log_lib",
"@com_google_googletest//:gtest_main",
],
linkstatic = 1,
)
================================================
FILE: sentinel-core/log/metric/metric_log_task.cc
================================================
#include <assert.h>
#include <map>
#include <string>
#include <thread>
#include <vector>
#include "sentinel-core/config/local_config.h"
#include "sentinel-core/log/metric/metric_log_task.h"
#include "sentinel-core/log/metric/metric_writer.h"
#include "sentinel-core/statistic/base/metric_item.h"
#include "sentinel-core/statistic/node/resource_node_storage.h"
namespace Sentinel {
namespace Log {
MetricLogTask::MetricLogTask() {
Config::LocalConfig& conf = Config::LocalConfig::GetInstance();
writer_ = std::make_unique<MetricWriter>(conf.SingleMetricFileSize(),
conf.TotalMetricFileCount());
}
MetricLogTask::~MetricLogTask() { Stop(); }
void MetricLogTask::AggregateMetrics(
MetricItemTimeMap& map,
std::unordered_map<long, Stat::MetricItemSharedPtr>&& metrics,
const std::string& resource) {
for (const auto& e : metrics) {
int64_t t = e.first;
auto item = e.second;
item->set_resource(resource);
if (map.find(t) == map.end()) {
map.insert(std::make_pair(t, std::vector<Stat::MetricItemSharedPtr>{}));
}
auto iter = map.find(t);
if (iter != map.end()) {
iter->second.push_back(item);
}
}
}
void MetricLogTask::RunLogTask() {
while (!stopped_.load()) {
std::map<int64_t, std::vector<Stat::MetricItemSharedPtr>> map;
const auto resource_node_map =
Stat::ResourceNodeStorage::GetInstance().GetNodeMap();
for (const auto& e : resource_node_map) {
auto resource_node = e.second;
assert(resource_node != nullptr);
if (resource_node != nullptr) {
AggregateMetrics(map, resource_node->Metrics(), e.first);
}
}
if (!map.empty()) {
for (auto& e : map) {
writer_->Write(e.first, e.second);
}
}
// sleep for 1s
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
}
}
void MetricLogTask::Initialize() {
thd_.reset(new std::thread(&MetricLogTask::RunLogTask, this));
}
void MetricLogTask::Stop() {
stopped_.store(true);
thd_->join();
}
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/metric/metric_log_task.h
================================================
#pragma once
#include <atomic>
#include <map>
#include <memory>
#include <unordered_map>
#include <vector>
#include "sentinel-core/init/init_target.h"
#include "sentinel-core/log/metric/metric_writer.h"
#include "sentinel-core/statistic/base/metric_item.h"
namespace Sentinel {
namespace Log {
using MetricItemTimeMap =
std::map<int64_t, std::vector<Stat::MetricItemSharedPtr>>;
class MetricLogTask : public Init::Target {
public:
MetricLogTask();
virtual ~MetricLogTask();
void Initialize() override;
void Stop();
private:
std::unique_ptr<MetricWriter> writer_;
std::atomic<bool> stopped_{false};
std::unique_ptr<std::thread> thd_;
void RunLogTask();
void AggregateMetrics(
MetricItemTimeMap& map,
std::unordered_map<long, Stat::MetricItemSharedPtr>&& metrics,
const std::string& resource);
};
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/metric/metric_reader.cc
================================================
#include "sentinel-core/log/metric/metric_reader.h"
#include <fstream>
#include <iostream>
#include <istream>
namespace Sentinel {
namespace Log {
std::vector<Stat::MetricItemSharedPtr> MetricReader::ReadMetrics(
const std::vector<std::string> &file_names, int pos, int64_t offset,
int recommend_lines_) {
std::vector<Stat::MetricItemSharedPtr> metric_vec;
if (pos >= file_names.size()) {
return metric_vec;
}
ReadMetricsInOneFile(metric_vec, file_names[pos++], offset, recommend_lines_);
while (pos < file_names.size() && metric_vec.size() < recommend_lines_) {
ReadMetricsInOneFile(metric_vec, file_names[pos++], 0, recommend_lines_);
}
return metric_vec;
}
void MetricReader::ReadMetricsInOneFile(
std::vector<Stat::MetricItemSharedPtr> &metric_vec,
const std::string &file_name, int64_t offset, int recommend_lines) {
int64_t last_second = -1;
if (metric_vec.size() > 0) {
last_second = metric_vec[metric_vec.size() - 1]->timestamp() / 1000;
}
std::ifstream in_file(file_name.c_str(), std::ios::in);
if (!in_file.is_open()) {
return;
}
in_file.seekg(offset);
std::string line;
while (getline(in_file, line)) {
auto node = Stat::MetricItem::FromFatString(line);
int64_t cur_second = node->timestamp() / 1000;
if (metric_vec.size() < recommend_lines) {
metric_vec.emplace_back(std::move(node));
} else if (cur_second == last_second) {
metric_vec.emplace_back(std::move(node));
} else {
break;
}
last_second = cur_second;
}
in_file.close();
}
std::vector<Stat::MetricItemSharedPtr> MetricReader::ReadMetricsByEndTime(
const std::vector<std::string> file_names, int pos, int64_t offset,
int64_t begin_time_ms, int64_t end_time_ms, const std::string &identity) {
std::vector<Stat::MetricItemSharedPtr> metric_vec;
if (pos >= file_names.size()) {
return metric_vec;
}
if (!ReadMetricsInOneFileByEndTime(metric_vec, file_names[pos++], offset,
begin_time_ms, end_time_ms, identity)) {
return metric_vec;
}
while (pos < file_names.size() &&
ReadMetricsInOneFileByEndTime(metric_vec, file_names[pos++], 0,
begin_time_ms, end_time_ms, identity)) {
}
return metric_vec;
}
bool MetricReader::ReadMetricsInOneFileByEndTime(
std::vector<Stat::MetricItemSharedPtr> &metric_vec,
const std::string &file_name, int64_t offset, int64_t begin_time_ms,
int64_t end_time_ms, const std::string &identity) {
std::ifstream in_file(file_name.c_str(), std::ios::in | std::ios::binary);
if (!in_file.is_open()) {
return false;
}
long begin_second = begin_time_ms / 1000;
long end_second = end_time_ms / 1000;
in_file.seekg(offset);
std::string line;
while (getline(in_file, line)) {
auto node = Stat::MetricItem::FromFatString(line);
auto cur_second = node->timestamp() / 1000;
// currentSecond should >= beginSecond, otherwise a wrong metric file must
// occur
if (cur_second < begin_second) {
return false;
}
if (cur_second <= end_second) {
// read all
if (identity.size() == 0) {
metric_vec.emplace_back(std::move(node));
} else if (node->resource() == identity) {
metric_vec.emplace_back(std::move(node));
}
} else {
return false;
}
if (metric_vec.size() >= kMaxLinesReturn) {
return false;
}
}
return true;
}
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/metric/metric_reader.h
================================================
#pragma once
#include <string>
#include <vector>
#include "sentinel-core/statistic/base/metric_item.h"
namespace Sentinel {
namespace Log {
class MetricReader {
public:
std::vector<Stat::MetricItemSharedPtr> ReadMetrics(
const std::vector<std::string> &file_names, int pos, int64_t offset,
int recommend_lines_);
void ReadMetricsInOneFile(std::vector<Stat::MetricItemSharedPtr> &metric_vec,
const std::string &file_name, int64_t offset,
int recommend_lines);
std::vector<Stat::MetricItemSharedPtr> ReadMetricsByEndTime(
const std::vector<std::string> file_names, int pos, int64_t offset,
int64_t begin_time_ms, int64_t end_time_ms, const std::string &identity);
bool ReadMetricsInOneFileByEndTime(
std::vector<Stat::MetricItemSharedPtr> &metric_vec,
const std::string &file_name, int64_t offset, int64_t begin_time_ms,
int64_t end_time_ms, const std::string &identity);
private:
static const int kMaxLinesReturn = 100000;
};
} // namespace Log
} // namespace Sentinel
================================================
FILE: sentinel-core/log/metric/metric_reader_test.cc
================================================
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include <cstdio>
#include <fstream>
#include <sstream>
#define private public
#include "absl/time/time.h"
#include "sentinel-core/config/local_config.h"
#include "sentinel-core/log/log_base.h"
#include "sentinel-core/log/metric/metric_reader.h"
#include "sentinel-core/log/metric/metric_test_utils.h"
#include "sentinel-core/log/metric/metric_writer.h"
#include "sentinel-core/utils/file_utils.h"
#include "sentinel-core/utils/time_utils.h"
namespace Sentinel {
namespace Log {
TEST(MetricReaderTest, TestReadMetrics) {
int64_t time = Sentinel::Utils::TimeUtils::CurrentTimeMillis().count();
MetricTestUtils::TestWriteMetricLog(time);
auto date_str = absl::FormatTime("%Y-%m-%d", absl::FromUnixMillis(time),
absl::LocalTimeZone());
auto log_file_name = LogBase::GetLogBaseDir() +
MetricTestUtils::GetAppName() + "-metrics.log." +
date_str;
std::vector<std::string> file_names{log_file_name};
MetricReader reader;
auto ret1 = reader.ReadMetrics(file_names, 0, 0, 10);
EXPECT_EQ(ret1.size(), 2);
auto ret2 = reader.ReadMetrics(file_names, 0, 0, 1);
EXPECT_EQ(ret2.size(), 1);
MetricTestUtils::RemoveTestLogFile();
}
TEST(MetricReaderTest, TestReadMetricsByEndTime) {
int64_t time = Sentinel::Utils::TimeUtils::CurrentTimeMillis().count();
MetricTestUtils::TestWriteMetricLog(time);
auto date_str = absl::FormatTime("%Y-%m-%d", absl::FromUnixMillis(time),
absl::LocalTimeZone());
auto log_file_name = LogBase::GetLogBaseDir() +
MetricTestUtils::GetAppName() + "
gitextract_c4eu14oz/
├── .bazelrc
├── .clang-format
├── .github/
│ ├── ISSUE_TEMPLATE.md
│ ├── PULL_REQUEST_TEMPLATE.md
│ └── workflows/
│ └── main.yml
├── .gitignore
├── BUILD
├── CMakeLists.txt
├── LICENSE
├── README.md
├── WORKSPACE
├── bazel/
│ ├── BUILD
│ ├── copts.bzl
│ ├── fmtlib.BUILD
│ ├── osx.tbb.BUILD
│ ├── spdlog.BUILD
│ ├── tbb.BUILD
│ └── third_party_repositories.bzl
├── cmake/
│ ├── common.cmake
│ └── third_party.cmake
├── examples/
│ ├── CMakeLists.txt
│ ├── abseil/
│ │ ├── BUILD
│ │ └── abseil_string.cc
│ ├── benchmark/
│ │ ├── BUILD
│ │ └── benchamrk_test.cc
│ ├── cache/
│ │ ├── BUILD
│ │ └── cache_test.cc
│ ├── fmt/
│ │ ├── BUILD
│ │ └── fmt_test.cc
│ ├── gtest/
│ │ ├── BUILD
│ │ └── hello_test.cc
│ ├── json/
│ │ ├── BUILD
│ │ └── nlohmann_json_example.cc
│ ├── libevent/
│ │ ├── BUILD
│ │ └── libevent_echosrv1.c
│ ├── log/
│ │ ├── BUILD
│ │ └── log_test.cc
│ ├── sentinel-cpp/
│ │ ├── BUILD
│ │ ├── basic_concurrency_limit.cc
│ │ ├── basic_param_limit.cc
│ │ ├── basic_qps_limit.cc
│ │ └── basic_system_limit.cc
│ └── tbb/
│ ├── BUILD
│ └── tbb_test.cc
├── format.sh
├── sentinel-core/
│ ├── BUILD
│ ├── circuitbreaker/
│ │ ├── BUILD
│ │ ├── circuit_breaker.cc
│ │ ├── circuit_breaker.h
│ │ ├── error_circuit_breaker.cc
│ │ ├── error_circuit_breaker.h
│ │ ├── rt_circuit_breaker.cc
│ │ ├── rt_circuit_breaker.h
│ │ ├── rule.cc
│ │ ├── rule.h
│ │ ├── rule_manager.cc
│ │ ├── rule_manager.h
│ │ ├── slot.cc
│ │ ├── slot.h
│ │ └── slot_test.cc
│ ├── common/
│ │ ├── BUILD
│ │ ├── constants.h
│ │ ├── entry.h
│ │ ├── entry_context.cc
│ │ ├── entry_context.h
│ │ ├── entry_node.h
│ │ ├── entry_result.cc
│ │ ├── entry_result.h
│ │ ├── entry_type.h
│ │ ├── global_status.cc
│ │ ├── global_status.h
│ │ ├── resource_wrapper.h
│ │ ├── rule.h
│ │ ├── string_resource_wrapper.h
│ │ ├── tracer.cc
│ │ ├── tracer.h
│ │ └── tracer_test.cc
│ ├── config/
│ │ ├── BUILD
│ │ ├── config_constants.h
│ │ ├── local_config.cc
│ │ ├── local_config.h
│ │ └── local_config_test.cc
│ ├── flow/
│ │ ├── BUILD
│ │ ├── default_traffic_shaping_calculator.cc
│ │ ├── default_traffic_shaping_calculator.h
│ │ ├── default_traffic_shaping_checker.cc
│ │ ├── default_traffic_shaping_checker.h
│ │ ├── flow_rule.cc
│ │ ├── flow_rule.h
│ │ ├── flow_rule_checker.cc
│ │ ├── flow_rule_checker.h
│ │ ├── flow_rule_constants.h
│ │ ├── flow_rule_manager.cc
│ │ ├── flow_rule_manager.h
│ │ ├── flow_slot.cc
│ │ ├── flow_slot.h
│ │ ├── flow_slot_test.cc
│ │ ├── throttling_traffic_shaping_checker.cc
│ │ ├── throttling_traffic_shaping_checker.h
│ │ ├── traffic_shaping_calculator.h
│ │ ├── traffic_shaping_checker.h
│ │ ├── traffic_shaping_controller.cc
│ │ ├── traffic_shaping_controller.h
│ │ └── traffic_shaping_controller_test.cc
│ ├── init/
│ │ ├── BUILD
│ │ ├── init_target.h
│ │ ├── init_target_registry.h
│ │ └── init_target_registry_test.cc
│ ├── log/
│ │ ├── BUILD
│ │ ├── block/
│ │ │ ├── BUILD
│ │ │ ├── block_log_task.cc
│ │ │ ├── block_log_task.h
│ │ │ └── block_log_task_test.cc
│ │ ├── log_base.cc
│ │ ├── log_base.h
│ │ ├── log_base_test.cc
│ │ ├── logger.cc
│ │ ├── logger.h
│ │ ├── logger_test.cc
│ │ └── metric/
│ │ ├── BUILD
│ │ ├── metric_log_task.cc
│ │ ├── metric_log_task.h
│ │ ├── metric_reader.cc
│ │ ├── metric_reader.h
│ │ ├── metric_reader_test.cc
│ │ ├── metric_searcher.cc
│ │ ├── metric_searcher.h
│ │ ├── metric_searcher_test.cc
│ │ ├── metric_test_utils.h
│ │ ├── metric_writer.cc
│ │ ├── metric_writer.h
│ │ └── metric_writer_test.cc
│ ├── param/
│ │ ├── BUILD
│ │ ├── param_flow_item.cc
│ │ ├── param_flow_item.h
│ │ ├── param_flow_rule.cc
│ │ ├── param_flow_rule.h
│ │ ├── param_flow_rule_checker.cc
│ │ ├── param_flow_rule_checker.h
│ │ ├── param_flow_rule_constants.h
│ │ ├── param_flow_rule_manager.cc
│ │ ├── param_flow_rule_manager.h
│ │ ├── param_flow_slot.cc
│ │ ├── param_flow_slot.h
│ │ ├── param_flow_slot_test.cc
│ │ └── statistic/
│ │ ├── BUILD
│ │ ├── any_cmp.cc
│ │ ├── any_cmp.h
│ │ ├── any_cmp_test.cc
│ │ ├── lru_cache.h
│ │ ├── param_bucket.cc
│ │ ├── param_bucket.h
│ │ ├── param_event.h
│ │ ├── param_leap_array.cc
│ │ ├── param_leap_array.h
│ │ ├── param_leap_array_key.h
│ │ ├── param_metric.cc
│ │ ├── param_metric.h
│ │ ├── param_metric_test.cc
│ │ └── scalable_cache.h
│ ├── property/
│ │ ├── BUILD
│ │ ├── dynamic_sentinel_property.h
│ │ ├── dynamic_sentinel_property_test.cc
│ │ ├── property_listener.h
│ │ └── sentinel_property.h
│ ├── public/
│ │ ├── BUILD
│ │ ├── sph_u.h
│ │ └── sph_u_test.cc
│ ├── slot/
│ │ ├── BUILD
│ │ ├── base/
│ │ │ ├── BUILD
│ │ │ ├── default_slot_chain_impl.cc
│ │ │ ├── default_slot_chain_impl.h
│ │ │ ├── default_slot_chain_impl_test.cc
│ │ │ ├── rule_checker_slot.h
│ │ │ ├── slot.h
│ │ │ ├── slot_base.h
│ │ │ ├── slot_chain.h
│ │ │ ├── stats_slot.h
│ │ │ ├── token_result.cc
│ │ │ └── token_result.h
│ │ ├── global_slot_chain.cc
│ │ ├── global_slot_chain.h
│ │ ├── log_slot.cc
│ │ ├── log_slot.h
│ │ ├── resource_node_builder_slot.cc
│ │ ├── resource_node_builder_slot.h
│ │ ├── resource_node_builder_slot_test.cc
│ │ ├── statistic_slot.cc
│ │ ├── statistic_slot.h
│ │ └── statistic_slot_test.cc
│ ├── statistic/
│ │ ├── base/
│ │ │ ├── BUILD
│ │ │ ├── bucket_leap_array.cc
│ │ │ ├── bucket_leap_array.h
│ │ │ ├── bucket_leap_array_test.cc
│ │ │ ├── leap_array.h
│ │ │ ├── metric.h
│ │ │ ├── metric_bucket.cc
│ │ │ ├── metric_bucket.h
│ │ │ ├── metric_event.h
│ │ │ ├── metric_item.cc
│ │ │ ├── metric_item.h
│ │ │ ├── metric_item_test.cc
│ │ │ ├── sliding_window_metric.cc
│ │ │ ├── sliding_window_metric.h
│ │ │ ├── sliding_window_metric_test.cc
│ │ │ ├── stat_config.h
│ │ │ ├── stat_config_manager.cc
│ │ │ ├── stat_config_manager.h
│ │ │ └── window_wrap.h
│ │ └── node/
│ │ ├── BUILD
│ │ ├── cluster_node.cc
│ │ ├── cluster_node.h
│ │ ├── node.h
│ │ ├── resource_node_storage.cc
│ │ ├── resource_node_storage.h
│ │ ├── statistic_node.cc
│ │ └── statistic_node.h
│ ├── system/
│ │ ├── BUILD
│ │ ├── system_rule.cc
│ │ ├── system_rule.h
│ │ ├── system_rule_manager.cc
│ │ ├── system_rule_manager.h
│ │ ├── system_slot.cc
│ │ ├── system_slot.h
│ │ ├── system_slot_mock.h
│ │ ├── system_slot_test.cc
│ │ ├── system_status_listener.cc
│ │ ├── system_status_listener.h
│ │ └── system_status_listener_test.cc
│ ├── test/
│ │ └── mock/
│ │ ├── common/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ ├── flow/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ ├── init/
│ │ │ ├── BUILD
│ │ │ └── mock.h
│ │ ├── property/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ ├── slot/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ └── statistic/
│ │ ├── base/
│ │ │ ├── BUILD
│ │ │ ├── mock.cc
│ │ │ └── mock.h
│ │ └── node/
│ │ ├── BUILD
│ │ ├── mock.cc
│ │ └── mock.h
│ ├── transport/
│ │ ├── BUILD
│ │ ├── command/
│ │ │ ├── BUILD
│ │ │ ├── command_handler.h
│ │ │ ├── command_request.cc
│ │ │ ├── command_request.h
│ │ │ ├── command_request_test.cc
│ │ │ ├── command_response.h
│ │ │ ├── handler/
│ │ │ │ ├── BUILD
│ │ │ │ ├── fetch_cluster_node_handler.cc
│ │ │ │ ├── fetch_cluster_node_handler.h
│ │ │ │ ├── fetch_cluster_node_handler_test.cc
│ │ │ │ ├── fetch_metric_log_handler.cc
│ │ │ │ ├── fetch_metric_log_handler.h
│ │ │ │ ├── get_switch_status_handler.cc
│ │ │ │ ├── get_switch_status_handler.h
│ │ │ │ ├── set_switch_status_handler.cc
│ │ │ │ ├── set_switch_status_handler.h
│ │ │ │ ├── set_switch_status_handler_test.cc
│ │ │ │ ├── version_handler.cc
│ │ │ │ ├── version_handler.h
│ │ │ │ └── vo/
│ │ │ │ ├── BUILD
│ │ │ │ ├── statistic_node_vo.cc
│ │ │ │ └── statistic_node_vo.h
│ │ │ ├── http_command_center.cc
│ │ │ ├── http_command_center.h
│ │ │ ├── http_command_utils.cc
│ │ │ ├── http_command_utils.h
│ │ │ ├── http_server.cc
│ │ │ ├── http_server.h
│ │ │ ├── http_server_init_target.cc
│ │ │ └── http_server_init_target.h
│ │ ├── common/
│ │ │ ├── BUILD
│ │ │ ├── event_loop_thread.cc
│ │ │ ├── event_loop_thread.h
│ │ │ └── event_loop_thread_test.cc
│ │ └── constants.h
│ └── utils/
│ ├── BUILD
│ ├── file_utils.cc
│ ├── file_utils.h
│ ├── macros.h
│ ├── time_utils.cc
│ ├── time_utils.h
│ ├── utils.cc
│ └── utils.h
├── sentinel-datasource-extension/
│ ├── datasource/
│ │ ├── BUILD
│ │ ├── abstract_readable_data_source.h
│ │ ├── abstract_readable_data_source_unittests.cc
│ │ ├── converter.h
│ │ └── readable_data_source.h
│ └── test/
│ └── mock/
│ └── datasource/
│ ├── BUILD
│ ├── mock.cc
│ └── mock.h
├── tests/
│ ├── BUILD
│ └── tsan-flow.cc
└── third_party/
└── nlohmann/
├── BUILD
└── json.hpp
Copy disabled (too large)
Download .txt
Showing preview only (36,598K chars total). Download the full file to get everything.
SYMBOL INDEX (1255 symbols across 235 files)
FILE: examples/abseil/abseil_string.cc
function Greet (line 7) | std::string Greet(absl::string_view person) {
function main (line 11) | int main(int argc, char* argv[]) {
FILE: examples/benchmark/benchamrk_test.cc
function BM_StringCreation (line 12) | static void BM_StringCreation(benchmark::State& state) {
function ParamRun (line 18) | static void ParamRun(benchmark::State& state) {
function ParamNotRun (line 55) | static void ParamNotRun(benchmark::State& state) {
function NoCache (line 69) | static void NoCache(benchmark::State& state) {
type ParamItemType (line 78) | enum class ParamItemType { kInt32 = 0, kInt64, kString }
class MyAny (line 80) | class MyAny : public absl::any {
method MyAny (line 86) | MyAny(int32_t v) : absl::any(v), my_type_(ParamItemType::kInt32) {}
method MyAny (line 87) | MyAny(int64_t v) : absl::any(v), my_type_(ParamItemType::kInt64) {}
method MyAny (line 88) | MyAny(std::string v) : absl::any(v), my_type_(ParamItemType::kString) {}
method ParamItemType (line 90) | ParamItemType my_type() const noexcept { return my_type_; }
type std (line 130) | namespace std {
type hash<MyAny> (line 133) | struct hash<MyAny> {
function WithCache (line 153) | static void WithCache(benchmark::State& state) {
FILE: examples/cache/cache_test.cc
function CurrentTimeMillis (line 20) | int64_t CurrentTimeMillis() {
function Increase (line 26) | void Increase(int id, int cnt) {
function Timer (line 40) | void Timer() {
function main (line 51) | int main() {
FILE: examples/fmt/fmt_test.cc
function main (line 6) | int main() {
FILE: examples/gtest/hello_test.cc
function TEST (line 5) | TEST(HelloTest, Basic) { EXPECT_EQ("Hello tester", "Hello tester"); }
FILE: examples/json/nlohmann_json_example.cc
function main (line 6) | int main() {
FILE: examples/libevent/libevent_echosrv1.c
type client (line 66) | struct client {
function setnonblock (line 73) | int setnonblock(int fd) {
function on_read (line 88) | void on_read(int fd, short ev, void *arg) {
function on_accept (line 133) | void on_accept(int fd, short ev, void *arg) {
function main (line 168) | int main(int argc, char **argv) {
FILE: examples/log/log_test.cc
function main (line 2) | int main() {
FILE: examples/sentinel-cpp/basic_concurrency_limit.cc
function doEntry (line 17) | void doEntry(const char* resource) {
function doOneEntry (line 31) | void doOneEntry() { doEntry("my_open_api_abc"); }
function doAnotherEntry (line 33) | void doAnotherEntry() { doEntry("big_brother_service:foo()"); }
function main (line 39) | int main() {
FILE: examples/sentinel-cpp/basic_param_limit.cc
function CurrentTimeMillis (line 27) | int64_t CurrentTimeMillis() {
function RunTask (line 32) | void RunTask() {
function DoEntry (line 40) | void DoEntry(const char* resource) {
function TimerTask (line 61) | void TimerTask() {
function main (line 96) | int main() {
FILE: examples/sentinel-cpp/basic_qps_limit.cc
function DoEntry (line 13) | void DoEntry(const char* resource) {
function DoOneEntry (line 29) | void DoOneEntry() { DoEntry("my_open_api_abc"); }
function DoAnotherEntry (line 31) | void DoAnotherEntry() { DoEntry("m1:my_another_api_233"); }
function main (line 37) | int main() {
FILE: examples/sentinel-cpp/basic_system_limit.cc
function CurrentTimeMillis (line 18) | int64_t CurrentTimeMillis() {
function RunTask (line 24) | void RunTask() {
function DoEntry (line 32) | void DoEntry(const char* resource, Sentinel::EntryType trafficType) {
function TimerTask (line 48) | void TimerTask() {
function main (line 80) | int main() {
FILE: examples/tbb/tbb_test.cc
class Stu (line 11) | class Stu {
function main (line 19) | int main() {
FILE: sentinel-core/circuitbreaker/circuit_breaker.cc
type Sentinel (line 7) | namespace Sentinel {
type CircuitBreaker (line 8) | namespace CircuitBreaker {
function State (line 10) | State AbstractCircuitBreaker::CurrentState() { return current_state_...
function Rule (line 12) | const Rule& AbstractCircuitBreaker::GetRule() const { return rule_; }
FILE: sentinel-core/circuitbreaker/circuit_breaker.h
type class (line 12) | enum class
function class (line 14) | class CircuitBreaker {
FILE: sentinel-core/circuitbreaker/error_circuit_breaker.cc
type Sentinel (line 5) | namespace Sentinel {
type CircuitBreaker (line 6) | namespace CircuitBreaker {
FILE: sentinel-core/circuitbreaker/error_circuit_breaker.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/circuitbreaker/rt_circuit_breaker.cc
type Sentinel (line 5) | namespace Sentinel {
type CircuitBreaker (line 6) | namespace CircuitBreaker {
FILE: sentinel-core/circuitbreaker/rt_circuit_breaker.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/circuitbreaker/rule.cc
type Sentinel (line 7) | namespace Sentinel {
type CircuitBreaker (line 8) | namespace CircuitBreaker {
FILE: sentinel-core/circuitbreaker/rule.h
type class (line 14) | enum class
function Strategy (line 16) | enum class Strategy { kSlowRtRatio = 0, kErrorRatio = 1, kErrorCount = 2 };
FILE: sentinel-core/circuitbreaker/rule_manager.cc
type Sentinel (line 12) | namespace Sentinel {
type CircuitBreaker (line 13) | namespace CircuitBreaker {
function IsValidRule (line 17) | bool IsValidRule(const Rule& rule) {
function RuleList (line 56) | RuleList RuleManager::GetRules() const {
function RuleSet (line 65) | RuleSet RuleManager::GetRulesOfResource(const std::string& resource)...
function CircuitBreakerSharedPtr (line 97) | CircuitBreakerSharedPtr RuleManager::GetExistingSameCbOrNew(const Ru...
function CircuitBreakerSharedPtr (line 116) | CircuitBreakerSharedPtr RuleManager::NewCircuitBreaker(const Rule& r...
function LogRuleMap (line 127) | void LogRuleMap(const std::unordered_map<std::string, RuleSet>& map) {
function CircuitBreakerMap (line 141) | CircuitBreakerMap RulePropertyListener::BuildCircuitBreakerMap(
FILE: sentinel-core/circuitbreaker/rule_manager.h
function namespace (line 15) | namespace Sentinel {
FILE: sentinel-core/circuitbreaker/slot.cc
type Sentinel (line 6) | namespace Sentinel {
type CircuitBreaker (line 7) | namespace CircuitBreaker {
FILE: sentinel-core/circuitbreaker/slot.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/circuitbreaker/slot_test.cc
type Sentinel (line 16) | namespace Sentinel {
type CircuitBreaker (line 17) | namespace CircuitBreaker {
function Entry_And_Exit (line 19) | Sentinel::Slot::TokenResultSharedPtr Entry_And_Exit(
function TEST (line 32) | TEST(CircuitBreakerSlotTest, CircuitBreakerErrorRatioTest) {
function TEST (line 93) | TEST(CircuitBreakerSlotTest, CircuitBreakerSlowRatioTest) {
FILE: sentinel-core/common/constants.h
function namespace (line 3) | namespace Sentinel {
FILE: sentinel-core/common/entry.h
function set_rt (line 37) | void set_rt(int64_t rt) { rt_ = rt; }
function set_error (line 38) | void set_error(const std::string& message) { error_ = message; }
function set_block_error (line 39) | void set_block_error(const std::string& message) { block_error_ = messag...
function set_cur_node (line 40) | void set_cur_node(const Stat::NodeSharedPtr& node) { cur_node_ = node; }
function set_params (line 41) | void set_params(const std::vector<absl::any>&& params) { params_ = param...
function exited_ (line 48) | bool exited_{false};
FILE: sentinel-core/common/entry_context.cc
type Sentinel (line 5) | namespace Sentinel {}
FILE: sentinel-core/common/entry_context.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/common/entry_result.cc
type Sentinel (line 4) | namespace Sentinel {
FILE: sentinel-core/common/entry_result.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/common/entry_type.h
function namespace (line 3) | namespace Sentinel {
FILE: sentinel-core/common/global_status.cc
type Sentinel (line 1) | namespace Sentinel {
type GlobalStatus (line 2) | namespace GlobalStatus {
FILE: sentinel-core/common/global_status.h
function namespace (line 3) | namespace Sentinel {
FILE: sentinel-core/common/resource_wrapper.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/common/rule.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/common/string_resource_wrapper.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/common/tracer.cc
type Sentinel (line 6) | namespace Sentinel {
FILE: sentinel-core/common/tracer.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/common/tracer_test.cc
type Sentinel (line 15) | namespace Sentinel {
function TEST (line 17) | TEST(TracerTest, TraceExceptionTest) {
FILE: sentinel-core/config/config_constants.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/config/local_config.cc
type Sentinel (line 9) | namespace Sentinel {
type Config (line 10) | namespace Config {
FILE: sentinel-core/config/local_config.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/config/local_config_test.cc
type Sentinel (line 10) | namespace Sentinel {
type Config (line 11) | namespace Config {
function TEST (line 13) | TEST(LocalConfigTest, TestResolveNormalAppName) {
function TEST (line 21) | TEST(LocalConfigTest, TestGetIntOfInvalidValue) {
function TEST (line 29) | TEST(LocalConfigTest, TestGetIntOfNormalValue) {
FILE: sentinel-core/flow/default_traffic_shaping_calculator.cc
type Sentinel (line 3) | namespace Sentinel {
type Flow (line 4) | namespace Flow {
FILE: sentinel-core/flow/default_traffic_shaping_calculator.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/flow/default_traffic_shaping_checker.cc
type Sentinel (line 4) | namespace Sentinel {
type Flow (line 5) | namespace Flow {
FILE: sentinel-core/flow/default_traffic_shaping_checker.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/flow/flow_rule.cc
type Sentinel (line 7) | namespace Sentinel {
type Flow (line 8) | namespace Flow {
FILE: sentinel-core/flow/flow_rule.h
function Rule (line 15) | struct FlowRule : public Rule {
FILE: sentinel-core/flow/flow_rule_checker.cc
type Sentinel (line 6) | namespace Sentinel {
type Flow (line 7) | namespace Flow {
FILE: sentinel-core/flow/flow_rule_checker.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/flow/flow_rule_constants.h
type class (line 6) | enum class
function FlowRelationStrategy (line 11) | enum class FlowRelationStrategy {
FILE: sentinel-core/flow/flow_rule_manager.cc
type Sentinel (line 12) | namespace Sentinel {
type Flow (line 13) | namespace Flow {
function IsValidRule (line 17) | bool IsValidRule(const FlowRule& rule) {
function CreateDefaultController (line 41) | std::shared_ptr<TrafficShapingController> CreateDefaultController(
function FlowRuleList (line 65) | FlowRuleList FlowRuleManager::GetRules() const {
function FlowRuleList (line 74) | FlowRuleList FlowRuleManager::GetRulesForResource(
function LogFlowMap (line 144) | void LogFlowMap(const std::unordered_map<std::string, FlowRuleList>&...
FILE: sentinel-core/flow/flow_rule_manager.h
function namespace (line 15) | namespace Sentinel {
FILE: sentinel-core/flow/flow_slot.cc
type Sentinel (line 6) | namespace Sentinel {
type Slot (line 7) | namespace Slot {
function TokenResultSharedPtr (line 11) | TokenResultSharedPtr FlowSlot::Entry(const EntrySharedPtr& entry,
FILE: sentinel-core/flow/flow_slot.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/flow/flow_slot_test.cc
type Sentinel (line 18) | namespace Sentinel {
type Slot (line 19) | namespace Slot {
function TEST (line 21) | TEST(FlowSlotTest, FlowControlSingleThreadIntegrationTest) {
FILE: sentinel-core/flow/throttling_traffic_shaping_checker.cc
type Sentinel (line 6) | namespace Sentinel {
type Flow (line 7) | namespace Flow {
FILE: sentinel-core/flow/throttling_traffic_shaping_checker.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/flow/traffic_shaping_calculator.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/flow/traffic_shaping_checker.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/flow/traffic_shaping_controller.cc
type Sentinel (line 5) | namespace Sentinel {
type Flow (line 6) | namespace Flow {
FILE: sentinel-core/flow/traffic_shaping_controller.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/flow/traffic_shaping_controller_test.cc
type Sentinel (line 16) | namespace Sentinel {
type Flow (line 17) | namespace Flow {
function TEST (line 19) | TEST(TrafficShapingControllerTest, TestBasicPassCheck) {
FILE: sentinel-core/init/init_target.h
function namespace (line 3) | namespace Sentinel {
FILE: sentinel-core/init/init_target_registry.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/init/init_target_registry_test.cc
type Sentinel (line 11) | namespace Sentinel {
type Init (line 12) | namespace Init {
function TEST (line 14) | TEST(InitTargetRegisterTest, TestCommonInitTargetInvoked) {
FILE: sentinel-core/log/block/block_log_task.cc
type Sentinel (line 16) | namespace Sentinel {
type Log (line 17) | namespace Log {
FILE: sentinel-core/log/block/block_log_task.h
function namespace (line 12) | namespace Sentinel {
FILE: sentinel-core/log/block/block_log_task_test.cc
type Sentinel (line 12) | namespace Sentinel {
type Log (line 13) | namespace Log {
function GetLineNumberFromFilePath (line 16) | size_t GetLineNumberFromFilePath(const std::string& filename) {
function TEST (line 23) | TEST(BlockLogTaskTest, TestWriteBlockLog) {
FILE: sentinel-core/log/log_base.cc
type Sentinel (line 12) | namespace Sentinel {
type Log (line 13) | namespace Log {
FILE: sentinel-core/log/log_base.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/log/log_base_test.cc
type Sentinel (line 7) | namespace Sentinel {
type Log (line 8) | namespace Log {
function TEST (line 10) | TEST(LogBaseTest, TestAddSeparator) {
FILE: sentinel-core/log/logger.cc
type Sentinel (line 8) | namespace Sentinel {
type Log (line 9) | namespace Log {
FILE: sentinel-core/log/logger.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/log/logger_test.cc
type Sentinel (line 22) | namespace Sentinel {
type Log (line 23) | namespace Log {
function GetLineNumberFromFilePathWithDate (line 26) | size_t GetLineNumberFromFilePathWithDate(const std::string& filename) {
function TEST (line 36) | TEST(LoggerTest, BasicConstruct) {
function TEST (line 42) | TEST(LoggerTest, BasicLogger) {
FILE: sentinel-core/log/metric/metric_log_task.cc
type Sentinel (line 13) | namespace Sentinel {
type Log (line 14) | namespace Log {
FILE: sentinel-core/log/metric/metric_log_task.h
function namespace (line 13) | namespace Sentinel {
FILE: sentinel-core/log/metric/metric_reader.cc
type Sentinel (line 7) | namespace Sentinel {
type Log (line 8) | namespace Log {
FILE: sentinel-core/log/metric/metric_reader.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/log/metric/metric_reader_test.cc
type Sentinel (line 20) | namespace Sentinel {
type Log (line 21) | namespace Log {
function TEST (line 23) | TEST(MetricReaderTest, TestReadMetrics) {
function TEST (line 45) | TEST(MetricReaderTest, TestReadMetricsByEndTime) {
FILE: sentinel-core/log/metric/metric_searcher.cc
type Sentinel (line 10) | namespace Sentinel {
type Log (line 11) | namespace Log {
FILE: sentinel-core/log/metric/metric_searcher.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/log/metric/metric_searcher_test.cc
type Sentinel (line 21) | namespace Sentinel {
type Log (line 22) | namespace Log {
function TEST (line 24) | TEST(MetricSearcherTest, TestFind) {
function TEST (line 49) | TEST(MetricSearcherTest, TestFindInMultiFile) {
function TEST (line 80) | TEST(MetricSearcherTest, TestFindByTimeAndResource) {
FILE: sentinel-core/log/metric/metric_test_utils.h
function TestWriteMetricLog (line 20) | void TestWriteMetricLog(int64_t time) {
FILE: sentinel-core/log/metric/metric_writer.cc
type Sentinel (line 28) | namespace Sentinel {
type Log (line 29) | namespace Log {
FILE: sentinel-core/log/metric/metric_writer.h
function namespace (line 11) | namespace Sentinel {
FILE: sentinel-core/log/metric/metric_writer_test.cc
type Sentinel (line 17) | namespace Sentinel {
type Log (line 18) | namespace Log {
function TEST (line 23) | TEST(MetricWriterTest, TestFormMetricFileName) {
function TEST (line 36) | TEST(MetricWriterTest, TestFormIndexFileName) {
function TEST (line 42) | TEST(MetricWriterTest, TestMetricFileNameComparator) {
function TEST (line 74) | TEST(MetricWriterTest, TestFileNameMatches) {
function TEST (line 94) | TEST(MetricWriterTest, TestNextFileNameOfDay) {
function TEST (line 115) | TEST(MetricWriterTest, TestIsNextDay) {
function TEST (line 132) | TEST(MetricWriterTest, TestIsExceedMaxSingleFileSize) {
function TEST (line 153) | TEST(MetricWriterTest, TestRemoveMoreFiles) {
FILE: sentinel-core/param/param_flow_item.cc
type Sentinel (line 4) | namespace Sentinel {
type Param (line 5) | namespace Param {
FILE: sentinel-core/param/param_flow_item.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/param/param_flow_rule.cc
type Sentinel (line 4) | namespace Sentinel {
type Param (line 5) | namespace Param {
FILE: sentinel-core/param/param_flow_rule.h
function namespace (line 16) | namespace Sentinel {
FILE: sentinel-core/param/param_flow_rule_checker.cc
type Sentinel (line 3) | namespace Sentinel {
type Param (line 4) | namespace Param {
FILE: sentinel-core/param/param_flow_rule_checker.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/param/param_flow_rule_constants.h
type class (line 6) | enum class
type class (line 12) | enum class
function ParamFlowControlBehavior (line 18) | enum class ParamFlowControlBehavior {
FILE: sentinel-core/param/param_flow_rule_manager.cc
type Sentinel (line 3) | namespace Sentinel {
type Param (line 4) | namespace Param {
function IsValidRule (line 8) | bool IsValidRule(const ParamFlowRule& rule) {
function LogParamMap (line 31) | void LogParamMap(const ParamFlowRulePtrMapSharedPtr map) {
function ParamFlowRulePtrListSharedPtr (line 55) | ParamFlowRulePtrListSharedPtr ParamFlowRuleManager::GetRuleOfResource(
function ParamFlowRulePtrMapSharedPtr (line 65) | ParamFlowRulePtrMapSharedPtr ParamFlowRuleManager::GetRuleMap() const {
function ParamFlowRulePtrMapSharedPtr (line 76) | ParamFlowRulePtrMapSharedPtr ParamPropertyListener::AggregatedHotPar...
FILE: sentinel-core/param/param_flow_rule_manager.h
function namespace (line 14) | namespace Sentinel {
FILE: sentinel-core/param/param_flow_slot.cc
type Sentinel (line 4) | namespace Sentinel {
type Slot (line 5) | namespace Slot {
function TokenResultSharedPtr (line 12) | TokenResultSharedPtr ParamFlowSlot::Entry(
function TokenResultSharedPtr (line 52) | TokenResultSharedPtr ParamFlowSlot::CheckFlow(
FILE: sentinel-core/param/param_flow_slot.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/param/param_flow_slot_test.cc
type Sentinel (line 19) | namespace Sentinel {
type Slot (line 20) | namespace Slot {
function TEST (line 22) | TEST(ParamFlowSlotTest, ParamFlowControlSingleThreadIntegrationTest) {
FILE: sentinel-core/param/statistic/any_cmp.cc
type Sentinel (line 4) | namespace Sentinel {
type Param (line 5) | namespace Param {
function IsInt32 (line 12) | bool IsInt32(const absl::any& a) {
function IsInt64 (line 15) | bool IsInt64(const absl::any& a) {
function IsString (line 18) | bool IsString(const absl::any& a) {
type absl (line 26) | namespace absl {
FILE: sentinel-core/param/statistic/any_cmp.h
function namespace (line 6) | namespace Sentinel {
function namespace (line 20) | namespace std {
function namespace (line 42) | namespace absl {
function namespace (line 49) | namespace Sentinel {
FILE: sentinel-core/param/statistic/any_cmp_test.cc
function main (line 4) | int main() {
FILE: sentinel-core/param/statistic/lru_cache.h
function namespace (line 27) | namespace Sentinel {
FILE: sentinel-core/param/statistic/param_bucket.cc
type Sentinel (line 3) | namespace Sentinel {
type Param (line 4) | namespace Param {
FILE: sentinel-core/param/statistic/param_bucket.h
function namespace (line 13) | namespace Sentinel {
FILE: sentinel-core/param/statistic/param_event.h
function namespace (line 3) | namespace Sentinel {
FILE: sentinel-core/param/statistic/param_leap_array.cc
type Sentinel (line 3) | namespace Sentinel {
type Param (line 4) | namespace Param {
function HotPairList (line 27) | HotPairList&& ParamLeapArray::GetTopValues(const ParamMetricEvent& e,
function HotPairList (line 44) | HotPairList&& ParamLeapArray::GetTopPassValues(int number) {
FILE: sentinel-core/param/statistic/param_leap_array.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/param/statistic/param_leap_array_key.h
function namespace (line 4) | namespace Sentinel {
FILE: sentinel-core/param/statistic/param_metric.cc
type Sentinel (line 2) | namespace Sentinel {
type Param (line 3) | namespace Param {
function HotPairList (line 132) | HotPairList&& ParamMetric::GetTopPassParamCount(
FILE: sentinel-core/param/statistic/param_metric.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/param/statistic/param_metric_test.cc
type Sentinel (line 14) | namespace Sentinel {
type Param (line 15) | namespace Param {
function TEST (line 17) | TEST(ParamMetricTest, TestOperateMetric) {
FILE: sentinel-core/param/statistic/scalable_cache.h
function namespace (line 23) | namespace Sentinel {
FILE: sentinel-core/property/dynamic_sentinel_property.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/property/dynamic_sentinel_property_test.cc
type Sentinel (line 16) | namespace Sentinel {
type Property (line 17) | namespace Property {
function TEST (line 19) | TEST(DynamicSentinelPropertyTest, Basic) {
FILE: sentinel-core/property/property_listener.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/property/sentinel_property.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/public/sph_u.h
function namespace (line 14) | namespace Sentinel {
function EntryResultPtr (line 103) | EntryResultPtr SphU::Entry(const std::string& r) {
FILE: sentinel-core/public/sph_u_test.cc
type Sentinel (line 11) | namespace Sentinel {
function TEST (line 13) | TEST(SphUTest, TestEntryBlockSimple) {
function TEST (line 36) | TEST(SphUTest, TestEntryPassWithoutRules) {
FILE: sentinel-core/slot/base/default_slot_chain_impl.cc
type Sentinel (line 5) | namespace Sentinel {
type Slot (line 6) | namespace Slot {
function TokenResultSharedPtr (line 17) | TokenResultSharedPtr DefaultSlotChainImpl::Entry(
FILE: sentinel-core/slot/base/default_slot_chain_impl.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/slot/base/default_slot_chain_impl_test.cc
type Sentinel (line 19) | namespace Sentinel {
type Slot (line 20) | namespace Slot {
function TEST (line 22) | TEST(DefaultSlotChainImplTest, Basic) {
FILE: sentinel-core/slot/base/rule_checker_slot.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/slot/base/slot.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/slot/base/slot_base.h
function namespace (line 11) | namespace Sentinel {
FILE: sentinel-core/slot/base/slot_chain.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/slot/base/stats_slot.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/slot/base/token_result.cc
type Sentinel (line 4) | namespace Sentinel {
type Slot (line 5) | namespace Slot {
function TokenResultSharedPtr (line 10) | TokenResultSharedPtr TokenResult::Ok() { return cachedOkPtr; }
function TokenResultSharedPtr (line 12) | TokenResultSharedPtr TokenResult::Blocked(const std::string& blocked...
function TokenResultSharedPtr (line 17) | TokenResultSharedPtr TokenResult::ShouldWait(
FILE: sentinel-core/slot/base/token_result.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/slot/global_slot_chain.cc
type Sentinel (line 13) | namespace Sentinel {
type Slot (line 14) | namespace Slot {
function SlotChainSharedPtr (line 17) | SlotChainSharedPtr BuildDefaultSlotChain() {
function SlotChainSharedPtr (line 33) | SlotChainSharedPtr GetGlobalSlotChain() {
FILE: sentinel-core/slot/global_slot_chain.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/slot/log_slot.cc
type Sentinel (line 8) | namespace Sentinel {
type Slot (line 9) | namespace Slot {
function TokenResultSharedPtr (line 16) | TokenResultSharedPtr LogSlot::Entry(const EntrySharedPtr& entry,
FILE: sentinel-core/slot/log_slot.h
function namespace (line 13) | namespace Sentinel {
FILE: sentinel-core/slot/resource_node_builder_slot.cc
type Sentinel (line 6) | namespace Sentinel {
type Slot (line 7) | namespace Slot {
function TokenResultSharedPtr (line 11) | TokenResultSharedPtr ResourceNodeBuilderSlot::Entry(
FILE: sentinel-core/slot/resource_node_builder_slot.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/slot/resource_node_builder_slot_test.cc
type Sentinel (line 18) | namespace Sentinel {
type Slot (line 19) | namespace Slot {
class RequireNodeFakeStatsSlot (line 21) | class RequireNodeFakeStatsSlot : public StatsSlot {
method RequireNodeFakeStatsSlot (line 23) | RequireNodeFakeStatsSlot() = default;
method TokenResultSharedPtr (line 26) | TokenResultSharedPtr Entry(const EntrySharedPtr& entry,
function TEST (line 44) | TEST(ResourceNodeBuilderSlotTest, TestEntrySingleThread) {
FILE: sentinel-core/slot/statistic_slot.cc
type Sentinel (line 10) | namespace Sentinel {
type Slot (line 11) | namespace Slot {
function TokenResultSharedPtr (line 40) | TokenResultSharedPtr StatisticSlot::OnPass(
function TokenResultSharedPtr (line 61) | TokenResultSharedPtr StatisticSlot::OnBlock(
function TokenResultSharedPtr (line 81) | TokenResultSharedPtr StatisticSlot::Entry(
FILE: sentinel-core/slot/statistic_slot.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/slot/statistic_slot_test.cc
type Sentinel (line 17) | namespace Sentinel {
type Slot (line 18) | namespace Slot {
function TEST (line 20) | TEST(StatisticSlotTest, TestEntryAndExitSingleThread) {
FILE: sentinel-core/statistic/base/bucket_leap_array.cc
type Sentinel (line 3) | namespace Sentinel {
type Stat (line 4) | namespace Stat {
FILE: sentinel-core/statistic/base/bucket_leap_array.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/statistic/base/bucket_leap_array_test.cc
type Sentinel (line 13) | namespace Sentinel {
type Stat (line 14) | namespace Stat {
function TEST (line 21) | TEST(BucketLeapArrayTest, TestNewWindow) {
function TEST (line 34) | TEST(BucketLeapArrayTest, TestLeapArrayWindowStart) {
function TEST (line 46) | TEST(BucketLeapArrayTest, TestWindowAfterOneInterval) {
function TEST (line 79) | TEST(BucketLeapArrayTest, TestListWindowsResetOld) {
FILE: sentinel-core/statistic/base/leap_array.h
function namespace (line 12) | namespace Sentinel {
FILE: sentinel-core/statistic/base/metric.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/statistic/base/metric_bucket.cc
type Sentinel (line 5) | namespace Sentinel {
type Stat (line 6) | namespace Stat {
function MetricBucket (line 8) | MetricBucket& MetricBucket::Reset() {
FILE: sentinel-core/statistic/base/metric_bucket.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/statistic/base/metric_event.h
function namespace (line 3) | namespace Sentinel {
FILE: sentinel-core/statistic/base/metric_item.cc
type Sentinel (line 13) | namespace Sentinel {
type Stat (line 14) | namespace Stat {
function ParseOrDefault (line 16) | int64_t ParseOrDefault(const std::string& s, int64_t default_value) {
function MetricItemSharedPtr (line 43) | MetricItemSharedPtr MetricItem::FromThinString(const std::string& th...
function MetricItemSharedPtr (line 59) | MetricItemSharedPtr MetricItem::FromFatString(const std::string& fat...
FILE: sentinel-core/statistic/base/metric_item.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/statistic/base/metric_item_test.cc
type Sentinel (line 5) | namespace Sentinel {
type Stat (line 6) | namespace Stat {
function TEST (line 8) | TEST(MetricItemTest, TestToThinString) {
function TEST (line 22) | TEST(MetricItemTest, TestFromThinString) {
function TEST (line 35) | TEST(MetricItemTest, TestFromFatString) {
FILE: sentinel-core/statistic/base/sliding_window_metric.cc
type Sentinel (line 8) | namespace Sentinel {
type Stat (line 9) | namespace Stat {
FILE: sentinel-core/statistic/base/sliding_window_metric.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/statistic/base/sliding_window_metric_test.cc
type Sentinel (line 12) | namespace Sentinel {
type Stat (line 13) | namespace Stat {
function TEST (line 15) | TEST(SlidingWindowMetricTest, TestOperateMetric) {
FILE: sentinel-core/statistic/base/stat_config.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/statistic/base/stat_config_manager.cc
type Sentinel (line 5) | namespace Sentinel {
type Stat (line 6) | namespace Stat {
FILE: sentinel-core/statistic/base/stat_config_manager.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/statistic/base/window_wrap.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/statistic/node/cluster_node.cc
type Sentinel (line 3) | namespace Sentinel {
type Stat (line 4) | namespace Stat {
function StatisticNodeSharedPtr (line 6) | StatisticNodeSharedPtr ClusterNode::GetTagNode(const std::string& ta...
function StatisticNodeSharedPtr (line 15) | StatisticNodeSharedPtr ClusterNode::GetOrCreateTagNode(const std::st...
FILE: sentinel-core/statistic/node/cluster_node.h
function namespace (line 11) | namespace Sentinel {
FILE: sentinel-core/statistic/node/node.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/statistic/node/resource_node_storage.cc
type Sentinel (line 8) | namespace Sentinel {
type Stat (line 9) | namespace Stat {
FILE: sentinel-core/statistic/node/resource_node_storage.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/statistic/node/statistic_node.cc
type Sentinel (line 7) | namespace Sentinel {
type Stat (line 8) | namespace Stat {
FILE: sentinel-core/statistic/node/statistic_node.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/system/system_rule.cc
type Sentinel (line 4) | namespace Sentinel {
type System (line 5) | namespace System {
function GetMetricTypeString (line 7) | std::string GetMetricTypeString(MetricType ruleType) {
FILE: sentinel-core/system/system_rule.h
function namespace (line 13) | namespace Sentinel {
function namespace (line 46) | namespace std {
FILE: sentinel-core/system/system_rule_manager.cc
type Sentinel (line 4) | namespace Sentinel {
type System (line 5) | namespace System {
function IsValidRule (line 9) | bool IsValidRule(const SystemRule &rule) {
function LogSystemMap (line 23) | void LogSystemMap(const SystemRuleMapSharedPtr map) {
FILE: sentinel-core/system/system_rule_manager.h
function namespace (line 22) | namespace Sentinel {
FILE: sentinel-core/system/system_slot.cc
type Sentinel (line 9) | namespace Sentinel {
type Slot (line 10) | namespace Slot {
function TokenResultSharedPtr (line 14) | TokenResultSharedPtr SystemSlot::Entry(const EntrySharedPtr& entry,
function TokenResultSharedPtr (line 38) | TokenResultSharedPtr SystemSlot::CheckSystem(
FILE: sentinel-core/system/system_slot.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/system/system_slot_mock.h
function namespace (line 14) | namespace Sentinel {
FILE: sentinel-core/system/system_slot_test.cc
type Sentinel (line 13) | namespace Sentinel {
type Slot (line 14) | namespace Slot {
function TEST (line 17) | TEST(SystemSlotTest, SystemRuleSingleThreadTest) {
FILE: sentinel-core/system/system_status_listener.cc
type Sentinel (line 4) | namespace Sentinel {
type System (line 5) | namespace System {
FILE: sentinel-core/system/system_status_listener.h
type CpuStates (line 18) | enum CpuStates {
function class (line 31) | class CpuLoadInfo {
function class (line 38) | class CpuUsageInfo {
function SystemStatusListener (line 53) | static SystemStatusListener& GetInstance() {
function virtual (line 58) | virtual ~SystemStatusListener() {
function GetCurLoad (line 65) | double GetCurLoad() { return cur_load_.load(); }
function GetCurCpuUsage (line 66) | double GetCurCpuUsage() { return cur_cpu_usage_.load(); }
function StopListner (line 87) | void StopListner() {
FILE: sentinel-core/system/system_status_listener_test.cc
type Sentinel (line 9) | namespace Sentinel {
type System (line 10) | namespace System {
function TEST (line 12) | TEST(SystemStatusListenerTest, SystemStatusListenerSingleThreadTest) {
FILE: sentinel-core/test/mock/common/mock.h
function namespace (line 11) | namespace Sentinel {
FILE: sentinel-core/test/mock/flow/mock.cc
type Sentinel (line 3) | namespace Sentinel {
type Flow (line 4) | namespace Flow {
FILE: sentinel-core/test/mock/flow/mock.h
function namespace (line 10) | namespace Sentinel {
function class (line 35) | class MockTrafficShapingChecker : public TrafficShapingChecker {
function class (line 44) | class MockTrafficShapingCalculator : public TrafficShapingCalculator {
FILE: sentinel-core/test/mock/init/mock.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/test/mock/property/mock.cc
type Sentinel (line 3) | namespace Sentinel {
type Property (line 4) | namespace Property {}
FILE: sentinel-core/test/mock/property/mock.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/test/mock/slot/mock.cc
type Sentinel (line 3) | namespace Sentinel {
type Slot (line 4) | namespace Slot {
FILE: sentinel-core/test/mock/slot/mock.h
function namespace (line 11) | namespace Sentinel {
FILE: sentinel-core/test/mock/statistic/base/mock.cc
type Sentinel (line 3) | namespace Sentinel {
type Stat (line 4) | namespace Stat {}
FILE: sentinel-core/test/mock/statistic/base/mock.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/test/mock/statistic/node/mock.cc
type Sentinel (line 3) | namespace Sentinel {
type Stat (line 4) | namespace Stat {
FILE: sentinel-core/test/mock/statistic/node/mock.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/transport/command/command_handler.h
function namespace (line 8) | namespace Sentinel {
FILE: sentinel-core/transport/command/command_request.cc
type Sentinel (line 3) | namespace Sentinel {
type Transport (line 4) | namespace Transport {
function CommandRequest (line 8) | CommandRequest& CommandRequest::set_body(const std::string& body) {
function CommandRequest (line 37) | CommandRequest& CommandRequest::AddParam(const std::string& key,
function CommandRequest (line 48) | CommandRequest& CommandRequest::AddMetadata(const std::string& key,
FILE: sentinel-core/transport/command/command_request.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/transport/command/command_request_test.cc
type Sentinel (line 8) | namespace Sentinel {
type Transport (line 9) | namespace Transport {
function TEST (line 11) | TEST(CommandRequestTest, TestBody) {
function TEST (line 20) | TEST(CommandRequestTest, TestParam) {
function TEST (line 39) | TEST(CommandRequestTest, TestMetadata) {
FILE: sentinel-core/transport/command/command_response.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/transport/command/handler/fetch_cluster_node_handler.cc
type Sentinel (line 11) | namespace Sentinel {
type Transport (line 12) | namespace Transport {
function ConvertNodeVoToJson (line 14) | nlohmann::json ConvertNodeVoToJson(
function CommandResponsePtr (line 33) | CommandResponsePtr FetchClusterNodeCommandHandler::Handle(
FILE: sentinel-core/transport/command/handler/fetch_cluster_node_handler.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/transport/command/handler/fetch_cluster_node_handler_test.cc
type Sentinel (line 12) | namespace Sentinel {
type Stat (line 13) | namespace Stat {
function TEST (line 15) | TEST(FetchClusterNodeHandlerTest, TestBasic) {}
FILE: sentinel-core/transport/command/handler/fetch_metric_log_handler.cc
type Sentinel (line 9) | namespace Sentinel {
type Transport (line 10) | namespace Transport {
function ParseOrDefault (line 20) | int64_t ParseOrDefault(const std::string& s, int64_t default_value) {
function CommandResponsePtr (line 28) | CommandResponsePtr FetchMetricLogCommandHandler::Handle(
FILE: sentinel-core/transport/command/handler/fetch_metric_log_handler.h
function namespace (line 12) | namespace Sentinel {
FILE: sentinel-core/transport/command/handler/get_switch_status_handler.cc
type Sentinel (line 9) | namespace Sentinel {
type Transport (line 10) | namespace Transport {
function CommandResponsePtr (line 12) | CommandResponsePtr GetSwitchStatusCommandHandler::Handle(
FILE: sentinel-core/transport/command/handler/get_switch_status_handler.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/transport/command/handler/set_switch_status_handler.cc
type Sentinel (line 5) | namespace Sentinel {
type Transport (line 6) | namespace Transport {
function CommandResponsePtr (line 8) | CommandResponsePtr SetSwitchStatusCommandHandler::Handle(
FILE: sentinel-core/transport/command/handler/set_switch_status_handler.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/transport/command/handler/set_switch_status_handler_test.cc
type Sentinel (line 9) | namespace Sentinel {
type Transport (line 10) | namespace Transport {
function TEST (line 12) | TEST(SetSwitchStatusCommandHandlerTest, TestHandleRequest) {
FILE: sentinel-core/transport/command/handler/version_handler.cc
type Sentinel (line 5) | namespace Sentinel {
type Transport (line 6) | namespace Transport {
function CommandResponsePtr (line 8) | CommandResponsePtr VersionCommandHandler::Handle(
FILE: sentinel-core/transport/command/handler/version_handler.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-core/transport/command/handler/vo/statistic_node_vo.cc
type Sentinel (line 6) | namespace Sentinel {
type Transport (line 7) | namespace Transport {
FILE: sentinel-core/transport/command/handler/vo/statistic_node_vo.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/transport/command/http_command_center.cc
type Sentinel (line 9) | namespace Sentinel {
type Transport (line 10) | namespace Transport {
type evhttp_request (line 47) | struct evhttp_request
type evhttp_request (line 64) | struct evhttp_request
FILE: sentinel-core/transport/command/http_command_center.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/transport/command/http_command_utils.cc
type Sentinel (line 11) | namespace Sentinel {
type Transport (line 12) | namespace Transport {
type evhttp_request (line 14) | struct evhttp_request
type evhttp_request (line 24) | struct evhttp_request
type evhttp_request (line 35) | struct evhttp_request
function CommandRequest (line 45) | CommandRequest HttpCommandUtils::ParseHttpRequest(
type evkeyvalq (line 76) | struct evkeyvalq
type evkeyval (line 78) | struct evkeyval
type evhttp_request (line 87) | struct evhttp_request
FILE: sentinel-core/transport/command/http_command_utils.h
function namespace (line 11) | namespace Sentinel {
FILE: sentinel-core/transport/command/http_server.cc
type Sentinel (line 8) | namespace Sentinel {
type Transport (line 9) | namespace Transport {
type evhttp_request (line 73) | struct evhttp_request
type evhttp_request (line 78) | struct evhttp_request
FILE: sentinel-core/transport/command/http_server.h
function namespace (line 13) | namespace Sentinel {
FILE: sentinel-core/transport/command/http_server_init_target.cc
type Sentinel (line 14) | namespace Sentinel {
type Transport (line 15) | namespace Transport {
FILE: sentinel-core/transport/command/http_server_init_target.h
function namespace (line 9) | namespace Sentinel {
FILE: sentinel-core/transport/common/event_loop_thread.cc
type Sentinel (line 7) | namespace Sentinel {
type Transport (line 8) | namespace Transport {
type event_base (line 137) | struct event_base
FILE: sentinel-core/transport/common/event_loop_thread.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-core/transport/common/event_loop_thread_test.cc
type Sentinel (line 8) | namespace Sentinel {
type Transport (line 9) | namespace Transport {
function TEST (line 11) | TEST(CommandRequestTest, TestStart) {
function TEST (line 19) | TEST(CommandRequestTest, TestStop) {
function TEST (line 29) | TEST(CommandRequestTest, TestRunTask) {
FILE: sentinel-core/transport/constants.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/utils/file_utils.cc
type Sentinel (line 13) | namespace Sentinel {
type Utils (line 14) | namespace Utils {
type dirent (line 62) | struct dirent
FILE: sentinel-core/utils/file_utils.h
function namespace (line 6) | namespace Sentinel {
FILE: sentinel-core/utils/macros.h
function namespace (line 4) | namespace Sentinel {
FILE: sentinel-core/utils/time_utils.cc
type Sentinel (line 3) | namespace Sentinel {
type Utils (line 4) | namespace Utils {
FILE: sentinel-core/utils/time_utils.h
function namespace (line 5) | namespace Sentinel {
FILE: sentinel-core/utils/utils.h
function namespace (line 3) | namespace Sentinel {
FILE: sentinel-datasource-extension/datasource/abstract_readable_data_source.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-datasource-extension/datasource/abstract_readable_data_source_unittests.cc
type Sentinel (line 8) | namespace Sentinel {
type DataSource (line 9) | namespace DataSource {
function TEST (line 16) | TEST(AbstractReadableDataSourceTest, Basic) {
FILE: sentinel-datasource-extension/datasource/converter.h
function namespace (line 7) | namespace Sentinel {
FILE: sentinel-datasource-extension/datasource/readable_data_source.h
function namespace (line 10) | namespace Sentinel {
FILE: sentinel-datasource-extension/test/mock/datasource/mock.cc
type Sentinel (line 1) | namespace Sentinel {
type DataSource (line 2) | namespace DataSource {}
FILE: sentinel-datasource-extension/test/mock/datasource/mock.h
function namespace (line 11) | namespace Sentinel {
FILE: tests/tsan-flow.cc
function doEntry (line 19) | void doEntry(const char* resource) {
function doOneEntry (line 32) | void doOneEntry() { doEntry("my_open_api_abc"); }
function doAnotherEntry (line 34) | void doAnotherEntry() { doEntry("big_brother_service:foo()"); }
function main (line 36) | int main() {
FILE: third_party/nlohmann/json.hpp
type nlohmann (line 84) | namespace nlohmann
type detail (line 86) | namespace detail
type position_t (line 89) | struct position_t
class exception (line 145) | class exception : public std::exception
method exception (line 158) | exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
method name (line 160) | static std::string name(const std::string& ename, int id_)
class parse_error (line 214) | class parse_error : public exception
method parse_error (line 226) | static parse_error create(int id_, const position_t& pos, const st...
method parse_error (line 233) | static parse_error create(int id_, std::size_t byte_, const std::s...
method parse_error (line 253) | parse_error(int id_, std::size_t byte_, const char* what_arg)
method position_string (line 256) | static std::string position_string(const position_t& pos)
class invalid_iterator (line 300) | class invalid_iterator : public exception
method invalid_iterator (line 303) | static invalid_iterator create(int id_, const std::string& what_arg)
method invalid_iterator (line 310) | invalid_iterator(int id_, const char* what_arg)
class type_error (line 353) | class type_error : public exception
method type_error (line 356) | static type_error create(int id_, const std::string& what_arg)
method type_error (line 363) | type_error(int id_, const char* what_arg) : exception(id_, what_ar...
class out_of_range (line 399) | class out_of_range : public exception
method out_of_range (line 402) | static out_of_range create(int id_, const std::string& what_arg)
method out_of_range (line 409) | out_of_range(int id_, const char* what_arg) : exception(id_, what_...
class other_error (line 436) | class other_error : public exception
method other_error (line 439) | static other_error create(int id_, const std::string& what_arg)
method other_error (line 446) | other_error(int id_, const char* what_arg) : exception(id_, what_a...
type index_sequence (line 625) | struct index_sequence
method size (line 629) | static constexpr std::size_t size() noexcept
type merge_and_renumber (line 636) | struct merge_and_renumber
type make_index_sequence (line 643) | struct make_index_sequence
type make_index_sequence<0> (line 647) | struct make_index_sequence<0> : index_sequence<> {}
type make_index_sequence<1> (line 648) | struct make_index_sequence<1> : index_sequence<0> {}
type priority_tag (line 654) | struct priority_tag : priority_tag < N - 1 > {}
type priority_tag<0> (line 655) | struct priority_tag<0> {}
type static_const (line 659) | struct static_const
type make_void (line 689) | struct make_void
type iterator_types (line 705) | struct iterator_types {}
type iterator_types <
It,
void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
typename It::reference, typename It::iterator_category >> (line 708) | struct iterator_types <
type iterator_traits (line 723) | struct iterator_traits
type iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >> (line 728) | struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
type iterator_traits<T*, enable_if_t<std::is_object<T>::value>> (line 734) | struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
type nonesuch (line 762) | struct nonesuch
method nonesuch (line 764) | nonesuch() = delete;
method nonesuch (line 766) | nonesuch(nonesuch const&) = delete;
method nonesuch (line 767) | nonesuch(nonesuch const&&) = delete;
type detector (line 776) | struct detector
type is_basic_json (line 902) | struct is_basic_json : std::false_type {}
type has_from_json (line 946) | struct has_from_json : std::false_type {}
type has_from_json<BasicJsonType, T,
enable_if_t<not is_basic_json<T>::value>> (line 949) | struct has_from_json<BasicJsonType, T,
type has_non_default_from_json (line 962) | struct has_non_default_from_json : std::false_type {}
type has_non_default_from_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>> (line 965) | struct has_non_default_from_json<BasicJsonType, T, enable_if_t<not i...
type has_to_json (line 977) | struct has_to_json : std::false_type {}
type has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>> (line 980) | struct has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T...
type is_iterator_traits (line 995) | struct is_iterator_traits : std::false_type {}
type is_iterator_traits<iterator_traits<T>> (line 998) | struct is_iterator_traits<iterator_traits<T>>
type is_complete_type (line 1015) | struct is_complete_type : std::false_type {}
type is_complete_type<T, decltype(void(sizeof(T)))> (line 1018) | struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_ty...
type is_compatible_object_type_impl (line 1022) | struct is_compatible_object_type_impl : std::false_type {}
type is_compatible_object_type_impl <
BasicJsonType, CompatibleObjectType,
enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value and
is_detected<key_type_t, CompatibleObjectType>::value >> (line 1025) | struct is_compatible_object_type_impl <
type is_compatible_object_type (line 1042) | struct is_compatible_object_type
type is_constructible_object_type_impl (line 1047) | struct is_constructible_object_type_impl : std::false_type {}
type is_constructible_object_type_impl <
BasicJsonType, ConstructibleObjectType,
enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value and
is_detected<key_type_t, ConstructibleObjectType>::value >> (line 1050) | struct is_constructible_object_type_impl <
type is_constructible_object_type (line 1065) | struct is_constructible_object_type
type is_compatible_string_type_impl (line 1071) | struct is_compatible_string_type_impl : std::false_type {}
type is_compatible_string_type_impl <
BasicJsonType, CompatibleStringType,
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, CompatibleStringType>::value >> (line 1074) | struct is_compatible_string_type_impl <
type is_compatible_string_type (line 1084) | struct is_compatible_string_type
type is_constructible_string_type_impl (line 1089) | struct is_constructible_string_type_impl : std::false_type {}
type is_constructible_string_type_impl <
BasicJsonType, ConstructibleStringType,
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, ConstructibleStringType>::value >> (line 1092) | struct is_constructible_string_type_impl <
type is_constructible_string_type (line 1103) | struct is_constructible_string_type
type is_compatible_array_type_impl (line 1107) | struct is_compatible_array_type_impl : std::false_type {}
type is_compatible_array_type (line 1126) | struct is_compatible_array_type
type is_constructible_array_type_impl (line 1130) | struct is_constructible_array_type_impl : std::false_type {}
type is_constructible_array_type_impl <
BasicJsonType, ConstructibleArrayType,
enable_if_t<std::is_same<ConstructibleArrayType,
typename BasicJsonType::value_type>::value >> (line 1133) | struct is_constructible_array_type_impl <
type is_constructible_array_type_impl <
BasicJsonType, ConstructibleArrayType,
enable_if_t<not std::is_same<ConstructibleArrayType,
typename BasicJsonType::value_type>::value and
is_detected<value_type_t, ConstructibleArrayType>::value and
is_detected<iterator_t, ConstructibleArrayType>::value and
is_complete_type<
detected_t<value_type_t, ConstructibleArrayType>>::value >> (line 1140) | struct is_constructible_array_type_impl <
type is_constructible_array_type (line 1165) | struct is_constructible_array_type
type is_compatible_integer_type_impl (line 1170) | struct is_compatible_integer_type_impl : std::false_type {}
type is_compatible_integer_type_impl <
RealIntegerType, CompatibleNumberIntegerType,
enable_if_t<std::is_integral<RealIntegerType>::value and
std::is_integral<CompatibleNumberIntegerType>::value and
not std::is_same<bool, CompatibleNumberIntegerType>::value >> (line 1173) | struct is_compatible_integer_type_impl <
type is_compatible_integer_type (line 1191) | struct is_compatible_integer_type
type is_compatible_type_impl (line 1196) | struct is_compatible_type_impl: std::false_type {}
type is_compatible_type_impl <
BasicJsonType, CompatibleType,
enable_if_t<is_complete_type<CompatibleType>::value >> (line 1199) | struct is_compatible_type_impl <
type is_compatible_type (line 1208) | struct is_compatible_type
type value_t (line 1254) | enum class value_t : std::uint8_t
function from_json (line 1298) | void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
function get_arithmetic_value (line 1312) | void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
function from_json (line 1338) | void from_json(const BasicJsonType& j, typename BasicJsonType::boole...
function from_json (line 1348) | void from_json(const BasicJsonType& j, typename BasicJsonType::strin...
function from_json (line 1364) | void from_json(const BasicJsonType& j, ConstructibleStringType& s)
function from_json (line 1375) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1381) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1387) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1394) | void from_json(const BasicJsonType& j, EnumType& e)
function from_json (line 1404) | void from_json(const BasicJsonType& j, std::forward_list<T, Allocato...
function from_json (line 1420) | void from_json(const BasicJsonType& j, std::valarray<T>& l)
function from_json_array_impl (line 1431) | void from_json_array_impl(const BasicJsonType& j, typename BasicJson...
function from_json_array_impl (line 1437) | auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& ...
function from_json_array_impl (line 1448) | auto from_json_array_impl(const BasicJsonType& j, ConstructibleArray...
function from_json_array_impl (line 1467) | void from_json_array_impl(const BasicJsonType& j, ConstructibleArray...
function from_json (line 1490) | auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
function from_json (line 1506) | void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
function from_json (line 1536) | void from_json(const BasicJsonType& j, ArithmeticType& val)
function from_json (line 1567) | void from_json(const BasicJsonType& j, std::pair<A1, A2>& p)
function from_json_tuple_impl (line 1573) | void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_se...
function from_json (line 1579) | void from_json(const BasicJsonType& j, std::tuple<Args...>& t)
function from_json (line 1587) | void from_json(const BasicJsonType& j, std::map<Key, Value, Compare,...
function from_json (line 1606) | void from_json(const BasicJsonType& j, std::unordered_map<Key, Value...
type from_json_fn (line 1622) | struct from_json_fn
class iteration_proxy_value (line 1673) | class iteration_proxy_value
method iteration_proxy_value (line 1695) | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(...
method iteration_proxy_value (line 1698) | iteration_proxy_value& operator*()
method iteration_proxy_value (line 1704) | iteration_proxy_value& operator++()
method value (line 1753) | typename IteratorType::reference value() const
class iteration_proxy (line 1760) | class iteration_proxy
method iteration_proxy (line 1768) | explicit iteration_proxy(typename IteratorType::reference cont) no...
method begin (line 1772) | iteration_proxy_value<IteratorType> begin() noexcept
method end (line 1778) | iteration_proxy_value<IteratorType> end() noexcept
function get (line 1787) | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>...
function get (line 1795) | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>...
type external_constructor (line 1845) | struct external_constructor
type external_constructor<value_t::boolean> (line 1848) | struct external_constructor<value_t::boolean>
method construct (line 1851) | static void construct(BasicJsonType& j, typename BasicJsonType::bo...
type external_constructor<value_t::string> (line 1860) | struct external_constructor<value_t::string>
method construct (line 1863) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1871) | static void construct(BasicJsonType& j, typename BasicJsonType::st...
method construct (line 1881) | static void construct(BasicJsonType& j, const CompatibleStringType...
type external_constructor<value_t::number_float> (line 1890) | struct external_constructor<value_t::number_float>
method construct (line 1893) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::number_unsigned> (line 1902) | struct external_constructor<value_t::number_unsigned>
method construct (line 1905) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::number_integer> (line 1914) | struct external_constructor<value_t::number_integer>
method construct (line 1917) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::array> (line 1926) | struct external_constructor<value_t::array>
method construct (line 1929) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1937) | static void construct(BasicJsonType& j, typename BasicJsonType::ar...
method construct (line 1947) | static void construct(BasicJsonType& j, const CompatibleArrayType&...
method construct (line 1957) | static void construct(BasicJsonType& j, const std::vector<bool>& arr)
method construct (line 1971) | static void construct(BasicJsonType& j, const std::valarray<T>& arr)
type external_constructor<value_t::object> (line 1982) | struct external_constructor<value_t::object>
method construct (line 1985) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1993) | static void construct(BasicJsonType& j, typename BasicJsonType::ob...
method construct (line 2002) | static void construct(BasicJsonType& j, const CompatibleObjectType...
function to_json (line 2019) | void to_json(BasicJsonType& j, T b) noexcept
function to_json (line 2026) | void to_json(BasicJsonType& j, const CompatibleString& s)
function to_json (line 2032) | void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
function to_json (line 2039) | void to_json(BasicJsonType& j, FloatType val) noexcept
function to_json (line 2046) | void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noe...
function to_json (line 2053) | void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noex...
function to_json (line 2060) | void to_json(BasicJsonType& j, EnumType e) noexcept
function to_json (line 2067) | void to_json(BasicJsonType& j, const std::vector<bool>& e)
function to_json (line 2080) | void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
function to_json (line 2087) | void to_json(BasicJsonType& j, const std::valarray<T>& arr)
function to_json (line 2093) | void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
function to_json (line 2100) | void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
function to_json (line 2106) | void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
function to_json (line 2116) | void to_json(BasicJsonType& j, const T(&arr)[N])
function to_json (line 2122) | void to_json(BasicJsonType& j, const std::pair<Args...>& p)
function to_json (line 2130) | void to_json(BasicJsonType& j, const T& b)
function to_json_tuple_impl (line 2136) | void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequ...
function to_json (line 2142) | void to_json(BasicJsonType& j, const std::tuple<Args...>& t)
type to_json_fn (line 2147) | struct to_json_fn
type input_format_t (line 2259) | enum class input_format_t { json, cbor, msgpack, ubjson, bson }
type input_adapter_protocol (line 2276) | struct input_adapter_protocol
class file_input_adapter (line 2290) | class file_input_adapter : public input_adapter_protocol
method file_input_adapter (line 2293) | explicit file_input_adapter(std::FILE* f) noexcept
method file_input_adapter (line 2298) | file_input_adapter(const file_input_adapter&) = delete;
method file_input_adapter (line 2299) | file_input_adapter(file_input_adapter&&) = default;
method file_input_adapter (line 2300) | file_input_adapter& operator=(const file_input_adapter&) = delete;
method file_input_adapter (line 2301) | file_input_adapter& operator=(file_input_adapter&&) = default;
method get_character (line 2304) | std::char_traits<char>::int_type get_character() noexcept override
class input_stream_adapter (line 2324) | class input_stream_adapter : public input_adapter_protocol
method input_stream_adapter (line 2334) | explicit input_stream_adapter(std::istream& i)
method input_stream_adapter (line 2339) | input_stream_adapter(const input_stream_adapter&) = delete;
method input_stream_adapter (line 2340) | input_stream_adapter& operator=(input_stream_adapter&) = delete;
method input_stream_adapter (line 2341) | input_stream_adapter(input_stream_adapter&&) = delete;
method input_stream_adapter (line 2342) | input_stream_adapter& operator=(input_stream_adapter&&) = delete;
method get_character (line 2347) | std::char_traits<char>::int_type get_character() override
class input_buffer_adapter (line 2365) | class input_buffer_adapter : public input_adapter_protocol
method input_buffer_adapter (line 2368) | input_buffer_adapter(const char* b, const std::size_t l) noexcept
method input_buffer_adapter (line 2373) | input_buffer_adapter(const input_buffer_adapter&) = delete;
method input_buffer_adapter (line 2374) | input_buffer_adapter& operator=(input_buffer_adapter&) = delete;
method input_buffer_adapter (line 2375) | input_buffer_adapter(input_buffer_adapter&&) = delete;
method input_buffer_adapter (line 2376) | input_buffer_adapter& operator=(input_buffer_adapter&&) = delete;
method get_character (line 2379) | std::char_traits<char>::int_type get_character() noexcept override
type wide_string_input_helper (line 2397) | struct wide_string_input_helper
method fill_buffer (line 2400) | static void fill_buffer(const WideStringType& str,
type wide_string_input_helper<WideStringType, 2> (line 2456) | struct wide_string_input_helper<WideStringType, 2>
method fill_buffer (line 2459) | static void fill_buffer(const WideStringType& str,
class wide_string_input_adapter (line 2521) | class wide_string_input_adapter : public input_adapter_protocol
method wide_string_input_adapter (line 2524) | explicit wide_string_input_adapter(const WideStringType& w) noexcept
method get_character (line 2528) | std::char_traits<char>::int_type get_character() noexcept override
method fill_buffer (line 2547) | void fill_buffer()
class input_adapter (line 2567) | class input_adapter
method input_adapter (line 2571) | input_adapter(std::FILE* file)
method input_adapter (line 2574) | input_adapter(std::istream& i)
method input_adapter (line 2578) | input_adapter(std::istream&& i)
method input_adapter (line 2581) | input_adapter(const std::wstring& ws)
method input_adapter (line 2584) | input_adapter(const std::u16string& ws)
method input_adapter (line 2587) | input_adapter(const std::u32string& ws)
method input_adapter (line 2597) | input_adapter(CharT b, std::size_t l)
method input_adapter (line 2609) | input_adapter(CharT b)
method input_adapter (line 2618) | input_adapter(IteratorType first, IteratorType last)
method input_adapter (line 2653) | input_adapter(T (&array)[N])
method input_adapter (line 2661) | input_adapter(const ContiguousContainer& c)
class json_sax_dom_parser (line 2823) | class json_sax_dom_parser
method json_sax_dom_parser (line 2836) | explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_ex...
method json_sax_dom_parser (line 2841) | json_sax_dom_parser(const json_sax_dom_parser&) = delete;
method json_sax_dom_parser (line 2842) | json_sax_dom_parser(json_sax_dom_parser&&) = default;
method json_sax_dom_parser (line 2843) | json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete;
method json_sax_dom_parser (line 2844) | json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default;
method null (line 2847) | bool null()
method boolean (line 2853) | bool boolean(bool val)
method number_integer (line 2859) | bool number_integer(number_integer_t val)
method number_unsigned (line 2865) | bool number_unsigned(number_unsigned_t val)
method number_float (line 2871) | bool number_float(number_float_t val, const string_t& /*unused*/)
method string (line 2877) | bool string(string_t& val)
method start_object (line 2883) | bool start_object(std::size_t len)
method key (line 2896) | bool key(string_t& val)
method end_object (line 2903) | bool end_object()
method start_array (line 2909) | bool start_array(std::size_t len)
method end_array (line 2922) | bool end_array()
method parse_error (line 2928) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
method is_errored (line 2956) | constexpr bool is_errored() const
method BasicJsonType (line 2969) | BasicJsonType* handle_value(Value&& v)
class json_sax_dom_callback_parser (line 3004) | class json_sax_dom_callback_parser
method json_sax_dom_callback_parser (line 3014) | json_sax_dom_callback_parser(BasicJsonType& r,
method json_sax_dom_callback_parser (line 3023) | json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) ...
method json_sax_dom_callback_parser (line 3024) | json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = def...
method json_sax_dom_callback_parser (line 3025) | json_sax_dom_callback_parser& operator=(const json_sax_dom_callbac...
method json_sax_dom_callback_parser (line 3026) | json_sax_dom_callback_parser& operator=(json_sax_dom_callback_pars...
method null (line 3029) | bool null()
method boolean (line 3035) | bool boolean(bool val)
method number_integer (line 3041) | bool number_integer(number_integer_t val)
method number_unsigned (line 3047) | bool number_unsigned(number_unsigned_t val)
method number_float (line 3053) | bool number_float(number_float_t val, const string_t& /*unused*/)
method string (line 3059) | bool string(string_t& val)
method start_object (line 3065) | bool start_object(std::size_t len)
method key (line 3083) | bool key(string_t& val)
method end_object (line 3100) | bool end_object()
method start_array (line 3129) | bool start_array(std::size_t len)
method end_array (line 3146) | bool end_array()
method parse_error (line 3174) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
method is_errored (line 3202) | constexpr bool is_errored() const
method handle_value (line 3224) | std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool...
class json_sax_acceptor (line 3308) | class json_sax_acceptor
method null (line 3316) | bool null()
method boolean (line 3321) | bool boolean(bool /*unused*/)
method number_integer (line 3326) | bool number_integer(number_integer_t /*unused*/)
method number_unsigned (line 3331) | bool number_unsigned(number_unsigned_t /*unused*/)
method number_float (line 3336) | bool number_float(number_float_t /*unused*/, const string_t& /*unu...
method string (line 3341) | bool string(string_t& /*unused*/)
method start_object (line 3346) | bool start_object(std::size_t /*unused*/ = std::size_t(-1))
method key (line 3351) | bool key(string_t& /*unused*/)
method end_object (line 3356) | bool end_object()
method start_array (line 3361) | bool start_array(std::size_t /*unused*/ = std::size_t(-1))
method end_array (line 3366) | bool end_array()
method parse_error (line 3371) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
type is_sax (line 3445) | struct is_sax
type is_sax_static_asserts (line 3477) | struct is_sax_static_asserts
class binary_reader (line 3543) | class binary_reader
method binary_reader (line 3557) | explicit binary_reader(input_adapter_t adapter) : ia(std::move(ada...
method binary_reader (line 3564) | binary_reader(const binary_reader&) = delete;
method binary_reader (line 3565) | binary_reader(binary_reader&&) = default;
method binary_reader (line 3566) | binary_reader& operator=(const binary_reader&) = delete;
method binary_reader (line 3567) | binary_reader& operator=(binary_reader&&) = default;
method sax_parse (line 3577) | bool sax_parse(const input_format_t format,
method little_endianess (line 3635) | static constexpr bool little_endianess(int num = 1) noexcept
method parse_bson_internal (line 3649) | bool parse_bson_internal()
method get_bson_cstr (line 3674) | bool get_bson_cstr(string_t& result)
method get_bson_string (line 3706) | bool get_bson_string(const NumberType len, string_t& result)
method parse_bson_element_internal (line 3727) | bool parse_bson_element_internal(const int element_type,
method parse_bson_element_list (line 3798) | bool parse_bson_element_list(const bool is_array)
method parse_bson_array (line 3835) | bool parse_bson_array()
method parse_cbor_internal (line 3864) | bool parse_cbor_internal(const bool get_char = true)
method get_cbor_string (line 4206) | bool get_cbor_string(string_t& result)
method get_cbor_array (line 4295) | bool get_cbor_array(const std::size_t len)
method get_cbor_object (line 4331) | bool get_cbor_object(const std::size_t len)
method parse_msgpack_internal (line 4383) | bool parse_msgpack_internal()
method get_msgpack_string (line 4752) | bool get_msgpack_string(string_t& result)
method get_msgpack_array (line 4828) | bool get_msgpack_array(const std::size_t len)
method get_msgpack_object (line 4850) | bool get_msgpack_object(const std::size_t len)
method parse_ubjson_internal (line 4887) | bool parse_ubjson_internal(const bool get_char = true)
method get_ubjson_string (line 4906) | bool get_ubjson_string(string_t& result, const bool get_char = true)
method get_ubjson_size_value (line 4960) | bool get_ubjson_size_value(std::size_t& result)
method get_ubjson_size_type (line 5037) | bool get_ubjson_size_type(std::pair<std::size_t, int>& result)
method get_ubjson_value (line 5078) | bool get_ubjson_value(const int prefix)
method get_ubjson_array (line 5174) | bool get_ubjson_array()
method get_ubjson_object (line 5236) | bool get_ubjson_object()
method get (line 5321) | int get()
method get_ignore_noop (line 5330) | int get_ignore_noop()
method get_number (line 5355) | bool get_number(const input_format_t format, NumberType& result)
method get_string (line 5398) | bool get_string(const input_format_t format,
method unexpect_eof (line 5420) | bool unexpect_eof(const input_format_t format, const char* context...
method get_token_string (line 5433) | std::string get_token_string() const
method exception_message (line 5446) | std::string exception_message(const input_format_t format,
class lexer (line 5532) | class lexer
type token_type (line 5541) | enum class token_type
method lexer (line 5606) | explicit lexer(detail::input_adapter_t&& adapter)
method lexer (line 5610) | lexer(const lexer&) = delete;
method lexer (line 5611) | lexer(lexer&&) = delete;
method lexer (line 5612) | lexer& operator=(lexer&) = delete;
method lexer (line 5613) | lexer& operator=(lexer&&) = delete;
method get_decimal_point (line 5622) | static char get_decimal_point() noexcept
method get_codepoint (line 5648) | int get_codepoint()
method next_byte_in_range (line 5696) | bool next_byte_in_range(std::initializer_list<int> ranges)
method token_type (line 5733) | token_type scan_string()
method strtof (line 6319) | static void strtof(float& f, const char* str, char** endptr) noexcept
method strtof (line 6324) | static void strtof(double& f, const char* str, char** endptr) noex...
method strtof (line 6329) | static void strtof(long double& f, const char* str, char** endptr)...
method token_type (line 6374) | token_type scan_number() // lgtm [cpp/use-of-goto]
method token_type (line 6704) | token_type scan_literal(const char* literal_text, const std::size_...
method reset (line 6724) | void reset() noexcept
method get (line 6741) | std::char_traits<char>::int_type get()
method unget (line 6778) | void unget()
method add (line 6805) | void add(int c)
method number_integer_t (line 6816) | constexpr number_integer_t get_number_integer() const noexcept
method number_unsigned_t (line 6822) | constexpr number_unsigned_t get_number_unsigned() const noexcept
method number_float_t (line 6828) | constexpr number_float_t get_number_float() const noexcept
method string_t (line 6834) | string_t& get_string()
method position_t (line 6844) | constexpr position_t get_position() const noexcept
method get_token_string (line 6852) | std::string get_token_string() const
method skip_bom (line 6889) | bool skip_bom()
method token_type (line 6903) | token_type scan()
class parser (line 7047) | class parser
type parse_event_t (line 7057) | enum class parse_event_t : uint8_t
method parser (line 7077) | explicit parser(detail::input_adapter_t&& adapter,
method parse (line 7096) | void parse(const bool strict, BasicJsonType& result)
method accept (line 7157) | bool accept(const bool strict = true)
method sax_parse (line 7164) | bool sax_parse(SAX* sax, const bool strict = true)
method sax_parse_internal (line 7183) | bool sax_parse_internal(SAX* sax)
method token_type (line 7465) | token_type get_token()
method exception_message (line 7470) | std::string exception_message(const token_type expected, const std...
class primitive_iterator_t (line 7534) | class primitive_iterator_t
method difference_type (line 7545) | constexpr difference_type get_value() const noexcept
method set_begin (line 7551) | void set_begin() noexcept
method set_end (line 7557) | void set_end() noexcept
method is_begin (line 7563) | constexpr bool is_begin() const noexcept
method is_end (line 7569) | constexpr bool is_end() const noexcept
method primitive_iterator_t (line 7584) | primitive_iterator_t operator+(difference_type n) noexcept
method difference_type (line 7591) | constexpr difference_type operator-(primitive_iterator_t lhs, prim...
method primitive_iterator_t (line 7596) | primitive_iterator_t& operator++() noexcept
method primitive_iterator_t (line 7602) | primitive_iterator_t const operator++(int) noexcept
method primitive_iterator_t (line 7609) | primitive_iterator_t& operator--() noexcept
method primitive_iterator_t (line 7615) | primitive_iterator_t const operator--(int) noexcept
method primitive_iterator_t (line 7622) | primitive_iterator_t& operator+=(difference_type n) noexcept
method primitive_iterator_t (line 7628) | primitive_iterator_t& operator-=(difference_type n) noexcept
type internal_iterator (line 7648) | struct internal_iterator
class iteration_proxy (line 7687) | class iteration_proxy
method iteration_proxy (line 1768) | explicit iteration_proxy(typename IteratorType::reference cont) no...
method begin (line 1772) | iteration_proxy_value<IteratorType> begin() noexcept
method end (line 1778) | iteration_proxy_value<IteratorType> end() noexcept
class iteration_proxy_value (line 7688) | class iteration_proxy_value
method iteration_proxy_value (line 1695) | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(...
method iteration_proxy_value (line 1698) | iteration_proxy_value& operator*()
method iteration_proxy_value (line 1704) | iteration_proxy_value& operator++()
method value (line 1753) | typename IteratorType::reference value() const
class iter_impl (line 7707) | class iter_impl
method iter_impl (line 7745) | iter_impl() = default;
method iter_impl (line 7753) | explicit iter_impl(pointer object) noexcept : m_object(object)
method iter_impl (line 7793) | iter_impl(const iter_impl<typename std::remove_const<BasicJsonType...
method iter_impl (line 7802) | iter_impl& operator=(const iter_impl<typename std::remove_const<Ba...
method set_begin (line 7814) | void set_begin() noexcept
method set_end (line 7851) | void set_end() noexcept
method reference (line 7882) | reference operator*() const
method pointer (line 7919) | pointer operator->() const
method iter_impl (line 7953) | iter_impl const operator++(int)
method iter_impl (line 7964) | iter_impl& operator++()
method iter_impl (line 7996) | iter_impl const operator--(int)
method iter_impl (line 8007) | iter_impl& operator--()
method iter_impl (line 8129) | iter_impl& operator+=(difference_type i)
method iter_impl (line 8158) | iter_impl& operator-=(difference_type i)
method iter_impl (line 8167) | iter_impl operator+(difference_type i) const
method iter_impl (line 8178) | iter_impl operator+(difference_type i, const iter_impl& it)
method iter_impl (line 8189) | iter_impl operator-(difference_type i) const
method difference_type (line 8200) | difference_type operator-(const iter_impl& other) const
method reference (line 8221) | reference operator[](difference_type n) const
method reference (line 8268) | reference value() const
class json_reverse_iterator (line 8318) | class json_reverse_iterator : public std::reverse_iterator<Base>
method json_reverse_iterator (line 8328) | explicit json_reverse_iterator(const typename base_iterator::itera...
method json_reverse_iterator (line 8332) | explicit json_reverse_iterator(const base_iterator& it) noexcept :...
method json_reverse_iterator (line 8335) | json_reverse_iterator const operator++(int)
method json_reverse_iterator (line 8341) | json_reverse_iterator& operator++()
method json_reverse_iterator (line 8347) | json_reverse_iterator const operator--(int)
method json_reverse_iterator (line 8353) | json_reverse_iterator& operator--()
method json_reverse_iterator (line 8359) | json_reverse_iterator& operator+=(difference_type i)
method json_reverse_iterator (line 8365) | json_reverse_iterator operator+(difference_type i) const
method json_reverse_iterator (line 8371) | json_reverse_iterator operator-(difference_type i) const
method difference_type (line 8377) | difference_type operator-(const json_reverse_iterator& other) const
method reference (line 8383) | reference operator[](difference_type n) const
method key (line 8389) | auto key() const -> decltype(std::declval<Base>().key())
method reference (line 8396) | reference value() const
class json_ref (line 9365) | class json_ref
method json_ref (line 9370) | json_ref(value_type&& value)
method json_ref (line 9374) | json_ref(const value_type& value)
method json_ref (line 9378) | json_ref(std::initializer_list<json_ref> init)
method json_ref (line 9385) | json_ref(Args && ... args)
method json_ref (line 9390) | json_ref(json_ref&&) = default;
method json_ref (line 9391) | json_ref(const json_ref&) = delete;
method json_ref (line 9392) | json_ref& operator=(const json_ref&) = delete;
method json_ref (line 9393) | json_ref& operator=(json_ref&&) = delete;
method value_type (line 9396) | value_type moved_or_copied() const
method value_type (line 9405) | value_type const& operator*() const
method value_type (line 9410) | value_type const* operator->() const
type output_adapter_protocol (line 9458) | struct output_adapter_protocol
class output_vector_adapter (line 9471) | class output_vector_adapter : public output_adapter_protocol<CharType>
method output_vector_adapter (line 9474) | explicit output_vector_adapter(std::vector<CharType>& vec) noexcept
method write_character (line 9478) | void write_character(CharType c) override
method write_characters (line 9483) | void write_characters(const CharType* s, std::size_t length) override
class output_stream_adapter (line 9494) | class output_stream_adapter : public output_adapter_protocol<CharType>
method output_stream_adapter (line 9497) | explicit output_stream_adapter(std::basic_ostream<CharType>& s) no...
method write_character (line 9501) | void write_character(CharType c) override
method write_characters (line 9506) | void write_characters(const CharType* s, std::size_t length) override
class output_string_adapter (line 9517) | class output_string_adapter : public output_adapter_protocol<CharType>
method output_string_adapter (line 9520) | explicit output_string_adapter(StringType& s) noexcept
method write_character (line 9524) | void write_character(CharType c) override
method write_characters (line 9529) | void write_characters(const CharType* s, std::size_t length) override
class output_adapter (line 9539) | class output_adapter
method output_adapter (line 9542) | output_adapter(std::vector<CharType>& vec)
method output_adapter (line 9545) | output_adapter(std::basic_ostream<CharType>& s)
method output_adapter (line 9548) | output_adapter(StringType& s)
class binary_writer (line 9575) | class binary_writer
method binary_writer (line 9585) | explicit binary_writer(output_adapter_t<CharType> adapter) : oa(ad...
method write_bson (line 9594) | void write_bson(const BasicJsonType& j)
method write_cbor (line 9614) | void write_cbor(const BasicJsonType& j)
method write_msgpack (line 9858) | void write_msgpack(const BasicJsonType& j)
method write_ubjson (line 10100) | void write_ubjson(const BasicJsonType& j, const bool use_count,
method calc_bson_entry_header_size (line 10264) | static std::size_t calc_bson_entry_header_size(const string_t& name)
method write_bson_entry_header (line 10279) | void write_bson_entry_header(const string_t& name,
method write_bson_boolean (line 10291) | void write_bson_boolean(const string_t& name,
method write_bson_double (line 10301) | void write_bson_double(const string_t& name,
method calc_bson_string_size (line 10311) | static std::size_t calc_bson_string_size(const string_t& value)
method write_bson_string (line 10319) | void write_bson_string(const string_t& name,
method write_bson_null (line 10333) | void write_bson_null(const string_t& name)
method calc_bson_integer_size (line 10341) | static std::size_t calc_bson_integer_size(const std::int64_t value)
method write_bson_integer (line 10351) | void write_bson_integer(const string_t& name,
method calc_bson_unsigned_size (line 10369) | static constexpr std::size_t calc_bson_unsigned_size(const std::ui...
method write_bson_unsigned (line 10379) | void write_bson_unsigned(const string_t& name,
method write_bson_object_entry (line 10401) | void write_bson_object_entry(const string_t& name,
method calc_bson_array_size (line 10411) | static std::size_t calc_bson_array_size(const typename BasicJsonTy...
method write_bson_array (line 10427) | void write_bson_array(const string_t& name,
method calc_bson_element_size (line 10447) | static std::size_t calc_bson_element_size(const string_t& name,
method write_bson_element (line 10492) | void write_bson_element(const string_t& name,
method calc_bson_object_size (line 10535) | static std::size_t calc_bson_object_size(const typename BasicJsonT...
method write_bson_object (line 10550) | void write_bson_object(const typename BasicJsonType::object_t& value)
method CharType (line 10566) | static constexpr CharType get_cbor_float_prefix(float /*unused*/)
method CharType (line 10571) | static constexpr CharType get_cbor_float_prefix(double /*unused*/)
method CharType (line 10580) | static constexpr CharType get_msgpack_float_prefix(float /*unused*/)
method CharType (line 10585) | static constexpr CharType get_msgpack_float_prefix(double /*unused*/)
method write_number_with_ubjson_prefix (line 10597) | void write_number_with_ubjson_prefix(const NumberType n,
method write_number_with_ubjson_prefix (line 10610) | void write_number_with_ubjson_prefix(const NumberType n,
method write_number_with_ubjson_prefix (line 10663) | void write_number_with_ubjson_prefix(const NumberType n,
method CharType (line 10723) | CharType ubjson_prefix(const BasicJsonType& j) const noexcept
method CharType (line 10794) | static constexpr CharType get_ubjson_float_prefix(float /*unused*/)
method CharType (line 10799) | static constexpr CharType get_ubjson_float_prefix(double /*unused*/)
method write_number (line 10820) | void write_number(const NumberType n)
method CharType (line 10843) | static constexpr CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10850) | static CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10861) | static constexpr CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10872) | static constexpr CharType to_char_type(InputCharType x) noexcept
type dtoa_impl (line 10942) | namespace dtoa_impl
function Target (line 10946) | Target reinterpret_bits(const Source source)
type diyfp (line 10955) | struct diyfp // f * 2^e
method diyfp (line 10962) | constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_...
method diyfp (line 10968) | static diyfp sub(const diyfp& x, const diyfp& y) noexcept
method diyfp (line 10980) | static diyfp mul(const diyfp& x, const diyfp& y) noexcept
method diyfp (line 11045) | static diyfp normalize(diyfp x) noexcept
method diyfp (line 11062) | static diyfp normalize_to(const diyfp& x, const int target_expon...
type boundaries (line 11073) | struct boundaries
function boundaries (line 11087) | boundaries compute_boundaries(FloatType value)
type cached_power (line 11212) | struct cached_power // c = f * 2^e ~= 10^k
function cached_power (line 11226) | inline cached_power get_cached_power_for_binary_exponent(int e)
function find_largest_pow10 (line 11390) | inline int find_largest_pow10(const std::uint32_t n, std::uint32_t...
function grisu2_round (line 11446) | inline void grisu2_round(char* buf, int len, std::uint64_t dist, s...
function grisu2_digit_gen (line 11487) | inline void grisu2_digit_gen(char* buffer, int& length, int& decim...
function grisu2 (line 11727) | inline void grisu2(char* buf, int& len, int& decimal_exponent,
function grisu2 (line 11786) | void grisu2(char* buf, int& len, int& decimal_exponent, FloatType ...
type error_handler_t (line 12027) | enum class error_handler_t
class serializer (line 12035) | class serializer
method serializer (line 12050) | serializer(output_adapter_t<char> s, const char ichar,
method serializer (line 12062) | serializer(const serializer&) = delete;
method serializer (line 12063) | serializer& operator=(const serializer&) = delete;
method serializer (line 12064) | serializer(serializer&&) = delete;
method serializer (line 12065) | serializer& operator=(serializer&&) = delete;
method dump (line 12085) | void dump(const BasicJsonType& val, const bool pretty_print,
method dump_escaped (line 12295) | void dump_escaped(const string_t& s, const bool ensure_ascii)
method count_digits (line 12551) | inline unsigned int count_digits(number_unsigned_t x) noexcept
method dump_integer (line 12590) | void dump_integer(NumberType x)
method dump_float (line 12676) | void dump_float(number_float_t x)
method dump_float (line 12697) | void dump_float(number_float_t x, std::true_type /*is_ieee_single_...
method dump_float (line 12705) | void dump_float(number_float_t x, std::false_type /*is_ieee_single...
method decode (line 12775) | static std::uint8_t decode(std::uint8_t& state, std::uint32_t& cod...
type detail (line 111) | namespace detail
type position_t (line 89) | struct position_t
class exception (line 145) | class exception : public std::exception
method exception (line 158) | exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
method name (line 160) | static std::string name(const std::string& ename, int id_)
class parse_error (line 214) | class parse_error : public exception
method parse_error (line 226) | static parse_error create(int id_, const position_t& pos, const st...
method parse_error (line 233) | static parse_error create(int id_, std::size_t byte_, const std::s...
method parse_error (line 253) | parse_error(int id_, std::size_t byte_, const char* what_arg)
method position_string (line 256) | static std::string position_string(const position_t& pos)
class invalid_iterator (line 300) | class invalid_iterator : public exception
method invalid_iterator (line 303) | static invalid_iterator create(int id_, const std::string& what_arg)
method invalid_iterator (line 310) | invalid_iterator(int id_, const char* what_arg)
class type_error (line 353) | class type_error : public exception
method type_error (line 356) | static type_error create(int id_, const std::string& what_arg)
method type_error (line 363) | type_error(int id_, const char* what_arg) : exception(id_, what_ar...
class out_of_range (line 399) | class out_of_range : public exception
method out_of_range (line 402) | static out_of_range create(int id_, const std::string& what_arg)
method out_of_range (line 409) | out_of_range(int id_, const char* what_arg) : exception(id_, what_...
class other_error (line 436) | class other_error : public exception
method other_error (line 439) | static other_error create(int id_, const std::string& what_arg)
method other_error (line 446) | other_error(int id_, const char* what_arg) : exception(id_, what_a...
type index_sequence (line 625) | struct index_sequence
method size (line 629) | static constexpr std::size_t size() noexcept
type merge_and_renumber (line 636) | struct merge_and_renumber
type make_index_sequence (line 643) | struct make_index_sequence
type make_index_sequence<0> (line 647) | struct make_index_sequence<0> : index_sequence<> {}
type make_index_sequence<1> (line 648) | struct make_index_sequence<1> : index_sequence<0> {}
type priority_tag (line 654) | struct priority_tag : priority_tag < N - 1 > {}
type priority_tag<0> (line 655) | struct priority_tag<0> {}
type static_const (line 659) | struct static_const
type make_void (line 689) | struct make_void
type iterator_types (line 705) | struct iterator_types {}
type iterator_types <
It,
void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
typename It::reference, typename It::iterator_category >> (line 708) | struct iterator_types <
type iterator_traits (line 723) | struct iterator_traits
type iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >> (line 728) | struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
type iterator_traits<T*, enable_if_t<std::is_object<T>::value>> (line 734) | struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
type nonesuch (line 762) | struct nonesuch
method nonesuch (line 764) | nonesuch() = delete;
method nonesuch (line 766) | nonesuch(nonesuch const&) = delete;
method nonesuch (line 767) | nonesuch(nonesuch const&&) = delete;
type detector (line 776) | struct detector
type is_basic_json (line 902) | struct is_basic_json : std::false_type {}
type has_from_json (line 946) | struct has_from_json : std::false_type {}
type has_from_json<BasicJsonType, T,
enable_if_t<not is_basic_json<T>::value>> (line 949) | struct has_from_json<BasicJsonType, T,
type has_non_default_from_json (line 962) | struct has_non_default_from_json : std::false_type {}
type has_non_default_from_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>> (line 965) | struct has_non_default_from_json<BasicJsonType, T, enable_if_t<not i...
type has_to_json (line 977) | struct has_to_json : std::false_type {}
type has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>> (line 980) | struct has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T...
type is_iterator_traits (line 995) | struct is_iterator_traits : std::false_type {}
type is_iterator_traits<iterator_traits<T>> (line 998) | struct is_iterator_traits<iterator_traits<T>>
type is_complete_type (line 1015) | struct is_complete_type : std::false_type {}
type is_complete_type<T, decltype(void(sizeof(T)))> (line 1018) | struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_ty...
type is_compatible_object_type_impl (line 1022) | struct is_compatible_object_type_impl : std::false_type {}
type is_compatible_object_type_impl <
BasicJsonType, CompatibleObjectType,
enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value and
is_detected<key_type_t, CompatibleObjectType>::value >> (line 1025) | struct is_compatible_object_type_impl <
type is_compatible_object_type (line 1042) | struct is_compatible_object_type
type is_constructible_object_type_impl (line 1047) | struct is_constructible_object_type_impl : std::false_type {}
type is_constructible_object_type_impl <
BasicJsonType, ConstructibleObjectType,
enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value and
is_detected<key_type_t, ConstructibleObjectType>::value >> (line 1050) | struct is_constructible_object_type_impl <
type is_constructible_object_type (line 1065) | struct is_constructible_object_type
type is_compatible_string_type_impl (line 1071) | struct is_compatible_string_type_impl : std::false_type {}
type is_compatible_string_type_impl <
BasicJsonType, CompatibleStringType,
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, CompatibleStringType>::value >> (line 1074) | struct is_compatible_string_type_impl <
type is_compatible_string_type (line 1084) | struct is_compatible_string_type
type is_constructible_string_type_impl (line 1089) | struct is_constructible_string_type_impl : std::false_type {}
type is_constructible_string_type_impl <
BasicJsonType, ConstructibleStringType,
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, ConstructibleStringType>::value >> (line 1092) | struct is_constructible_string_type_impl <
type is_constructible_string_type (line 1103) | struct is_constructible_string_type
type is_compatible_array_type_impl (line 1107) | struct is_compatible_array_type_impl : std::false_type {}
type is_compatible_array_type (line 1126) | struct is_compatible_array_type
type is_constructible_array_type_impl (line 1130) | struct is_constructible_array_type_impl : std::false_type {}
type is_constructible_array_type_impl <
BasicJsonType, ConstructibleArrayType,
enable_if_t<std::is_same<ConstructibleArrayType,
typename BasicJsonType::value_type>::value >> (line 1133) | struct is_constructible_array_type_impl <
type is_constructible_array_type_impl <
BasicJsonType, ConstructibleArrayType,
enable_if_t<not std::is_same<ConstructibleArrayType,
typename BasicJsonType::value_type>::value and
is_detected<value_type_t, ConstructibleArrayType>::value and
is_detected<iterator_t, ConstructibleArrayType>::value and
is_complete_type<
detected_t<value_type_t, ConstructibleArrayType>>::value >> (line 1140) | struct is_constructible_array_type_impl <
type is_constructible_array_type (line 1165) | struct is_constructible_array_type
type is_compatible_integer_type_impl (line 1170) | struct is_compatible_integer_type_impl : std::false_type {}
type is_compatible_integer_type_impl <
RealIntegerType, CompatibleNumberIntegerType,
enable_if_t<std::is_integral<RealIntegerType>::value and
std::is_integral<CompatibleNumberIntegerType>::value and
not std::is_same<bool, CompatibleNumberIntegerType>::value >> (line 1173) | struct is_compatible_integer_type_impl <
type is_compatible_integer_type (line 1191) | struct is_compatible_integer_type
type is_compatible_type_impl (line 1196) | struct is_compatible_type_impl: std::false_type {}
type is_compatible_type_impl <
BasicJsonType, CompatibleType,
enable_if_t<is_complete_type<CompatibleType>::value >> (line 1199) | struct is_compatible_type_impl <
type is_compatible_type (line 1208) | struct is_compatible_type
type value_t (line 1254) | enum class value_t : std::uint8_t
function from_json (line 1298) | void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
function get_arithmetic_value (line 1312) | void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
function from_json (line 1338) | void from_json(const BasicJsonType& j, typename BasicJsonType::boole...
function from_json (line 1348) | void from_json(const BasicJsonType& j, typename BasicJsonType::strin...
function from_json (line 1364) | void from_json(const BasicJsonType& j, ConstructibleStringType& s)
function from_json (line 1375) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1381) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1387) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1394) | void from_json(const BasicJsonType& j, EnumType& e)
function from_json (line 1404) | void from_json(const BasicJsonType& j, std::forward_list<T, Allocato...
function from_json (line 1420) | void from_json(const BasicJsonType& j, std::valarray<T>& l)
function from_json_array_impl (line 1431) | void from_json_array_impl(const BasicJsonType& j, typename BasicJson...
function from_json_array_impl (line 1437) | auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& ...
function from_json_array_impl (line 1448) | auto from_json_array_impl(const BasicJsonType& j, ConstructibleArray...
function from_json_array_impl (line 1467) | void from_json_array_impl(const BasicJsonType& j, ConstructibleArray...
function from_json (line 1490) | auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
function from_json (line 1506) | void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
function from_json (line 1536) | void from_json(const BasicJsonType& j, ArithmeticType& val)
function from_json (line 1567) | void from_json(const BasicJsonType& j, std::pair<A1, A2>& p)
function from_json_tuple_impl (line 1573) | void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_se...
function from_json (line 1579) | void from_json(const BasicJsonType& j, std::tuple<Args...>& t)
function from_json (line 1587) | void from_json(const BasicJsonType& j, std::map<Key, Value, Compare,...
function from_json (line 1606) | void from_json(const BasicJsonType& j, std::unordered_map<Key, Value...
type from_json_fn (line 1622) | struct from_json_fn
class iteration_proxy_value (line 1673) | class iteration_proxy_value
method iteration_proxy_value (line 1695) | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(...
method iteration_proxy_value (line 1698) | iteration_proxy_value& operator*()
method iteration_proxy_value (line 1704) | iteration_proxy_value& operator++()
method value (line 1753) | typename IteratorType::reference value() const
class iteration_proxy (line 1760) | class iteration_proxy
method iteration_proxy (line 1768) | explicit iteration_proxy(typename IteratorType::reference cont) no...
method begin (line 1772) | iteration_proxy_value<IteratorType> begin() noexcept
method end (line 1778) | iteration_proxy_value<IteratorType> end() noexcept
function get (line 1787) | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>...
function get (line 1795) | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>...
type external_constructor (line 1845) | struct external_constructor
type external_constructor<value_t::boolean> (line 1848) | struct external_constructor<value_t::boolean>
method construct (line 1851) | static void construct(BasicJsonType& j, typename BasicJsonType::bo...
type external_constructor<value_t::string> (line 1860) | struct external_constructor<value_t::string>
method construct (line 1863) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1871) | static void construct(BasicJsonType& j, typename BasicJsonType::st...
method construct (line 1881) | static void construct(BasicJsonType& j, const CompatibleStringType...
type external_constructor<value_t::number_float> (line 1890) | struct external_constructor<value_t::number_float>
method construct (line 1893) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::number_unsigned> (line 1902) | struct external_constructor<value_t::number_unsigned>
method construct (line 1905) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::number_integer> (line 1914) | struct external_constructor<value_t::number_integer>
method construct (line 1917) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::array> (line 1926) | struct external_constructor<value_t::array>
method construct (line 1929) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1937) | static void construct(BasicJsonType& j, typename BasicJsonType::ar...
method construct (line 1947) | static void construct(BasicJsonType& j, const CompatibleArrayType&...
method construct (line 1957) | static void construct(BasicJsonType& j, const std::vector<bool>& arr)
method construct (line 1971) | static void construct(BasicJsonType& j, const std::valarray<T>& arr)
type external_constructor<value_t::object> (line 1982) | struct external_constructor<value_t::object>
method construct (line 1985) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1993) | static void construct(BasicJsonType& j, typename BasicJsonType::ob...
method construct (line 2002) | static void construct(BasicJsonType& j, const CompatibleObjectType...
function to_json (line 2019) | void to_json(BasicJsonType& j, T b) noexcept
function to_json (line 2026) | void to_json(BasicJsonType& j, const CompatibleString& s)
function to_json (line 2032) | void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
function to_json (line 2039) | void to_json(BasicJsonType& j, FloatType val) noexcept
function to_json (line 2046) | void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noe...
function to_json (line 2053) | void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noex...
function to_json (line 2060) | void to_json(BasicJsonType& j, EnumType e) noexcept
function to_json (line 2067) | void to_json(BasicJsonType& j, const std::vector<bool>& e)
function to_json (line 2080) | void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
function to_json (line 2087) | void to_json(BasicJsonType& j, const std::valarray<T>& arr)
function to_json (line 2093) | void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
function to_json (line 2100) | void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
function to_json (line 2106) | void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
function to_json (line 2116) | void to_json(BasicJsonType& j, const T(&arr)[N])
function to_json (line 2122) | void to_json(BasicJsonType& j, const std::pair<Args...>& p)
function to_json (line 2130) | void to_json(BasicJsonType& j, const T& b)
function to_json_tuple_impl (line 2136) | void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequ...
function to_json (line 2142) | void to_json(BasicJsonType& j, const std::tuple<Args...>& t)
type to_json_fn (line 2147) | struct to_json_fn
type input_format_t (line 2259) | enum class input_format_t { json, cbor, msgpack, ubjson, bson }
type input_adapter_protocol (line 2276) | struct input_adapter_protocol
class file_input_adapter (line 2290) | class file_input_adapter : public input_adapter_protocol
method file_input_adapter (line 2293) | explicit file_input_adapter(std::FILE* f) noexcept
method file_input_adapter (line 2298) | file_input_adapter(const file_input_adapter&) = delete;
method file_input_adapter (line 2299) | file_input_adapter(file_input_adapter&&) = default;
method file_input_adapter (line 2300) | file_input_adapter& operator=(const file_input_adapter&) = delete;
method file_input_adapter (line 2301) | file_input_adapter& operator=(file_input_adapter&&) = default;
method get_character (line 2304) | std::char_traits<char>::int_type get_character() noexcept override
class input_stream_adapter (line 2324) | class input_stream_adapter : public input_adapter_protocol
method input_stream_adapter (line 2334) | explicit input_stream_adapter(std::istream& i)
method input_stream_adapter (line 2339) | input_stream_adapter(const input_stream_adapter&) = delete;
method input_stream_adapter (line 2340) | input_stream_adapter& operator=(input_stream_adapter&) = delete;
method input_stream_adapter (line 2341) | input_stream_adapter(input_stream_adapter&&) = delete;
method input_stream_adapter (line 2342) | input_stream_adapter& operator=(input_stream_adapter&&) = delete;
method get_character (line 2347) | std::char_traits<char>::int_type get_character() override
class input_buffer_adapter (line 2365) | class input_buffer_adapter : public input_adapter_protocol
method input_buffer_adapter (line 2368) | input_buffer_adapter(const char* b, const std::size_t l) noexcept
method input_buffer_adapter (line 2373) | input_buffer_adapter(const input_buffer_adapter&) = delete;
method input_buffer_adapter (line 2374) | input_buffer_adapter& operator=(input_buffer_adapter&) = delete;
method input_buffer_adapter (line 2375) | input_buffer_adapter(input_buffer_adapter&&) = delete;
method input_buffer_adapter (line 2376) | input_buffer_adapter& operator=(input_buffer_adapter&&) = delete;
method get_character (line 2379) | std::char_traits<char>::int_type get_character() noexcept override
type wide_string_input_helper (line 2397) | struct wide_string_input_helper
method fill_buffer (line 2400) | static void fill_buffer(const WideStringType& str,
type wide_string_input_helper<WideStringType, 2> (line 2456) | struct wide_string_input_helper<WideStringType, 2>
method fill_buffer (line 2459) | static void fill_buffer(const WideStringType& str,
class wide_string_input_adapter (line 2521) | class wide_string_input_adapter : public input_adapter_protocol
method wide_string_input_adapter (line 2524) | explicit wide_string_input_adapter(const WideStringType& w) noexcept
method get_character (line 2528) | std::char_traits<char>::int_type get_character() noexcept override
method fill_buffer (line 2547) | void fill_buffer()
class input_adapter (line 2567) | class input_adapter
method input_adapter (line 2571) | input_adapter(std::FILE* file)
method input_adapter (line 2574) | input_adapter(std::istream& i)
method input_adapter (line 2578) | input_adapter(std::istream&& i)
method input_adapter (line 2581) | input_adapter(const std::wstring& ws)
method input_adapter (line 2584) | input_adapter(const std::u16string& ws)
method input_adapter (line 2587) | input_adapter(const std::u32string& ws)
method input_adapter (line 2597) | input_adapter(CharT b, std::size_t l)
method input_adapter (line 2609) | input_adapter(CharT b)
method input_adapter (line 2618) | input_adapter(IteratorType first, IteratorType last)
method input_adapter (line 2653) | input_adapter(T (&array)[N])
method input_adapter (line 2661) | input_adapter(const ContiguousContainer& c)
class json_sax_dom_parser (line 2823) | class json_sax_dom_parser
method json_sax_dom_parser (line 2836) | explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_ex...
method json_sax_dom_parser (line 2841) | json_sax_dom_parser(const json_sax_dom_parser&) = delete;
method json_sax_dom_parser (line 2842) | json_sax_dom_parser(json_sax_dom_parser&&) = default;
method json_sax_dom_parser (line 2843) | json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete;
method json_sax_dom_parser (line 2844) | json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default;
method null (line 2847) | bool null()
method boolean (line 2853) | bool boolean(bool val)
method number_integer (line 2859) | bool number_integer(number_integer_t val)
method number_unsigned (line 2865) | bool number_unsigned(number_unsigned_t val)
method number_float (line 2871) | bool number_float(number_float_t val, const string_t& /*unused*/)
method string (line 2877) | bool string(string_t& val)
method start_object (line 2883) | bool start_object(std::size_t len)
method key (line 2896) | bool key(string_t& val)
method end_object (line 2903) | bool end_object()
method start_array (line 2909) | bool start_array(std::size_t len)
method end_array (line 2922) | bool end_array()
method parse_error (line 2928) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
method is_errored (line 2956) | constexpr bool is_errored() const
method BasicJsonType (line 2969) | BasicJsonType* handle_value(Value&& v)
class json_sax_dom_callback_parser (line 3004) | class json_sax_dom_callback_parser
method json_sax_dom_callback_parser (line 3014) | json_sax_dom_callback_parser(BasicJsonType& r,
method json_sax_dom_callback_parser (line 3023) | json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) ...
method json_sax_dom_callback_parser (line 3024) | json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = def...
method json_sax_dom_callback_parser (line 3025) | json_sax_dom_callback_parser& operator=(const json_sax_dom_callbac...
method json_sax_dom_callback_parser (line 3026) | json_sax_dom_callback_parser& operator=(json_sax_dom_callback_pars...
method null (line 3029) | bool null()
method boolean (line 3035) | bool boolean(bool val)
method number_integer (line 3041) | bool number_integer(number_integer_t val)
method number_unsigned (line 3047) | bool number_unsigned(number_unsigned_t val)
method number_float (line 3053) | bool number_float(number_float_t val, const string_t& /*unused*/)
method string (line 3059) | bool string(string_t& val)
method start_object (line 3065) | bool start_object(std::size_t len)
method key (line 3083) | bool key(string_t& val)
method end_object (line 3100) | bool end_object()
method start_array (line 3129) | bool start_array(std::size_t len)
method end_array (line 3146) | bool end_array()
method parse_error (line 3174) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
method is_errored (line 3202) | constexpr bool is_errored() const
method handle_value (line 3224) | std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool...
class json_sax_acceptor (line 3308) | class json_sax_acceptor
method null (line 3316) | bool null()
method boolean (line 3321) | bool boolean(bool /*unused*/)
method number_integer (line 3326) | bool number_integer(number_integer_t /*unused*/)
method number_unsigned (line 3331) | bool number_unsigned(number_unsigned_t /*unused*/)
method number_float (line 3336) | bool number_float(number_float_t /*unused*/, const string_t& /*unu...
method string (line 3341) | bool string(string_t& /*unused*/)
method start_object (line 3346) | bool start_object(std::size_t /*unused*/ = std::size_t(-1))
method key (line 3351) | bool key(string_t& /*unused*/)
method end_object (line 3356) | bool end_object()
method start_array (line 3361) | bool start_array(std::size_t /*unused*/ = std::size_t(-1))
method end_array (line 3366) | bool end_array()
method parse_error (line 3371) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
type is_sax (line 3445) | struct is_sax
type is_sax_static_asserts (line 3477) | struct is_sax_static_asserts
class binary_reader (line 3543) | class binary_reader
method binary_reader (line 3557) | explicit binary_reader(input_adapter_t adapter) : ia(std::move(ada...
method binary_reader (line 3564) | binary_reader(const binary_reader&) = delete;
method binary_reader (line 3565) | binary_reader(binary_reader&&) = default;
method binary_reader (line 3566) | binary_reader& operator=(const binary_reader&) = delete;
method binary_reader (line 3567) | binary_reader& operator=(binary_reader&&) = default;
method sax_parse (line 3577) | bool sax_parse(const input_format_t format,
method little_endianess (line 3635) | static constexpr bool little_endianess(int num = 1) noexcept
method parse_bson_internal (line 3649) | bool parse_bson_internal()
method get_bson_cstr (line 3674) | bool get_bson_cstr(string_t& result)
method get_bson_string (line 3706) | bool get_bson_string(const NumberType len, string_t& result)
method parse_bson_element_internal (line 3727) | bool parse_bson_element_internal(const int element_type,
method parse_bson_element_list (line 3798) | bool parse_bson_element_list(const bool is_array)
method parse_bson_array (line 3835) | bool parse_bson_array()
method parse_cbor_internal (line 3864) | bool parse_cbor_internal(const bool get_char = true)
method get_cbor_string (line 4206) | bool get_cbor_string(string_t& result)
method get_cbor_array (line 4295) | bool get_cbor_array(const std::size_t len)
method get_cbor_object (line 4331) | bool get_cbor_object(const std::size_t len)
method parse_msgpack_internal (line 4383) | bool parse_msgpack_internal()
method get_msgpack_string (line 4752) | bool get_msgpack_string(string_t& result)
method get_msgpack_array (line 4828) | bool get_msgpack_array(const std::size_t len)
method get_msgpack_object (line 4850) | bool get_msgpack_object(const std::size_t len)
method parse_ubjson_internal (line 4887) | bool parse_ubjson_internal(const bool get_char = true)
method get_ubjson_string (line 4906) | bool get_ubjson_string(string_t& result, const bool get_char = true)
method get_ubjson_size_value (line 4960) | bool get_ubjson_size_value(std::size_t& result)
method get_ubjson_size_type (line 5037) | bool get_ubjson_size_type(std::pair<std::size_t, int>& result)
method get_ubjson_value (line 5078) | bool get_ubjson_value(const int prefix)
method get_ubjson_array (line 5174) | bool get_ubjson_array()
method get_ubjson_object (line 5236) | bool get_ubjson_object()
method get (line 5321) | int get()
method get_ignore_noop (line 5330) | int get_ignore_noop()
method get_number (line 5355) | bool get_number(const input_format_t format, NumberType& result)
method get_string (line 5398) | bool get_string(const input_format_t format,
method unexpect_eof (line 5420) | bool unexpect_eof(const input_format_t format, const char* context...
method get_token_string (line 5433) | std::string get_token_string() const
method exception_message (line 5446) | std::string exception_message(const input_format_t format,
class lexer (line 5532) | class lexer
type token_type (line 5541) | enum class token_type
method lexer (line 5606) | explicit lexer(detail::input_adapter_t&& adapter)
method lexer (line 5610) | lexer(const lexer&) = delete;
method lexer (line 5611) | lexer(lexer&&) = delete;
method lexer (line 5612) | lexer& operator=(lexer&) = delete;
method lexer (line 5613) | lexer& operator=(lexer&&) = delete;
method get_decimal_point (line 5622) | static char get_decimal_point() noexcept
method get_codepoint (line 5648) | int get_codepoint()
method next_byte_in_range (line 5696) | bool next_byte_in_range(std::initializer_list<int> ranges)
method token_type (line 5733) | token_type scan_string()
method strtof (line 6319) | static void strtof(float& f, const char* str, char** endptr) noexcept
method strtof (line 6324) | static void strtof(double& f, const char* str, char** endptr) noex...
method strtof (line 6329) | static void strtof(long double& f, const char* str, char** endptr)...
method token_type (line 6374) | token_type scan_number() // lgtm [cpp/use-of-goto]
method token_type (line 6704) | token_type scan_literal(const char* literal_text, const std::size_...
method reset (line 6724) | void reset() noexcept
method get (line 6741) | std::char_traits<char>::int_type get()
method unget (line 6778) | void unget()
method add (line 6805) | void add(int c)
method number_integer_t (line 6816) | constexpr number_integer_t get_number_integer() const noexcept
method number_unsigned_t (line 6822) | constexpr number_unsigned_t get_number_unsigned() const noexcept
method number_float_t (line 6828) | constexpr number_float_t get_number_float() const noexcept
method string_t (line 6834) | string_t& get_string()
method position_t (line 6844) | constexpr position_t get_position() const noexcept
method get_token_string (line 6852) | std::string get_token_string() const
method skip_bom (line 6889) | bool skip_bom()
method token_type (line 6903) | token_type scan()
class parser (line 7047) | class parser
type parse_event_t (line 7057) | enum class parse_event_t : uint8_t
method parser (line 7077) | explicit parser(detail::input_adapter_t&& adapter,
method parse (line 7096) | void parse(const bool strict, BasicJsonType& result)
method accept (line 7157) | bool accept(const bool strict = true)
method sax_parse (line 7164) | bool sax_parse(SAX* sax, const bool strict = true)
method sax_parse_internal (line 7183) | bool sax_parse_internal(SAX* sax)
method token_type (line 7465) | token_type get_token()
method exception_message (line 7470) | std::string exception_message(const token_type expected, const std...
class primitive_iterator_t (line 7534) | class primitive_iterator_t
method difference_type (line 7545) | constexpr difference_type get_value() const noexcept
method set_begin (line 7551) | void set_begin() noexcept
method set_end (line 7557) | void set_end() noexcept
method is_begin (line 7563) | constexpr bool is_begin() const noexcept
method is_end (line 7569) | constexpr bool is_end() const noexcept
method primitive_iterator_t (line 7584) | primitive_iterator_t operator+(difference_type n) noexcept
method difference_type (line 7591) | constexpr difference_type operator-(primitive_iterator_t lhs, prim...
method primitive_iterator_t (line 7596) | primitive_iterator_t& operator++() noexcept
method primitive_iterator_t (line 7602) | primitive_iterator_t const operator++(int) noexcept
method primitive_iterator_t (line 7609) | primitive_iterator_t& operator--() noexcept
method primitive_iterator_t (line 7615) | primitive_iterator_t const operator--(int) noexcept
method primitive_iterator_t (line 7622) | primitive_iterator_t& operator+=(difference_type n) noexcept
method primitive_iterator_t (line 7628) | primitive_iterator_t& operator-=(difference_type n) noexcept
type internal_iterator (line 7648) | struct internal_iterator
class iteration_proxy (line 7687) | class iteration_proxy
method iteration_proxy (line 1768) | explicit iteration_proxy(typename IteratorType::reference cont) no...
method begin (line 1772) | iteration_proxy_value<IteratorType> begin() noexcept
method end (line 1778) | iteration_proxy_value<IteratorType> end() noexcept
class iteration_proxy_value (line 7688) | class iteration_proxy_value
method iteration_proxy_value (line 1695) | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(...
method iteration_proxy_value (line 1698) | iteration_proxy_value& operator*()
method iteration_proxy_value (line 1704) | iteration_proxy_value& operator++()
method value (line 1753) | typename IteratorType::reference value() const
class iter_impl (line 7707) | class iter_impl
method iter_impl (line 7745) | iter_impl() = default;
method iter_impl (line 7753) | explicit iter_impl(pointer object) noexcept : m_object(object)
method iter_impl (line 7793) | iter_impl(const iter_impl<typename std::remove_const<BasicJsonType...
method iter_impl (line 7802) | iter_impl& operator=(const iter_impl<typename std::remove_const<Ba...
method set_begin (line 7814) | void set_begin() noexcept
method set_end (line 7851) | void set_end() noexcept
method reference (line 7882) | reference operator*() const
method pointer (line 7919) | pointer operator->() const
method iter_impl (line 7953) | iter_impl const operator++(int)
method iter_impl (line 7964) | iter_impl& operator++()
method iter_impl (line 7996) | iter_impl const operator--(int)
method iter_impl (line 8007) | iter_impl& operator--()
method iter_impl (line 8129) | iter_impl& operator+=(difference_type i)
method iter_impl (line 8158) | iter_impl& operator-=(difference_type i)
method iter_impl (line 8167) | iter_impl operator+(difference_type i) const
method iter_impl (line 8178) | iter_impl operator+(difference_type i, const iter_impl& it)
method iter_impl (line 8189) | iter_impl operator-(difference_type i) const
method difference_type (line 8200) | difference_type operator-(const iter_impl& other) const
method reference (line 8221) | reference operator[](difference_type n) const
method reference (line 8268) | reference value() const
class json_reverse_iterator (line 8318) | class json_reverse_iterator : public std::reverse_iterator<Base>
method json_reverse_iterator (line 8328) | explicit json_reverse_iterator(const typename base_iterator::itera...
method json_reverse_iterator (line 8332) | explicit json_reverse_iterator(const base_iterator& it) noexcept :...
method json_reverse_iterator (line 8335) | json_reverse_iterator const operator++(int)
method json_reverse_iterator (line 8341) | json_reverse_iterator& operator++()
method json_reverse_iterator (line 8347) | json_reverse_iterator const operator--(int)
method json_reverse_iterator (line 8353) | json_reverse_iterator& operator--()
method json_reverse_iterator (line 8359) | json_reverse_iterator& operator+=(difference_type i)
method json_reverse_iterator (line 8365) | json_reverse_iterator operator+(difference_type i) const
method json_reverse_iterator (line 8371) | json_reverse_iterator operator-(difference_type i) const
method difference_type (line 8377) | difference_type operator-(const json_reverse_iterator& other) const
method reference (line 8383) | reference operator[](difference_type n) const
method key (line 8389) | auto key() const -> decltype(std::declval<Base>().key())
method reference (line 8396) | reference value() const
class json_ref (line 9365) | class json_ref
method json_ref (line 9370) | json_ref(value_type&& value)
method json_ref (line 9374) | json_ref(const value_type& value)
method json_ref (line 9378) | json_ref(std::initializer_list<json_ref> init)
method json_ref (line 9385) | json_ref(Args && ... args)
method json_ref (line 9390) | json_ref(json_ref&&) = default;
method json_ref (line 9391) | json_ref(const json_ref&) = delete;
method json_ref (line 9392) | json_ref& operator=(const json_ref&) = delete;
method json_ref (line 9393) | json_ref& operator=(json_ref&&) = delete;
method value_type (line 9396) | value_type moved_or_copied() const
method value_type (line 9405) | value_type const& operator*() const
method value_type (line 9410) | value_type const* operator->() const
type output_adapter_protocol (line 9458) | struct output_adapter_protocol
class output_vector_adapter (line 9471) | class output_vector_adapter : public output_adapter_protocol<CharType>
method output_vector_adapter (line 9474) | explicit output_vector_adapter(std::vector<CharType>& vec) noexcept
method write_character (line 9478) | void write_character(CharType c) override
method write_characters (line 9483) | void write_characters(const CharType* s, std::size_t length) override
class output_stream_adapter (line 9494) | class output_stream_adapter : public output_adapter_protocol<CharType>
method output_stream_adapter (line 9497) | explicit output_stream_adapter(std::basic_ostream<CharType>& s) no...
method write_character (line 9501) | void write_character(CharType c) override
method write_characters (line 9506) | void write_characters(const CharType* s, std::size_t length) override
class output_string_adapter (line 9517) | class output_string_adapter : public output_adapter_protocol<CharType>
method output_string_adapter (line 9520) | explicit output_string_adapter(StringType& s) noexcept
method write_character (line 9524) | void write_character(CharType c) override
method write_characters (line 9529) | void write_characters(const CharType* s, std::size_t length) override
class output_adapter (line 9539) | class output_adapter
method output_adapter (line 9542) | output_adapter(std::vector<CharType>& vec)
method output_adapter (line 9545) | output_adapter(std::basic_ostream<CharType>& s)
method output_adapter (line 9548) | output_adapter(StringType& s)
class binary_writer (line 9575) | class binary_writer
method binary_writer (line 9585) | explicit binary_writer(output_adapter_t<CharType> adapter) : oa(ad...
method write_bson (line 9594) | void write_bson(const BasicJsonType& j)
method write_cbor (line 9614) | void write_cbor(const BasicJsonType& j)
method write_msgpack (line 9858) | void write_msgpack(const BasicJsonType& j)
method write_ubjson (line 10100) | void write_ubjson(const BasicJsonType& j, const bool use_count,
method calc_bson_entry_header_size (line 10264) | static std::size_t calc_bson_entry_header_size(const string_t& name)
method write_bson_entry_header (line 10279) | void write_bson_entry_header(const string_t& name,
method write_bson_boolean (line 10291) | void write_bson_boolean(const string_t& name,
method write_bson_double (line 10301) | void write_bson_double(const string_t& name,
method calc_bson_string_size (line 10311) | static std::size_t calc_bson_string_size(const string_t& value)
method write_bson_string (line 10319) | void write_bson_string(const string_t& name,
method write_bson_null (line 10333) | void write_bson_null(const string_t& name)
method calc_bson_integer_size (line 10341) | static std::size_t calc_bson_integer_size(const std::int64_t value)
method write_bson_integer (line 10351) | void write_bson_integer(const string_t& name,
method calc_bson_unsigned_size (line 10369) | static constexpr std::size_t calc_bson_unsigned_size(const std::ui...
method write_bson_unsigned (line 10379) | void write_bson_unsigned(const string_t& name,
method write_bson_object_entry (line 10401) | void write_bson_object_entry(const string_t& name,
method calc_bson_array_size (line 10411) | static std::size_t calc_bson_array_size(const typename BasicJsonTy...
method write_bson_array (line 10427) | void write_bson_array(const string_t& name,
method calc_bson_element_size (line 10447) | static std::size_t calc_bson_element_size(const string_t& name,
method write_bson_element (line 10492) | void write_bson_element(const string_t& name,
method calc_bson_object_size (line 10535) | static std::size_t calc_bson_object_size(const typename BasicJsonT...
method write_bson_object (line 10550) | void write_bson_object(const typename BasicJsonType::object_t& value)
method CharType (line 10566) | static constexpr CharType get_cbor_float_prefix(float /*unused*/)
method CharType (line 10571) | static constexpr CharType get_cbor_float_prefix(double /*unused*/)
method CharType (line 10580) | static constexpr CharType get_msgpack_float_prefix(float /*unused*/)
method CharType (line 10585) | static constexpr CharType get_msgpack_float_prefix(double /*unused*/)
method write_number_with_ubjson_prefix (line 10597) | void write_number_with_ubjson_prefix(const NumberType n,
method write_number_with_ubjson_prefix (line 10610) | void write_number_with_ubjson_prefix(const NumberType n,
method write_number_with_ubjson_prefix (line 10663) | void write_number_with_ubjson_prefix(const NumberType n,
method CharType (line 10723) | CharType ubjson_prefix(const BasicJsonType& j) const noexcept
method CharType (line 10794) | static constexpr CharType get_ubjson_float_prefix(float /*unused*/)
method CharType (line 10799) | static constexpr CharType get_ubjson_float_prefix(double /*unused*/)
method write_number (line 10820) | void write_number(const NumberType n)
method CharType (line 10843) | static constexpr CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10850) | static CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10861) | static constexpr CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10872) | static constexpr CharType to_char_type(InputCharType x) noexcept
type dtoa_impl (line 10942) | namespace dtoa_impl
function Target (line 10946) | Target reinterpret_bits(const Source source)
type diyfp (line 10955) | struct diyfp // f * 2^e
method diyfp (line 10962) | constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_...
method diyfp (line 10968) | static diyfp sub(const diyfp& x, const diyfp& y) noexcept
method diyfp (line 10980) | static diyfp mul(const diyfp& x, const diyfp& y) noexcept
method diyfp (line 11045) | static diyfp normalize(diyfp x) noexcept
method diyfp (line 11062) | static diyfp normalize_to(const diyfp& x, const int target_expon...
type boundaries (line 11073) | struct boundaries
function boundaries (line 11087) | boundaries compute_boundaries(FloatType value)
type cached_power (line 11212) | struct cached_power // c = f * 2^e ~= 10^k
function cached_power (line 11226) | inline cached_power get_cached_power_for_binary_exponent(int e)
function find_largest_pow10 (line 11390) | inline int find_largest_pow10(const std::uint32_t n, std::uint32_t...
function grisu2_round (line 11446) | inline void grisu2_round(char* buf, int len, std::uint64_t dist, s...
function grisu2_digit_gen (line 11487) | inline void grisu2_digit_gen(char* buffer, int& length, int& decim...
function grisu2 (line 11727) | inline void grisu2(char* buf, int& len, int& decimal_exponent,
function grisu2 (line 11786) | void grisu2(char* buf, int& len, int& decimal_exponent, FloatType ...
type error_handler_t (line 12027) | enum class error_handler_t
class serializer (line 12035) | class serializer
method serializer (line 12050) | serializer(output_adapter_t<char> s, const char ichar,
method serializer (line 12062) | serializer(const serializer&) = delete;
method serializer (line 12063) | serializer& operator=(const serializer&) = delete;
method serializer (line 12064) | serializer(serializer&&) = delete;
method serializer (line 12065) | serializer& operator=(serializer&&) = delete;
method dump (line 12085) | void dump(const BasicJsonType& val, const bool pretty_print,
method dump_escaped (line 12295) | void dump_escaped(const string_t& s, const bool ensure_ascii)
method count_digits (line 12551) | inline unsigned int count_digits(number_unsigned_t x) noexcept
method dump_integer (line 12590) | void dump_integer(NumberType x)
method dump_float (line 12676) | void dump_float(number_float_t x)
method dump_float (line 12697) | void dump_float(number_float_t x, std::true_type /*is_ieee_single_...
method dump_float (line 12705) | void dump_float(number_float_t x, std::false_type /*is_ieee_single...
method decode (line 12775) | static std::uint8_t decode(std::uint8_t& state, std::uint32_t& cod...
type detail (line 613) | namespace detail
type position_t (line 89) | struct position_t
class exception (line 145) | class exception : public std::exception
method exception (line 158) | exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
method name (line 160) | static std::string name(const std::string& ename, int id_)
class parse_error (line 214) | class parse_error : public exception
method parse_error (line 226) | static parse_error create(int id_, const position_t& pos, const st...
method parse_error (line 233) | static parse_error create(int id_, std::size_t byte_, const std::s...
method parse_error (line 253) | parse_error(int id_, std::size_t byte_, const char* what_arg)
method position_string (line 256) | static std::string position_string(const position_t& pos)
class invalid_iterator (line 300) | class invalid_iterator : public exception
method invalid_iterator (line 303) | static invalid_iterator create(int id_, const std::string& what_arg)
method invalid_iterator (line 310) | invalid_iterator(int id_, const char* what_arg)
class type_error (line 353) | class type_error : public exception
method type_error (line 356) | static type_error create(int id_, const std::string& what_arg)
method type_error (line 363) | type_error(int id_, const char* what_arg) : exception(id_, what_ar...
class out_of_range (line 399) | class out_of_range : public exception
method out_of_range (line 402) | static out_of_range create(int id_, const std::string& what_arg)
method out_of_range (line 409) | out_of_range(int id_, const char* what_arg) : exception(id_, what_...
class other_error (line 436) | class other_error : public exception
method other_error (line 439) | static other_error create(int id_, const std::string& what_arg)
method other_error (line 446) | other_error(int id_, const char* what_arg) : exception(id_, what_a...
type index_sequence (line 625) | struct index_sequence
method size (line 629) | static constexpr std::size_t size() noexcept
type merge_and_renumber (line 636) | struct merge_and_renumber
type make_index_sequence (line 643) | struct make_index_sequence
type make_index_sequence<0> (line 647) | struct make_index_sequence<0> : index_sequence<> {}
type make_index_sequence<1> (line 648) | struct make_index_sequence<1> : index_sequence<0> {}
type priority_tag (line 654) | struct priority_tag : priority_tag < N - 1 > {}
type priority_tag<0> (line 655) | struct priority_tag<0> {}
type static_const (line 659) | struct static_const
type make_void (line 689) | struct make_void
type iterator_types (line 705) | struct iterator_types {}
type iterator_types <
It,
void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
typename It::reference, typename It::iterator_category >> (line 708) | struct iterator_types <
type iterator_traits (line 723) | struct iterator_traits
type iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >> (line 728) | struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
type iterator_traits<T*, enable_if_t<std::is_object<T>::value>> (line 734) | struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
type nonesuch (line 762) | struct nonesuch
method nonesuch (line 764) | nonesuch() = delete;
method nonesuch (line 766) | nonesuch(nonesuch const&) = delete;
method nonesuch (line 767) | nonesuch(nonesuch const&&) = delete;
type detector (line 776) | struct detector
type is_basic_json (line 902) | struct is_basic_json : std::false_type {}
type has_from_json (line 946) | struct has_from_json : std::false_type {}
type has_from_json<BasicJsonType, T,
enable_if_t<not is_basic_json<T>::value>> (line 949) | struct has_from_json<BasicJsonType, T,
type has_non_default_from_json (line 962) | struct has_non_default_from_json : std::false_type {}
type has_non_default_from_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>> (line 965) | struct has_non_default_from_json<BasicJsonType, T, enable_if_t<not i...
type has_to_json (line 977) | struct has_to_json : std::false_type {}
type has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>> (line 980) | struct has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T...
type is_iterator_traits (line 995) | struct is_iterator_traits : std::false_type {}
type is_iterator_traits<iterator_traits<T>> (line 998) | struct is_iterator_traits<iterator_traits<T>>
type is_complete_type (line 1015) | struct is_complete_type : std::false_type {}
type is_complete_type<T, decltype(void(sizeof(T)))> (line 1018) | struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_ty...
type is_compatible_object_type_impl (line 1022) | struct is_compatible_object_type_impl : std::false_type {}
type is_compatible_object_type_impl <
BasicJsonType, CompatibleObjectType,
enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value and
is_detected<key_type_t, CompatibleObjectType>::value >> (line 1025) | struct is_compatible_object_type_impl <
type is_compatible_object_type (line 1042) | struct is_compatible_object_type
type is_constructible_object_type_impl (line 1047) | struct is_constructible_object_type_impl : std::false_type {}
type is_constructible_object_type_impl <
BasicJsonType, ConstructibleObjectType,
enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value and
is_detected<key_type_t, ConstructibleObjectType>::value >> (line 1050) | struct is_constructible_object_type_impl <
type is_constructible_object_type (line 1065) | struct is_constructible_object_type
type is_compatible_string_type_impl (line 1071) | struct is_compatible_string_type_impl : std::false_type {}
type is_compatible_string_type_impl <
BasicJsonType, CompatibleStringType,
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, CompatibleStringType>::value >> (line 1074) | struct is_compatible_string_type_impl <
type is_compatible_string_type (line 1084) | struct is_compatible_string_type
type is_constructible_string_type_impl (line 1089) | struct is_constructible_string_type_impl : std::false_type {}
type is_constructible_string_type_impl <
BasicJsonType, ConstructibleStringType,
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, ConstructibleStringType>::value >> (line 1092) | struct is_constructible_string_type_impl <
type is_constructible_string_type (line 1103) | struct is_constructible_string_type
type is_compatible_array_type_impl (line 1107) | struct is_compatible_array_type_impl : std::false_type {}
type is_compatible_array_type (line 1126) | struct is_compatible_array_type
type is_constructible_array_type_impl (line 1130) | struct is_constructible_array_type_impl : std::false_type {}
type is_constructible_array_type_impl <
BasicJsonType, ConstructibleArrayType,
enable_if_t<std::is_same<ConstructibleArrayType,
typename BasicJsonType::value_type>::value >> (line 1133) | struct is_constructible_array_type_impl <
type is_constructible_array_type_impl <
BasicJsonType, ConstructibleArrayType,
enable_if_t<not std::is_same<ConstructibleArrayType,
typename BasicJsonType::value_type>::value and
is_detected<value_type_t, ConstructibleArrayType>::value and
is_detected<iterator_t, ConstructibleArrayType>::value and
is_complete_type<
detected_t<value_type_t, ConstructibleArrayType>>::value >> (line 1140) | struct is_constructible_array_type_impl <
type is_constructible_array_type (line 1165) | struct is_constructible_array_type
type is_compatible_integer_type_impl (line 1170) | struct is_compatible_integer_type_impl : std::false_type {}
type is_compatible_integer_type_impl <
RealIntegerType, CompatibleNumberIntegerType,
enable_if_t<std::is_integral<RealIntegerType>::value and
std::is_integral<CompatibleNumberIntegerType>::value and
not std::is_same<bool, CompatibleNumberIntegerType>::value >> (line 1173) | struct is_compatible_integer_type_impl <
type is_compatible_integer_type (line 1191) | struct is_compatible_integer_type
type is_compatible_type_impl (line 1196) | struct is_compatible_type_impl: std::false_type {}
type is_compatible_type_impl <
BasicJsonType, CompatibleType,
enable_if_t<is_complete_type<CompatibleType>::value >> (line 1199) | struct is_compatible_type_impl <
type is_compatible_type (line 1208) | struct is_compatible_type
type value_t (line 1254) | enum class value_t : std::uint8_t
function from_json (line 1298) | void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
function get_arithmetic_value (line 1312) | void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
function from_json (line 1338) | void from_json(const BasicJsonType& j, typename BasicJsonType::boole...
function from_json (line 1348) | void from_json(const BasicJsonType& j, typename BasicJsonType::strin...
function from_json (line 1364) | void from_json(const BasicJsonType& j, ConstructibleStringType& s)
function from_json (line 1375) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1381) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1387) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1394) | void from_json(const BasicJsonType& j, EnumType& e)
function from_json (line 1404) | void from_json(const BasicJsonType& j, std::forward_list<T, Allocato...
function from_json (line 1420) | void from_json(const BasicJsonType& j, std::valarray<T>& l)
function from_json_array_impl (line 1431) | void from_json_array_impl(const BasicJsonType& j, typename BasicJson...
function from_json_array_impl (line 1437) | auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& ...
function from_json_array_impl (line 1448) | auto from_json_array_impl(const BasicJsonType& j, ConstructibleArray...
function from_json_array_impl (line 1467) | void from_json_array_impl(const BasicJsonType& j, ConstructibleArray...
function from_json (line 1490) | auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
function from_json (line 1506) | void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
function from_json (line 1536) | void from_json(const BasicJsonType& j, ArithmeticType& val)
function from_json (line 1567) | void from_json(const BasicJsonType& j, std::pair<A1, A2>& p)
function from_json_tuple_impl (line 1573) | void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_se...
function from_json (line 1579) | void from_json(const BasicJsonType& j, std::tuple<Args...>& t)
function from_json (line 1587) | void from_json(const BasicJsonType& j, std::map<Key, Value, Compare,...
function from_json (line 1606) | void from_json(const BasicJsonType& j, std::unordered_map<Key, Value...
type from_json_fn (line 1622) | struct from_json_fn
class iteration_proxy_value (line 1673) | class iteration_proxy_value
method iteration_proxy_value (line 1695) | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(...
method iteration_proxy_value (line 1698) | iteration_proxy_value& operator*()
method iteration_proxy_value (line 1704) | iteration_proxy_value& operator++()
method value (line 1753) | typename IteratorType::reference value() const
class iteration_proxy (line 1760) | class iteration_proxy
method iteration_proxy (line 1768) | explicit iteration_proxy(typename IteratorType::reference cont) no...
method begin (line 1772) | iteration_proxy_value<IteratorType> begin() noexcept
method end (line 1778) | iteration_proxy_value<IteratorType> end() noexcept
function get (line 1787) | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>...
function get (line 1795) | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>...
type external_constructor (line 1845) | struct external_constructor
type external_constructor<value_t::boolean> (line 1848) | struct external_constructor<value_t::boolean>
method construct (line 1851) | static void construct(BasicJsonType& j, typename BasicJsonType::bo...
type external_constructor<value_t::string> (line 1860) | struct external_constructor<value_t::string>
method construct (line 1863) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1871) | static void construct(BasicJsonType& j, typename BasicJsonType::st...
method construct (line 1881) | static void construct(BasicJsonType& j, const CompatibleStringType...
type external_constructor<value_t::number_float> (line 1890) | struct external_constructor<value_t::number_float>
method construct (line 1893) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::number_unsigned> (line 1902) | struct external_constructor<value_t::number_unsigned>
method construct (line 1905) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::number_integer> (line 1914) | struct external_constructor<value_t::number_integer>
method construct (line 1917) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::array> (line 1926) | struct external_constructor<value_t::array>
method construct (line 1929) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1937) | static void construct(BasicJsonType& j, typename BasicJsonType::ar...
method construct (line 1947) | static void construct(BasicJsonType& j, const CompatibleArrayType&...
method construct (line 1957) | static void construct(BasicJsonType& j, const std::vector<bool>& arr)
method construct (line 1971) | static void construct(BasicJsonType& j, const std::valarray<T>& arr)
type external_constructor<value_t::object> (line 1982) | struct external_constructor<value_t::object>
method construct (line 1985) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1993) | static void construct(BasicJsonType& j, typename BasicJsonType::ob...
method construct (line 2002) | static void construct(BasicJsonType& j, const CompatibleObjectType...
function to_json (line 2019) | void to_json(BasicJsonType& j, T b) noexcept
function to_json (line 2026) | void to_json(BasicJsonType& j, const CompatibleString& s)
function to_json (line 2032) | void to_json(BasicJsonType& j, typename BasicJsonType::string_t&& s)
function to_json (line 2039) | void to_json(BasicJsonType& j, FloatType val) noexcept
function to_json (line 2046) | void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noe...
function to_json (line 2053) | void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noex...
function to_json (line 2060) | void to_json(BasicJsonType& j, EnumType e) noexcept
function to_json (line 2067) | void to_json(BasicJsonType& j, const std::vector<bool>& e)
function to_json (line 2080) | void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
function to_json (line 2087) | void to_json(BasicJsonType& j, const std::valarray<T>& arr)
function to_json (line 2093) | void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
function to_json (line 2100) | void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
function to_json (line 2106) | void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
function to_json (line 2116) | void to_json(BasicJsonType& j, const T(&arr)[N])
function to_json (line 2122) | void to_json(BasicJsonType& j, const std::pair<Args...>& p)
function to_json (line 2130) | void to_json(BasicJsonType& j, const T& b)
function to_json_tuple_impl (line 2136) | void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequ...
function to_json (line 2142) | void to_json(BasicJsonType& j, const std::tuple<Args...>& t)
type to_json_fn (line 2147) | struct to_json_fn
type input_format_t (line 2259) | enum class input_format_t { json, cbor, msgpack, ubjson, bson }
type input_adapter_protocol (line 2276) | struct input_adapter_protocol
class file_input_adapter (line 2290) | class file_input_adapter : public input_adapter_protocol
method file_input_adapter (line 2293) | explicit file_input_adapter(std::FILE* f) noexcept
method file_input_adapter (line 2298) | file_input_adapter(const file_input_adapter&) = delete;
method file_input_adapter (line 2299) | file_input_adapter(file_input_adapter&&) = default;
method file_input_adapter (line 2300) | file_input_adapter& operator=(const file_input_adapter&) = delete;
method file_input_adapter (line 2301) | file_input_adapter& operator=(file_input_adapter&&) = default;
method get_character (line 2304) | std::char_traits<char>::int_type get_character() noexcept override
class input_stream_adapter (line 2324) | class input_stream_adapter : public input_adapter_protocol
method input_stream_adapter (line 2334) | explicit input_stream_adapter(std::istream& i)
method input_stream_adapter (line 2339) | input_stream_adapter(const input_stream_adapter&) = delete;
method input_stream_adapter (line 2340) | input_stream_adapter& operator=(input_stream_adapter&) = delete;
method input_stream_adapter (line 2341) | input_stream_adapter(input_stream_adapter&&) = delete;
method input_stream_adapter (line 2342) | input_stream_adapter& operator=(input_stream_adapter&&) = delete;
method get_character (line 2347) | std::char_traits<char>::int_type get_character() override
class input_buffer_adapter (line 2365) | class input_buffer_adapter : public input_adapter_protocol
method input_buffer_adapter (line 2368) | input_buffer_adapter(const char* b, const std::size_t l) noexcept
method input_buffer_adapter (line 2373) | input_buffer_adapter(const input_buffer_adapter&) = delete;
method input_buffer_adapter (line 2374) | input_buffer_adapter& operator=(input_buffer_adapter&) = delete;
method input_buffer_adapter (line 2375) | input_buffer_adapter(input_buffer_adapter&&) = delete;
method input_buffer_adapter (line 2376) | input_buffer_adapter& operator=(input_buffer_adapter&&) = delete;
method get_character (line 2379) | std::char_traits<char>::int_type get_character() noexcept override
type wide_string_input_helper (line 2397) | struct wide_string_input_helper
method fill_buffer (line 2400) | static void fill_buffer(const WideStringType& str,
type wide_string_input_helper<WideStringType, 2> (line 2456) | struct wide_string_input_helper<WideStringType, 2>
method fill_buffer (line 2459) | static void fill_buffer(const WideStringType& str,
class wide_string_input_adapter (line 2521) | class wide_string_input_adapter : public input_adapter_protocol
method wide_string_input_adapter (line 2524) | explicit wide_string_input_adapter(const WideStringType& w) noexcept
method get_character (line 2528) | std::char_traits<char>::int_type get_character() noexcept override
method fill_buffer (line 2547) | void fill_buffer()
class input_adapter (line 2567) | class input_adapter
method input_adapter (line 2571) | input_adapter(std::FILE* file)
method input_adapter (line 2574) | input_adapter(std::istream& i)
method input_adapter (line 2578) | input_adapter(std::istream&& i)
method input_adapter (line 2581) | input_adapter(const std::wstring& ws)
method input_adapter (line 2584) | input_adapter(const std::u16string& ws)
method input_adapter (line 2587) | input_adapter(const std::u32string& ws)
method input_adapter (line 2597) | input_adapter(CharT b, std::size_t l)
method input_adapter (line 2609) | input_adapter(CharT b)
method input_adapter (line 2618) | input_adapter(IteratorType first, IteratorType last)
method input_adapter (line 2653) | input_adapter(T (&array)[N])
method input_adapter (line 2661) | input_adapter(const ContiguousContainer& c)
class json_sax_dom_parser (line 2823) | class json_sax_dom_parser
method json_sax_dom_parser (line 2836) | explicit json_sax_dom_parser(BasicJsonType& r, const bool allow_ex...
method json_sax_dom_parser (line 2841) | json_sax_dom_parser(const json_sax_dom_parser&) = delete;
method json_sax_dom_parser (line 2842) | json_sax_dom_parser(json_sax_dom_parser&&) = default;
method json_sax_dom_parser (line 2843) | json_sax_dom_parser& operator=(const json_sax_dom_parser&) = delete;
method json_sax_dom_parser (line 2844) | json_sax_dom_parser& operator=(json_sax_dom_parser&&) = default;
method null (line 2847) | bool null()
method boolean (line 2853) | bool boolean(bool val)
method number_integer (line 2859) | bool number_integer(number_integer_t val)
method number_unsigned (line 2865) | bool number_unsigned(number_unsigned_t val)
method number_float (line 2871) | bool number_float(number_float_t val, const string_t& /*unused*/)
method string (line 2877) | bool string(string_t& val)
method start_object (line 2883) | bool start_object(std::size_t len)
method key (line 2896) | bool key(string_t& val)
method end_object (line 2903) | bool end_object()
method start_array (line 2909) | bool start_array(std::size_t len)
method end_array (line 2922) | bool end_array()
method parse_error (line 2928) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
method is_errored (line 2956) | constexpr bool is_errored() const
method BasicJsonType (line 2969) | BasicJsonType* handle_value(Value&& v)
class json_sax_dom_callback_parser (line 3004) | class json_sax_dom_callback_parser
method json_sax_dom_callback_parser (line 3014) | json_sax_dom_callback_parser(BasicJsonType& r,
method json_sax_dom_callback_parser (line 3023) | json_sax_dom_callback_parser(const json_sax_dom_callback_parser&) ...
method json_sax_dom_callback_parser (line 3024) | json_sax_dom_callback_parser(json_sax_dom_callback_parser&&) = def...
method json_sax_dom_callback_parser (line 3025) | json_sax_dom_callback_parser& operator=(const json_sax_dom_callbac...
method json_sax_dom_callback_parser (line 3026) | json_sax_dom_callback_parser& operator=(json_sax_dom_callback_pars...
method null (line 3029) | bool null()
method boolean (line 3035) | bool boolean(bool val)
method number_integer (line 3041) | bool number_integer(number_integer_t val)
method number_unsigned (line 3047) | bool number_unsigned(number_unsigned_t val)
method number_float (line 3053) | bool number_float(number_float_t val, const string_t& /*unused*/)
method string (line 3059) | bool string(string_t& val)
method start_object (line 3065) | bool start_object(std::size_t len)
method key (line 3083) | bool key(string_t& val)
method end_object (line 3100) | bool end_object()
method start_array (line 3129) | bool start_array(std::size_t len)
method end_array (line 3146) | bool end_array()
method parse_error (line 3174) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
method is_errored (line 3202) | constexpr bool is_errored() const
method handle_value (line 3224) | std::pair<bool, BasicJsonType*> handle_value(Value&& v, const bool...
class json_sax_acceptor (line 3308) | class json_sax_acceptor
method null (line 3316) | bool null()
method boolean (line 3321) | bool boolean(bool /*unused*/)
method number_integer (line 3326) | bool number_integer(number_integer_t /*unused*/)
method number_unsigned (line 3331) | bool number_unsigned(number_unsigned_t /*unused*/)
method number_float (line 3336) | bool number_float(number_float_t /*unused*/, const string_t& /*unu...
method string (line 3341) | bool string(string_t& /*unused*/)
method start_object (line 3346) | bool start_object(std::size_t /*unused*/ = std::size_t(-1))
method key (line 3351) | bool key(string_t& /*unused*/)
method end_object (line 3356) | bool end_object()
method start_array (line 3361) | bool start_array(std::size_t /*unused*/ = std::size_t(-1))
method end_array (line 3366) | bool end_array()
method parse_error (line 3371) | bool parse_error(std::size_t /*unused*/, const std::string& /*unus...
type is_sax (line 3445) | struct is_sax
type is_sax_static_asserts (line 3477) | struct is_sax_static_asserts
class binary_reader (line 3543) | class binary_reader
method binary_reader (line 3557) | explicit binary_reader(input_adapter_t adapter) : ia(std::move(ada...
method binary_reader (line 3564) | binary_reader(const binary_reader&) = delete;
method binary_reader (line 3565) | binary_reader(binary_reader&&) = default;
method binary_reader (line 3566) | binary_reader& operator=(const binary_reader&) = delete;
method binary_reader (line 3567) | binary_reader& operator=(binary_reader&&) = default;
method sax_parse (line 3577) | bool sax_parse(const input_format_t format,
method little_endianess (line 3635) | static constexpr bool little_endianess(int num = 1) noexcept
method parse_bson_internal (line 3649) | bool parse_bson_internal()
method get_bson_cstr (line 3674) | bool get_bson_cstr(string_t& result)
method get_bson_string (line 3706) | bool get_bson_string(const NumberType len, string_t& result)
method parse_bson_element_internal (line 3727) | bool parse_bson_element_internal(const int element_type,
method parse_bson_element_list (line 3798) | bool parse_bson_element_list(const bool is_array)
method parse_bson_array (line 3835) | bool parse_bson_array()
method parse_cbor_internal (line 3864) | bool parse_cbor_internal(const bool get_char = true)
method get_cbor_string (line 4206) | bool get_cbor_string(string_t& result)
method get_cbor_array (line 4295) | bool get_cbor_array(const std::size_t len)
method get_cbor_object (line 4331) | bool get_cbor_object(const std::size_t len)
method parse_msgpack_internal (line 4383) | bool parse_msgpack_internal()
method get_msgpack_string (line 4752) | bool get_msgpack_string(string_t& result)
method get_msgpack_array (line 4828) | bool get_msgpack_array(const std::size_t len)
method get_msgpack_object (line 4850) | bool get_msgpack_object(const std::size_t len)
method parse_ubjson_internal (line 4887) | bool parse_ubjson_internal(const bool get_char = true)
method get_ubjson_string (line 4906) | bool get_ubjson_string(string_t& result, const bool get_char = true)
method get_ubjson_size_value (line 4960) | bool get_ubjson_size_value(std::size_t& result)
method get_ubjson_size_type (line 5037) | bool get_ubjson_size_type(std::pair<std::size_t, int>& result)
method get_ubjson_value (line 5078) | bool get_ubjson_value(const int prefix)
method get_ubjson_array (line 5174) | bool get_ubjson_array()
method get_ubjson_object (line 5236) | bool get_ubjson_object()
method get (line 5321) | int get()
method get_ignore_noop (line 5330) | int get_ignore_noop()
method get_number (line 5355) | bool get_number(const input_format_t format, NumberType& result)
method get_string (line 5398) | bool get_string(const input_format_t format,
method unexpect_eof (line 5420) | bool unexpect_eof(const input_format_t format, const char* context...
method get_token_string (line 5433) | std::string get_token_string() const
method exception_message (line 5446) | std::string exception_message(const input_format_t format,
class lexer (line 5532) | class lexer
type token_type (line 5541) | enum class token_type
method lexer (line 5606) | explicit lexer(detail::input_adapter_t&& adapter)
method lexer (line 5610) | lexer(const lexer&) = delete;
method lexer (line 5611) | lexer(lexer&&) = delete;
method lexer (line 5612) | lexer& operator=(lexer&) = delete;
method lexer (line 5613) | lexer& operator=(lexer&&) = delete;
method get_decimal_point (line 5622) | static char get_decimal_point() noexcept
method get_codepoint (line 5648) | int get_codepoint()
method next_byte_in_range (line 5696) | bool next_byte_in_range(std::initializer_list<int> ranges)
method token_type (line 5733) | token_type scan_string()
method strtof (line 6319) | static void strtof(float& f, const char* str, char** endptr) noexcept
method strtof (line 6324) | static void strtof(double& f, const char* str, char** endptr) noex...
method strtof (line 6329) | static void strtof(long double& f, const char* str, char** endptr)...
method token_type (line 6374) | token_type scan_number() // lgtm [cpp/use-of-goto]
method token_type (line 6704) | token_type scan_literal(const char* literal_text, const std::size_...
method reset (line 6724) | void reset() noexcept
method get (line 6741) | std::char_traits<char>::int_type get()
method unget (line 6778) | void unget()
method add (line 6805) | void add(int c)
method number_integer_t (line 6816) | constexpr number_integer_t get_number_integer() const noexcept
method number_unsigned_t (line 6822) | constexpr number_unsigned_t get_number_unsigned() const noexcept
method number_float_t (line 6828) | constexpr number_float_t get_number_float() const noexcept
method string_t (line 6834) | string_t& get_string()
method position_t (line 6844) | constexpr position_t get_position() const noexcept
method get_token_string (line 6852) | std::string get_token_string() const
method skip_bom (line 6889) | bool skip_bom()
method token_type (line 6903) | token_type scan()
class parser (line 7047) | class parser
type parse_event_t (line 7057) | enum class parse_event_t : uint8_t
method parser (line 7077) | explicit parser(detail::input_adapter_t&& adapter,
method parse (line 7096) | void parse(const bool strict, BasicJsonType& result)
method accept (line 7157) | bool accept(const bool strict = true)
method sax_parse (line 7164) | bool sax_parse(SAX* sax, const bool strict = true)
method sax_parse_internal (line 7183) | bool sax_parse_internal(SAX* sax)
method token_type (line 7465) | token_type get_token()
method exception_message (line 7470) | std::string exception_message(const token_type expected, const std...
class primitive_iterator_t (line 7534) | class primitive_iterator_t
method difference_type (line 7545) | constexpr difference_type get_value() const noexcept
method set_begin (line 7551) | void set_begin() noexcept
method set_end (line 7557) | void set_end() noexcept
method is_begin (line 7563) | constexpr bool is_begin() const noexcept
method is_end (line 7569) | constexpr bool is_end() const noexcept
method primitive_iterator_t (line 7584) | primitive_iterator_t operator+(difference_type n) noexcept
method difference_type (line 7591) | constexpr difference_type operator-(primitive_iterator_t lhs, prim...
method primitive_iterator_t (line 7596) | primitive_iterator_t& operator++() noexcept
method primitive_iterator_t (line 7602) | primitive_iterator_t const operator++(int) noexcept
method primitive_iterator_t (line 7609) | primitive_iterator_t& operator--() noexcept
method primitive_iterator_t (line 7615) | primitive_iterator_t const operator--(int) noexcept
method primitive_iterator_t (line 7622) | primitive_iterator_t& operator+=(difference_type n) noexcept
method primitive_iterator_t (line 7628) | primitive_iterator_t& operator-=(difference_type n) noexcept
type internal_iterator (line 7648) | struct internal_iterator
class iteration_proxy (line 7687) | class iteration_proxy
method iteration_proxy (line 1768) | explicit iteration_proxy(typename IteratorType::reference cont) no...
method begin (line 1772) | iteration_proxy_value<IteratorType> begin() noexcept
method end (line 1778) | iteration_proxy_value<IteratorType> end() noexcept
class iteration_proxy_value (line 7688) | class iteration_proxy_value
method iteration_proxy_value (line 1695) | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(...
method iteration_proxy_value (line 1698) | iteration_proxy_value& operator*()
method iteration_proxy_value (line 1704) | iteration_proxy_value& operator++()
method value (line 1753) | typename IteratorType::reference value() const
class iter_impl (line 7707) | class iter_impl
method iter_impl (line 7745) | iter_impl() = default;
method iter_impl (line 7753) | explicit iter_impl(pointer object) noexcept : m_object(object)
method iter_impl (line 7793) | iter_impl(const iter_impl<typename std::remove_const<BasicJsonType...
method iter_impl (line 7802) | iter_impl& operator=(const iter_impl<typename std::remove_const<Ba...
method set_begin (line 7814) | void set_begin() noexcept
method set_end (line 7851) | void set_end() noexcept
method reference (line 7882) | reference operator*() const
method pointer (line 7919) | pointer operator->() const
method iter_impl (line 7953) | iter_impl const operator++(int)
method iter_impl (line 7964) | iter_impl& operator++()
method iter_impl (line 7996) | iter_impl const operator--(int)
method iter_impl (line 8007) | iter_impl& operator--()
method iter_impl (line 8129) | iter_impl& operator+=(difference_type i)
method iter_impl (line 8158) | iter_impl& operator-=(difference_type i)
method iter_impl (line 8167) | iter_impl operator+(difference_type i) const
method iter_impl (line 8178) | iter_impl operator+(difference_type i, const iter_impl& it)
method iter_impl (line 8189) | iter_impl operator-(difference_type i) const
method difference_type (line 8200) | difference_type operator-(const iter_impl& other) const
method reference (line 8221) | reference operator[](difference_type n) const
method reference (line 8268) | reference value() const
class json_reverse_iterator (line 8318) | class json_reverse_iterator : public std::reverse_iterator<Base>
method json_reverse_iterator (line 8328) | explicit json_reverse_iterator(const typename base_iterator::itera...
method json_reverse_iterator (line 8332) | explicit json_reverse_iterator(const base_iterator& it) noexcept :...
method json_reverse_iterator (line 8335) | json_reverse_iterator const operator++(int)
method json_reverse_iterator (line 8341) | json_reverse_iterator& operator++()
method json_reverse_iterator (line 8347) | json_reverse_iterator const operator--(int)
method json_reverse_iterator (line 8353) | json_reverse_iterator& operator--()
method json_reverse_iterator (line 8359) | json_reverse_iterator& operator+=(difference_type i)
method json_reverse_iterator (line 8365) | json_reverse_iterator operator+(difference_type i) const
method json_reverse_iterator (line 8371) | json_reverse_iterator operator-(difference_type i) const
method difference_type (line 8377) | difference_type operator-(const json_reverse_iterator& other) const
method reference (line 8383) | reference operator[](difference_type n) const
method key (line 8389) | auto key() const -> decltype(std::declval<Base>().key())
method reference (line 8396) | reference value() const
class json_ref (line 9365) | class json_ref
method json_ref (line 9370) | json_ref(value_type&& value)
method json_ref (line 9374) | json_ref(const value_type& value)
method json_ref (line 9378) | json_ref(std::initializer_list<json_ref> init)
method json_ref (line 9385) | json_ref(Args && ... args)
method json_ref (line 9390) | json_ref(json_ref&&) = default;
method json_ref (line 9391) | json_ref(const json_ref&) = delete;
method json_ref (line 9392) | json_ref& operator=(const json_ref&) = delete;
method json_ref (line 9393) | json_ref& operator=(json_ref&&) = delete;
method value_type (line 9396) | value_type moved_or_copied() const
method value_type (line 9405) | value_type const& operator*() const
method value_type (line 9410) | value_type const* operator->() const
type output_adapter_protocol (line 9458) | struct output_adapter_protocol
class output_vector_adapter (line 9471) | class output_vector_adapter : public output_adapter_protocol<CharType>
method output_vector_adapter (line 9474) | explicit output_vector_adapter(std::vector<CharType>& vec) noexcept
method write_character (line 9478) | void write_character(CharType c) override
method write_characters (line 9483) | void write_characters(const CharType* s, std::size_t length) override
class output_stream_adapter (line 9494) | class output_stream_adapter : public output_adapter_protocol<CharType>
method output_stream_adapter (line 9497) | explicit output_stream_adapter(std::basic_ostream<CharType>& s) no...
method write_character (line 9501) | void write_character(CharType c) override
method write_characters (line 9506) | void write_characters(const CharType* s, std::size_t length) override
class output_string_adapter (line 9517) | class output_string_adapter : public output_adapter_protocol<CharType>
method output_string_adapter (line 9520) | explicit output_string_adapter(StringType& s) noexcept
method write_character (line 9524) | void write_character(CharType c) override
method write_characters (line 9529) | void write_characters(const CharType* s, std::size_t length) override
class output_adapter (line 9539) | class output_adapter
method output_adapter (line 9542) | output_adapter(std::vector<CharType>& vec)
method output_adapter (line 9545) | output_adapter(std::basic_ostream<CharType>& s)
method output_adapter (line 9548) | output_adapter(StringType& s)
class binary_writer (line 9575) | class binary_writer
method binary_writer (line 9585) | explicit binary_writer(output_adapter_t<CharType> adapter) : oa(ad...
method write_bson (line 9594) | void write_bson(const BasicJsonType& j)
method write_cbor (line 9614) | void write_cbor(const BasicJsonType& j)
method write_msgpack (line 9858) | void write_msgpack(const BasicJsonType& j)
method write_ubjson (line 10100) | void write_ubjson(const BasicJsonType& j, const bool use_count,
method calc_bson_entry_header_size (line 10264) | static std::size_t calc_bson_entry_header_size(const string_t& name)
method write_bson_entry_header (line 10279) | void write_bson_entry_header(const string_t& name,
method write_bson_boolean (line 10291) | void write_bson_boolean(const string_t& name,
method write_bson_double (line 10301) | void write_bson_double(const string_t& name,
method calc_bson_string_size (line 10311) | static std::size_t calc_bson_string_size(const string_t& value)
method write_bson_string (line 10319) | void write_bson_string(const string_t& name,
method write_bson_null (line 10333) | void write_bson_null(const string_t& name)
method calc_bson_integer_size (line 10341) | static std::size_t calc_bson_integer_size(const std::int64_t value)
method write_bson_integer (line 10351) | void write_bson_integer(const string_t& name,
method calc_bson_unsigned_size (line 10369) | static constexpr std::size_t calc_bson_unsigned_size(const std::ui...
method write_bson_unsigned (line 10379) | void write_bson_unsigned(const string_t& name,
method write_bson_object_entry (line 10401) | void write_bson_object_entry(const string_t& name,
method calc_bson_array_size (line 10411) | static std::size_t calc_bson_array_size(const typename BasicJsonTy...
method write_bson_array (line 10427) | void write_bson_array(const string_t& name,
method calc_bson_element_size (line 10447) | static std::size_t calc_bson_element_size(const string_t& name,
method write_bson_element (line 10492) | void write_bson_element(const string_t& name,
method calc_bson_object_size (line 10535) | static std::size_t calc_bson_object_size(const typename BasicJsonT...
method write_bson_object (line 10550) | void write_bson_object(const typename BasicJsonType::object_t& value)
method CharType (line 10566) | static constexpr CharType get_cbor_float_prefix(float /*unused*/)
method CharType (line 10571) | static constexpr CharType get_cbor_float_prefix(double /*unused*/)
method CharType (line 10580) | static constexpr CharType get_msgpack_float_prefix(float /*unused*/)
method CharType (line 10585) | static constexpr CharType get_msgpack_float_prefix(double /*unused*/)
method write_number_with_ubjson_prefix (line 10597) | void write_number_with_ubjson_prefix(const NumberType n,
method write_number_with_ubjson_prefix (line 10610) | void write_number_with_ubjson_prefix(const NumberType n,
method write_number_with_ubjson_prefix (line 10663) | void write_number_with_ubjson_prefix(const NumberType n,
method CharType (line 10723) | CharType ubjson_prefix(const BasicJsonType& j) const noexcept
method CharType (line 10794) | static constexpr CharType get_ubjson_float_prefix(float /*unused*/)
method CharType (line 10799) | static constexpr CharType get_ubjson_float_prefix(double /*unused*/)
method write_number (line 10820) | void write_number(const NumberType n)
method CharType (line 10843) | static constexpr CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10850) | static CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10861) | static constexpr CharType to_char_type(std::uint8_t x) noexcept
method CharType (line 10872) | static constexpr CharType to_char_type(InputCharType x) noexcept
type dtoa_impl (line 10942) | namespace dtoa_impl
function Target (line 10946) | Target reinterpret_bits(const Source source)
type diyfp (line 10955) | struct diyfp // f * 2^e
method diyfp (line 10962) | constexpr diyfp(std::uint64_t f_, int e_) noexcept : f(f_), e(e_...
method diyfp (line 10968) | static diyfp sub(const diyfp& x, const diyfp& y) noexcept
method diyfp (line 10980) | static diyfp mul(const diyfp& x, const diyfp& y) noexcept
method diyfp (line 11045) | static diyfp normalize(diyfp x) noexcept
method diyfp (line 11062) | static diyfp normalize_to(const diyfp& x, const int target_expon...
type boundaries (line 11073) | struct boundaries
function boundaries (line 11087) | boundaries compute_boundaries(FloatType value)
type cached_power (line 11212) | struct cached_power // c = f * 2^e ~= 10^k
function cached_power (line 11226) | inline cached_power get_cached_power_for_binary_exponent(int e)
function find_largest_pow10 (line 11390) | inline int find_largest_pow10(const std::uint32_t n, std::uint32_t...
function grisu2_round (line 11446) | inline void grisu2_round(char* buf, int len, std::uint64_t dist, s...
function grisu2_digit_gen (line 11487) | inline void grisu2_digit_gen(char* buffer, int& length, int& decim...
function grisu2 (line 11727) | inline void grisu2(char* buf, int& len, int& decimal_exponent,
function grisu2 (line 11786) | void grisu2(char* buf, int& len, int& decimal_exponent, FloatType ...
type error_handler_t (line 12027) | enum class error_handler_t
class serializer (line 12035) | class serializer
method serializer (line 12050) | serializer(output_adapter_t<char> s, const char ichar,
method serializer (line 12062) | serializer(const serializer&) = delete;
method serializer (line 12063) | serializer& operator=(const serializer&) = delete;
method serializer (line 12064) | serializer(serializer&&) = delete;
method serializer (line 12065) | serializer& operator=(serializer&&) = delete;
method dump (line 12085) | void dump(const BasicJsonType& val, const bool pretty_print,
method dump_escaped (line 12295) | void dump_escaped(const string_t& s, const bool ensure_ascii)
method count_digits (line 12551) | inline unsigned int count_digits(number_unsigned_t x) noexcept
method dump_integer (line 12590) | void dump_integer(NumberType x)
method dump_float (line 12676) | void dump_float(number_float_t x)
method dump_float (line 12697) | void dump_float(number_float_t x, std::true_type /*is_ieee_single_...
method dump_float (line 12705) | void dump_float(number_float_t x, std::false_type /*is_ieee_single...
method decode (line 12775) | static std::uint8_t decode(std::uint8_t& state, std::uint32_t& cod...
type detail (line 687) | namespace detail
type position_t (line 89) | struct position_t
class exception (line 145) | class exception : public std::exception
method exception (line 158) | exception(int id_, const char* what_arg) : id(id_), m(what_arg) {}
method name (line 160) | static std::string name(const std::string& ename, int id_)
class parse_error (line 214) | class parse_error : public exception
method parse_error (line 226) | static parse_error create(int id_, const position_t& pos, const st...
method parse_error (line 233) | static parse_error create(int id_, std::size_t byte_, const std::s...
method parse_error (line 253) | parse_error(int id_, std::size_t byte_, const char* what_arg)
method position_string (line 256) | static std::string position_string(const position_t& pos)
class invalid_iterator (line 300) | class invalid_iterator : public exception
method invalid_iterator (line 303) | static invalid_iterator create(int id_, const std::string& what_arg)
method invalid_iterator (line 310) | invalid_iterator(int id_, const char* what_arg)
class type_error (line 353) | class type_error : public exception
method type_error (line 356) | static type_error create(int id_, const std::string& what_arg)
method type_error (line 363) | type_error(int id_, const char* what_arg) : exception(id_, what_ar...
class out_of_range (line 399) | class out_of_range : public exception
method out_of_range (line 402) | static out_of_range create(int id_, const std::string& what_arg)
method out_of_range (line 409) | out_of_range(int id_, const char* what_arg) : exception(id_, what_...
class other_error (line 436) | class other_error : public exception
method other_error (line 439) | static other_error create(int id_, const std::string& what_arg)
method other_error (line 446) | other_error(int id_, const char* what_arg) : exception(id_, what_a...
type index_sequence (line 625) | struct index_sequence
method size (line 629) | static constexpr std::size_t size() noexcept
type merge_and_renumber (line 636) | struct merge_and_renumber
type make_index_sequence (line 643) | struct make_index_sequence
type make_index_sequence<0> (line 647) | struct make_index_sequence<0> : index_sequence<> {}
type make_index_sequence<1> (line 648) | struct make_index_sequence<1> : index_sequence<0> {}
type priority_tag (line 654) | struct priority_tag : priority_tag < N - 1 > {}
type priority_tag<0> (line 655) | struct priority_tag<0> {}
type static_const (line 659) | struct static_const
type make_void (line 689) | struct make_void
type iterator_types (line 705) | struct iterator_types {}
type iterator_types <
It,
void_t<typename It::difference_type, typename It::value_type, typename It::pointer,
typename It::reference, typename It::iterator_category >> (line 708) | struct iterator_types <
type iterator_traits (line 723) | struct iterator_traits
type iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >> (line 728) | struct iterator_traits < T, enable_if_t < !std::is_pointer<T>::value >>
type iterator_traits<T*, enable_if_t<std::is_object<T>::value>> (line 734) | struct iterator_traits<T*, enable_if_t<std::is_object<T>::value>>
type nonesuch (line 762) | struct nonesuch
method nonesuch (line 764) | nonesuch() = delete;
method nonesuch (line 766) | nonesuch(nonesuch const&) = delete;
method nonesuch (line 767) | nonesuch(nonesuch const&&) = delete;
type detector (line 776) | struct detector
type is_basic_json (line 902) | struct is_basic_json : std::false_type {}
type has_from_json (line 946) | struct has_from_json : std::false_type {}
type has_from_json<BasicJsonType, T,
enable_if_t<not is_basic_json<T>::value>> (line 949) | struct has_from_json<BasicJsonType, T,
type has_non_default_from_json (line 962) | struct has_non_default_from_json : std::false_type {}
type has_non_default_from_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>> (line 965) | struct has_non_default_from_json<BasicJsonType, T, enable_if_t<not i...
type has_to_json (line 977) | struct has_to_json : std::false_type {}
type has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T>::value>> (line 980) | struct has_to_json<BasicJsonType, T, enable_if_t<not is_basic_json<T...
type is_iterator_traits (line 995) | struct is_iterator_traits : std::false_type {}
type is_iterator_traits<iterator_traits<T>> (line 998) | struct is_iterator_traits<iterator_traits<T>>
type is_complete_type (line 1015) | struct is_complete_type : std::false_type {}
type is_complete_type<T, decltype(void(sizeof(T)))> (line 1018) | struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_ty...
type is_compatible_object_type_impl (line 1022) | struct is_compatible_object_type_impl : std::false_type {}
type is_compatible_object_type_impl <
BasicJsonType, CompatibleObjectType,
enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value and
is_detected<key_type_t, CompatibleObjectType>::value >> (line 1025) | struct is_compatible_object_type_impl <
type is_compatible_object_type (line 1042) | struct is_compatible_object_type
type is_constructible_object_type_impl (line 1047) | struct is_constructible_object_type_impl : std::false_type {}
type is_constructible_object_type_impl <
BasicJsonType, ConstructibleObjectType,
enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value and
is_detected<key_type_t, ConstructibleObjectType>::value >> (line 1050) | struct is_constructible_object_type_impl <
type is_constructible_object_type (line 1065) | struct is_constructible_object_type
type is_compatible_string_type_impl (line 1071) | struct is_compatible_string_type_impl : std::false_type {}
type is_compatible_string_type_impl <
BasicJsonType, CompatibleStringType,
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, CompatibleStringType>::value >> (line 1074) | struct is_compatible_string_type_impl <
type is_compatible_string_type (line 1084) | struct is_compatible_string_type
type is_constructible_string_type_impl (line 1089) | struct is_constructible_string_type_impl : std::false_type {}
type is_constructible_string_type_impl <
BasicJsonType, ConstructibleStringType,
enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
value_type_t, ConstructibleStringType>::value >> (line 1092) | struct is_constructible_string_type_impl <
type is_constructible_string_type (line 1103) | struct is_constructible_string_type
type is_compatible_array_type_impl (line 1107) | struct is_compatible_array_type_impl : std::false_type {}
type is_compatible_array_type (line 1126) | struct is_compatible_array_type
type is_constructible_array_type_impl (line 1130) | struct is_constructible_array_type_impl : std::false_type {}
type is_constructible_array_type_impl <
BasicJsonType, ConstructibleArrayType,
enable_if_t<std::is_same<ConstructibleArrayType,
typename BasicJsonType::value_type>::value >> (line 1133) | struct is_constructible_array_type_impl <
type is_constructible_array_type_impl <
BasicJsonType, ConstructibleArrayType,
enable_if_t<not std::is_same<ConstructibleArrayType,
typename BasicJsonType::value_type>::value and
is_detected<value_type_t, ConstructibleArrayType>::value and
is_detected<iterator_t, ConstructibleArrayType>::value and
is_complete_type<
detected_t<value_type_t, ConstructibleArrayType>>::value >> (line 1140) | struct is_constructible_array_type_impl <
type is_constructible_array_type (line 1165) | struct is_constructible_array_type
type is_compatible_integer_type_impl (line 1170) | struct is_compatible_integer_type_impl : std::false_type {}
type is_compatible_integer_type_impl <
RealIntegerType, CompatibleNumberIntegerType,
enable_if_t<std::is_integral<RealIntegerType>::value and
std::is_integral<CompatibleNumberIntegerType>::value and
not std::is_same<bool, CompatibleNumberIntegerType>::value >> (line 1173) | struct is_compatible_integer_type_impl <
type is_compatible_integer_type (line 1191) | struct is_compatible_integer_type
type is_compatible_type_impl (line 1196) | struct is_compatible_type_impl: std::false_type {}
type is_compatible_type_impl <
BasicJsonType, CompatibleType,
enable_if_t<is_complete_type<CompatibleType>::value >> (line 1199) | struct is_compatible_type_impl <
type is_compatible_type (line 1208) | struct is_compatible_type
type value_t (line 1254) | enum class value_t : std::uint8_t
function from_json (line 1298) | void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
function get_arithmetic_value (line 1312) | void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
function from_json (line 1338) | void from_json(const BasicJsonType& j, typename BasicJsonType::boole...
function from_json (line 1348) | void from_json(const BasicJsonType& j, typename BasicJsonType::strin...
function from_json (line 1364) | void from_json(const BasicJsonType& j, ConstructibleStringType& s)
function from_json (line 1375) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1381) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1387) | void from_json(const BasicJsonType& j, typename BasicJsonType::numbe...
function from_json (line 1394) | void from_json(const BasicJsonType& j, EnumType& e)
function from_json (line 1404) | void from_json(const BasicJsonType& j, std::forward_list<T, Allocato...
function from_json (line 1420) | void from_json(const BasicJsonType& j, std::valarray<T>& l)
function from_json_array_impl (line 1431) | void from_json_array_impl(const BasicJsonType& j, typename BasicJson...
function from_json_array_impl (line 1437) | auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& ...
function from_json_array_impl (line 1448) | auto from_json_array_impl(const BasicJsonType& j, ConstructibleArray...
function from_json_array_impl (line 1467) | void from_json_array_impl(const BasicJsonType& j, ConstructibleArray...
function from_json (line 1490) | auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
function from_json (line 1506) | void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
function from_json (line 1536) | void from_json(const BasicJsonType& j, ArithmeticType& val)
function from_json (line 1567) | void from_json(const BasicJsonType& j, std::pair<A1, A2>& p)
function from_json_tuple_impl (line 1573) | void from_json_tuple_impl(const BasicJsonType& j, Tuple& t, index_se...
function from_json (line 1579) | void from_json(const BasicJsonType& j, std::tuple<Args...>& t)
function from_json (line 1587) | void from_json(const BasicJsonType& j, std::map<Key, Value, Compare,...
function from_json (line 1606) | void from_json(const BasicJsonType& j, std::unordered_map<Key, Value...
type from_json_fn (line 1622) | struct from_json_fn
class iteration_proxy_value (line 1673) | class iteration_proxy_value
method iteration_proxy_value (line 1695) | explicit iteration_proxy_value(IteratorType it) noexcept : anchor(...
method iteration_proxy_value (line 1698) | iteration_proxy_value& operator*()
method iteration_proxy_value (line 1704) | iteration_proxy_value& operator++()
method value (line 1753) | typename IteratorType::reference value() const
class iteration_proxy (line 1760) | class iteration_proxy
method iteration_proxy (line 1768) | explicit iteration_proxy(typename IteratorType::reference cont) no...
method begin (line 1772) | iteration_proxy_value<IteratorType> begin() noexcept
method end (line 1778) | iteration_proxy_value<IteratorType> end() noexcept
function get (line 1787) | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>...
function get (line 1795) | auto get(const nlohmann::detail::iteration_proxy_value<IteratorType>...
type external_constructor (line 1845) | struct external_constructor
type external_constructor<value_t::boolean> (line 1848) | struct external_constructor<value_t::boolean>
method construct (line 1851) | static void construct(BasicJsonType& j, typename BasicJsonType::bo...
type external_constructor<value_t::string> (line 1860) | struct external_constructor<value_t::string>
method construct (line 1863) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1871) | static void construct(BasicJsonType& j, typename BasicJsonType::st...
method construct (line 1881) | static void construct(BasicJsonType& j, const CompatibleStringType...
type external_constructor<value_t::number_float> (line 1890) | struct external_constructor<value_t::number_float>
method construct (line 1893) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::number_unsigned> (line 1902) | struct external_constructor<value_t::number_unsigned>
method construct (line 1905) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::number_integer> (line 1914) | struct external_constructor<value_t::number_integer>
method construct (line 1917) | static void construct(BasicJsonType& j, typename BasicJsonType::nu...
type external_constructor<value_t::array> (line 1926) | struct external_constructor<value_t::array>
method construct (line 1929) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1937) | static void construct(BasicJsonType& j, typename BasicJsonType::ar...
method construct (line 1947) | static void construct(BasicJsonType& j, const CompatibleArrayType&...
method construct (line 1957) | static void construct(BasicJsonType& j, const std::vector<bool>& arr)
method construct (line 1971) | static void construct(BasicJsonType& j, const std::valarray<T>& arr)
type external_constructor<value_t::object> (line 1982) | struct external_constructor<value_t::object>
method construct (line 1985) | static void construct(BasicJsonType& j, const typename BasicJsonTy...
method construct (line 1993) | static void construct(BasicJsonType& j, typename BasicJsonType::ob...
method construct (line 2002) | static void construct(Basi
Condensed preview — 305 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,258K chars).
[
{
"path": ".bazelrc",
"chars": 100,
"preview": "# Clang TSAN\nbuild:clang-tsan --copt -fsanitize=thread\nbuild:clang-tsan --linkopt -fsanitize=thread\n"
},
{
"path": ".clang-format",
"chars": 60,
"preview": "# Use the Google style in this project.\nBasedOnStyle: Google"
},
{
"path": ".github/ISSUE_TEMPLATE.md",
"chars": 554,
"preview": "<!-- Here is for bug reports and feature requests ONLY! \n\nIf you're looking for help, please check our mail list and the"
},
{
"path": ".github/PULL_REQUEST_TEMPLATE.md",
"chars": 564,
"preview": "<!-- Thanks for submitting a pull request! Here are some tips for you:\n1. Please make sure you have read and understood"
},
{
"path": ".github/workflows/main.yml",
"chars": 1606,
"preview": "name: CI\n\non:\n push:\n branches: master\n pull_request:\n branches: \"*\"\n\njobs:\n build:\n\n runs-on: ${{ matrix.os"
},
{
"path": ".gitignore",
"chars": 315,
"preview": "/bazel-*\nBROWSE\n/build\n/build_*\n.cache\n/ci/bazel-*\n/ci/prebuilt/thirdparty\n/ci/prebuilt/thirdparty_build\ncompile_command"
},
{
"path": "BUILD",
"chars": 590,
"preview": "load(\"@rules_foreign_cc//tools/build_defs:configure.bzl\", \"configure_make\")\n# load(\"@rules_foreign_cc//tools/build_defs:"
},
{
"path": "CMakeLists.txt",
"chars": 258,
"preview": "cmake_minimum_required(VERSION 3.14)\n\nproject(sentinel-cpp VERSION 1.0.1 LANGUAGES C CXX)\n\nset(CMAKE_CXX_STANDARD 14)\n\ns"
},
{
"path": "LICENSE",
"chars": 11358,
"preview": "\n Apache License\n Version 2.0, January 2004\n "
},
{
"path": "README.md",
"chars": 948,
"preview": "<img src=\"https://user-images.githubusercontent.com/9434884/43697219-3cb4ef3a-9975-11e8-9a9c-73f4f537442d.png\" alt=\"Sent"
},
{
"path": "WORKSPACE",
"chars": 2124,
"preview": "# Copyright 2019 Alibaba Inc. All rights reserved\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n#"
},
{
"path": "bazel/BUILD",
"chars": 354,
"preview": "licenses([\"notice\"]) # Apache 2.0\n\npackage(default_visibility = [\"//visibility:public\"])\n\nconfig_setting(\n name = \"l"
},
{
"path": "bazel/copts.bzl",
"chars": 1041,
"preview": "\"\"\"\nFlags specified here must not impact ABI. Code compiled with and without these\nopts will be linked together, and in "
},
{
"path": "bazel/fmtlib.BUILD",
"chars": 274,
"preview": "licenses([\"notice\"]) # Apache 2\n\ncc_library(\n name = \"fmtlib\",\n srcs = glob([\n \"fmt/*.cc\",\n ]),\n hdr"
},
{
"path": "bazel/osx.tbb.BUILD",
"chars": 904,
"preview": "licenses([\"notice\"]) # Apache 2\npackage(default_visibility = [\"//visibility:public\"])\n\ngenrule(\n name = \"build_tbb_osx"
},
{
"path": "bazel/spdlog.BUILD",
"chars": 306,
"preview": "licenses([\"notice\"]) # Apache 2\n\ncc_library(\n name = \"spdlog\",\n hdrs = glob([\n \"include/**/*.cc\",\n "
},
{
"path": "bazel/tbb.BUILD",
"chars": 1167,
"preview": "licenses([\"notice\"]) # Apache 2\npackage(default_visibility = [\"//visibility:public\"])\n\ngenrule(\n name = \"build_tbb\",\n "
},
{
"path": "bazel/third_party_repositories.bzl",
"chars": 1759,
"preview": "load(\"@bazel_tools//tools/build_defs/repo:http.bzl\", \"http_archive\", \"http_file\")\n\nall_content = \"\"\"filegroup(name = \"al"
},
{
"path": "cmake/common.cmake",
"chars": 3904,
"preview": "cmake_minimum_required( VERSION 3.14 )\n\nfind_package(Libevent REQUIRED)\ninclude_directories(${LIBEVENT_INCLUDE_DIR})\n\nin"
},
{
"path": "cmake/third_party.cmake",
"chars": 722,
"preview": "cmake_minimum_required( VERSION 3.14 )\ninclude( FetchContent )\n\n########################################################"
},
{
"path": "examples/CMakeLists.txt",
"chars": 992,
"preview": "cmake_minimum_required(VERSION 3.14)\n\nproject(sentinel-cpp VERSION 1.0.1 LANGUAGES C CXX)\n\nset(CMAKE_CXX_STANDARD 14)\n\ns"
},
{
"path": "examples/abseil/BUILD",
"chars": 136,
"preview": "cc_binary(\n name = \"asbeil_string\",\n srcs = [\"abseil_string.cc\"],\n deps = [\n \"@com_google_absl//absl/str"
},
{
"path": "examples/abseil/abseil_string.cc",
"chars": 304,
"preview": "#include <iostream>\n#include <string>\n\n#include \"absl/strings/str_cat.h\"\n#include \"absl/strings/string_view.h\"\n\nstd::str"
},
{
"path": "examples/benchmark/BUILD",
"chars": 328,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\ncc_binary(\n name = \"benchmark_test\",\n srcs = [\"benchamrk"
},
{
"path": "examples/benchmark/benchamrk_test.cc",
"chars": 5243,
"preview": "\n#include <benchmark/benchmark.h>\n#include <atomic>\n#include <iostream>\n#include <thread>\n#include <unordered_map>\n#incl"
},
{
"path": "examples/cache/BUILD",
"chars": 364,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_binar"
},
{
"path": "examples/cache/cache_test.cc",
"chars": 1896,
"preview": "\n#include <atomic>\n#include <chrono>\n#include <iostream>\n#include <thread>\n#include <vector>\n#include \"sentinel-core/log"
},
{
"path": "examples/fmt/BUILD",
"chars": 127,
"preview": "cc_binary(\n name = \"fmt_test\",\n srcs = [\"fmt_test.cc\"],\n deps = [\n \"@com_github_fmtlib_fmt//:fmtlib\",\n "
},
{
"path": "examples/fmt/fmt_test.cc",
"chars": 202,
"preview": "#include <iostream>\n#include <string>\n\n#include \"fmt/format.h\"\n\nint main() {\n std::string s = fmt::format(\"I'd rather b"
},
{
"path": "examples/gtest/BUILD",
"chars": 133,
"preview": "cc_test(\n name = \"hello_test\",\n srcs = [\"hello_test.cc\"],\n deps = [\n \"@com_google_googletest//:gtest_mai"
},
{
"path": "examples/gtest/hello_test.cc",
"chars": 115,
"preview": "#include <string>\n\n#include \"gtest/gtest.h\"\n\nTEST(HelloTest, Basic) { EXPECT_EQ(\"Hello tester\", \"Hello tester\"); }\n"
},
{
"path": "examples/json/BUILD",
"chars": 161,
"preview": "cc_binary(\n name = \"nlohmann_json_example\",\n srcs = [\"nlohmann_json_example.cc\"],\n deps = [\n \"//third_par"
},
{
"path": "examples/json/nlohmann_json_example.cc",
"chars": 515,
"preview": "#include <iostream>\n#include <typeinfo>\n\n#include \"third_party/nlohmann/json.hpp\"\n\nint main() {\n try {\n auto j2 = nl"
},
{
"path": "examples/libevent/BUILD",
"chars": 124,
"preview": "cc_binary(\n name = \"libevent_echosrv1\",\n srcs = [\"libevent_echosrv1.c\"],\n deps = [\n \"//:libevent\",\n ]"
},
{
"path": "examples/libevent/libevent_echosrv1.c",
"chars": 6614,
"preview": "// Copied from\n// https://github.com/jasonish/libevent-examples/blob/6d20f0d86c2cd263f5edff28862bc09ce4a3220f/echo-serve"
},
{
"path": "examples/log/BUILD",
"chars": 130,
"preview": "cc_binary(\n name = \"log_test\",\n srcs = [\"log_test.cc\"],\n deps = [\n \"@com_github_gabime_spdlog//:spdlog\","
},
{
"path": "examples/log/log_test.cc",
"chars": 1036,
"preview": "#include \"spdlog/spdlog.h\"\nint main() {\n spdlog::info(\"Welcome to spdlog!\");\n spdlog::error(\"Some error message with a"
},
{
"path": "examples/sentinel-cpp/BUILD",
"chars": 1439,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\n# https"
},
{
"path": "examples/sentinel-cpp/basic_concurrency_limit.cc",
"chars": 1911,
"preview": "#include <chrono>\n#include <cstdlib>\n#include <iostream>\n#include <string>\n#include <thread>\n\n#include \"sentinel-core/fl"
},
{
"path": "examples/sentinel-cpp/basic_param_limit.cc",
"chars": 4575,
"preview": "#include <math.h>\n#include <atomic>\n#include <chrono>\n#include <cstdlib>\n#include <iostream>\n#include <mutex>\n#include <"
},
{
"path": "examples/sentinel-cpp/basic_qps_limit.cc",
"chars": 2132,
"preview": "#include <chrono>\n#include <cstdlib>\n#include <iostream>\n#include <string>\n#include <thread>\n\n#include \"sentinel-core/fl"
},
{
"path": "examples/sentinel-cpp/basic_system_limit.cc",
"chars": 3976,
"preview": "#include <math.h>\n#include <atomic>\n#include <chrono>\n#include <cstdlib>\n#include <iostream>\n#include <string>\n#include "
},
{
"path": "examples/tbb/BUILD",
"chars": 597,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_binar"
},
{
"path": "examples/tbb/tbb_test.cc",
"chars": 807,
"preview": "\n#include <chrono>\n#include <iostream>\n#include <thread>\n\n#include \"sentinel-core/log/logger.h\"\n#include \"tbb/concurrent"
},
{
"path": "format.sh",
"chars": 348,
"preview": "#!/usr/bin/env bash\n\nCMD=clang-format-8\n$CMD -version\n$CMD -i -style=Google $(git ls-files|grep -E \".*\\.(cc|h)$\")\nCHANGE"
},
{
"path": "sentinel-core/BUILD",
"chars": 0,
"preview": ""
},
{
"path": "sentinel-core/circuitbreaker/BUILD",
"chars": 3162,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/circuitbreaker/circuit_breaker.cc",
"chars": 1566,
"preview": "#include <atomic>\n#include <memory>\n\n#include \"sentinel-core/circuitbreaker/circuit_breaker.h\"\n#include \"sentinel-core/u"
},
{
"path": "sentinel-core/circuitbreaker/circuit_breaker.h",
"chars": 1404,
"preview": "#pragma once\n\n#include <atomic>\n#include <memory>\n\n#include \"sentinel-core/circuitbreaker/rule.h\"\n#include \"sentinel-cor"
},
{
"path": "sentinel-core/circuitbreaker/error_circuit_breaker.cc",
"chars": 2259,
"preview": "#include <memory>\n\n#include \"sentinel-core/circuitbreaker/error_circuit_breaker.h\"\n\nnamespace Sentinel {\nnamespace Circu"
},
{
"path": "sentinel-core/circuitbreaker/error_circuit_breaker.h",
"chars": 2171,
"preview": "#pragma once\n\n#include <atomic>\n#include <memory>\n\n#include \"sentinel-core/circuitbreaker/circuit_breaker.h\"\n#include \"s"
},
{
"path": "sentinel-core/circuitbreaker/rt_circuit_breaker.cc",
"chars": 2191,
"preview": "#include <memory>\n\n#include \"sentinel-core/circuitbreaker/rt_circuit_breaker.h\"\n\nnamespace Sentinel {\nnamespace CircuitB"
},
{
"path": "sentinel-core/circuitbreaker/rt_circuit_breaker.h",
"chars": 2143,
"preview": "#pragma once\n\n#include <atomic>\n#include <memory>\n\n#include \"sentinel-core/circuitbreaker/circuit_breaker.h\"\n#include \"s"
},
{
"path": "sentinel-core/circuitbreaker/rule.cc",
"chars": 1033,
"preview": "#include <string>\n\n#include \"sentinel-core/circuitbreaker/rule.h\"\n\n#include \"absl/strings/str_format.h\"\n\nnamespace Senti"
},
{
"path": "sentinel-core/circuitbreaker/rule.h",
"chars": 2578,
"preview": "#pragma once\n\n#include <functional>\n#include <memory>\n#include <string>\n#include <unordered_set>\n#include <vector>\n\n#inc"
},
{
"path": "sentinel-core/circuitbreaker/rule_manager.cc",
"chars": 5871,
"preview": "#include <memory>\n#include <mutex>\n#include <unordered_map>\n#include <unordered_set>\n\n#include \"sentinel-core/circuitbre"
},
{
"path": "sentinel-core/circuitbreaker/rule_manager.h",
"chars": 1955,
"preview": "#pragma once\n\n#include <mutex>\n#include <string>\n#include <unordered_map>\n#include <vector>\n\n#include \"absl/synchronizat"
},
{
"path": "sentinel-core/circuitbreaker/slot.cc",
"chars": 2019,
"preview": "#include \"sentinel-core/circuitbreaker/slot.h\"\n\n#include \"sentinel-core/circuitbreaker/rule_manager.h\"\n#include \"sentine"
},
{
"path": "sentinel-core/circuitbreaker/slot.h",
"chars": 1471,
"preview": "#pragma once\n\n#include \"sentinel-core/slot/base/rule_checker_slot.h\"\n#include \"sentinel-core/slot/base/stats_slot.h\"\n\nna"
},
{
"path": "sentinel-core/circuitbreaker/slot_test.cc",
"chars": 5126,
"preview": "#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/test/mock/statistic/node/mock.h\"\n\n#include \"s"
},
{
"path": "sentinel-core/common/BUILD",
"chars": 2124,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/common/constants.h",
"chars": 537,
"preview": "#pragma once\n\nnamespace Sentinel {\nnamespace Constants {\n\nstatic constexpr int kDefaultSampleCount = 2;\nstatic constexpr"
},
{
"path": "sentinel-core/common/entry.h",
"chars": 1856,
"preview": "#pragma once\n\n#include <chrono>\n#include <memory>\n#include <vector>\n\n#include \"sentinel-core/common/entry_context.h\"\n#in"
},
{
"path": "sentinel-core/common/entry_context.cc",
"chars": 113,
"preview": "#include <string>\n\n#include \"sentinel-core/common/entry_context.h\"\n\nnamespace Sentinel {} // namespace Sentinel\n"
},
{
"path": "sentinel-core/common/entry_context.h",
"chars": 1162,
"preview": "#pragma once\n\n#include <memory>\n#include <string>\n\n#include \"sentinel-core/slot/base/token_result.h\"\n#include \"sentinel-"
},
{
"path": "sentinel-core/common/entry_node.h",
"chars": 0,
"preview": ""
},
{
"path": "sentinel-core/common/entry_result.cc",
"chars": 842,
"preview": "#include \"sentinel-core/common/entry_result.h\"\n#include \"sentinel-core/slot/global_slot_chain.h\"\n\nnamespace Sentinel {\n\n"
},
{
"path": "sentinel-core/common/entry_result.h",
"chars": 939,
"preview": "#pragma once\n\n#include <memory>\n#include <string>\n#include <vector>\n#include \"absl/types/optional.h\"\n#include \"sentinel-"
},
{
"path": "sentinel-core/common/entry_type.h",
"chars": 95,
"preview": "#pragma once\n\nnamespace Sentinel {\nenum class EntryType { IN, OUT };\n\n} // namespace Sentinel\n"
},
{
"path": "sentinel-core/common/global_status.cc",
"chars": 125,
"preview": "namespace Sentinel {\nnamespace GlobalStatus {\n\nbool activated = true;\n\n}; // namespace GlobalStatus\n} // namespace Sen"
},
{
"path": "sentinel-core/common/global_status.h",
"chars": 139,
"preview": "#pragma once\n\nnamespace Sentinel {\nnamespace GlobalStatus {\n\nextern bool activated;\n\n}; // namespace GlobalStatus\n} //"
},
{
"path": "sentinel-core/common/resource_wrapper.h",
"chars": 431,
"preview": "#pragma once\n\n#include <memory>\n#include <string>\n\n#include \"absl/types/any.h\"\n#include \"sentinel-core/common/entry_type"
},
{
"path": "sentinel-core/common/rule.h",
"chars": 561,
"preview": "#pragma once\n\n#include <string>\n\n#include \"sentinel-core/common/constants.h\"\n\nnamespace Sentinel {\n\nclass Rule {\n public"
},
{
"path": "sentinel-core/common/string_resource_wrapper.h",
"chars": 535,
"preview": "#pragma once\n\n#include <string>\n\n#include \"sentinel-core/common/resource_wrapper.h\"\n\nnamespace Sentinel {\nclass StringRe"
},
{
"path": "sentinel-core/common/tracer.cc",
"chars": 558,
"preview": "#include <string>\n\n#include \"sentinel-core/common/tracer.h\"\n#include \"sentinel-core/statistic/node/node.h\"\n\nnamespace Se"
},
{
"path": "sentinel-core/common/tracer.h",
"chars": 355,
"preview": "#pragma once\n\n#include <string>\n\n#include \"sentinel-core/common/entry.h\"\n\nnamespace Sentinel {\n\nclass Tracer {\n public:\n"
},
{
"path": "sentinel-core/common/tracer_test.cc",
"chars": 777,
"preview": "#include <memory>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/common/entry.h\"\n#include \""
},
{
"path": "sentinel-core/config/BUILD",
"chars": 715,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/config/config_constants.h",
"chars": 1490,
"preview": "#pragma once\n\n#include <cstdint>\n\nnamespace Sentinel {\nnamespace Config {\n\nconst auto kUnknownAppName = \"unknown_cpp_ser"
},
{
"path": "sentinel-core/config/local_config.cc",
"chars": 3640,
"preview": "#include <cstdint>\n\n#include \"absl/strings/numbers.h\"\n\n#include \"sentinel-core/config/config_constants.h\"\n#include \"sent"
},
{
"path": "sentinel-core/config/local_config.h",
"chars": 1258,
"preview": "#pragma once\n\n#include <string>\n#include <unordered_map>\n\n#include \"sentinel-core/init/init_target.h\"\n\nnamespace Sentine"
},
{
"path": "sentinel-core/config/local_config_test.cc",
"chars": 1011,
"preview": "#include <cstdint>\n#include <string>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/config/"
},
{
"path": "sentinel-core/flow/BUILD",
"chars": 3884,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/flow/default_traffic_shaping_calculator.cc",
"chars": 285,
"preview": "#include \"sentinel-core/flow/default_traffic_shaping_calculator.h\"\n\nnamespace Sentinel {\nnamespace Flow {\n\ndouble Defaul"
},
{
"path": "sentinel-core/flow/default_traffic_shaping_calculator.h",
"chars": 539,
"preview": "#pragma once\n\n#include \"sentinel-core/flow/traffic_shaping_calculator.h\"\n\nnamespace Sentinel {\nnamespace Flow {\n\nclass D"
},
{
"path": "sentinel-core/flow/default_traffic_shaping_checker.cc",
"chars": 696,
"preview": "#include \"sentinel-core/flow/default_traffic_shaping_checker.h\"\n#include \"sentinel-core/flow/flow_rule_constants.h\"\n\nnam"
},
{
"path": "sentinel-core/flow/default_traffic_shaping_checker.h",
"chars": 719,
"preview": "#pragma once\n\n#include \"sentinel-core/flow/flow_rule_constants.h\"\n#include \"sentinel-core/flow/traffic_shaping_checker.h"
},
{
"path": "sentinel-core/flow/flow_rule.cc",
"chars": 1251,
"preview": "#include <string>\n\n#include \"sentinel-core/flow/flow_rule.h\"\n\n#include \"absl/strings/str_format.h\"\n\nnamespace Sentinel {"
},
{
"path": "sentinel-core/flow/flow_rule.h",
"chars": 4015,
"preview": "#pragma once\n\n#include <functional>\n#include <memory>\n#include <string>\n#include <vector>\n\n#include \"sentinel-core/commo"
},
{
"path": "sentinel-core/flow/flow_rule_checker.cc",
"chars": 3478,
"preview": "#include \"sentinel-core/flow/flow_rule_checker.h\"\n#include \"sentinel-core/flow/flow_rule_constants.h\"\n#include \"sentinel"
},
{
"path": "sentinel-core/flow/flow_rule_checker.h",
"chars": 1584,
"preview": "#pragma once\n\n#include \"sentinel-core/common/entry.h\"\n#include \"sentinel-core/flow/flow_rule.h\"\n#include \"sentinel-core/"
},
{
"path": "sentinel-core/flow/flow_rule_constants.h",
"chars": 449,
"preview": "#pragma once\n\nnamespace Sentinel {\nnamespace Flow {\n\nenum class FlowMetricType {\n kThreadCount = 0,\n kQps = 1 // defa"
},
{
"path": "sentinel-core/flow/flow_rule_manager.cc",
"chars": 6235,
"preview": "#include <memory>\n#include <mutex>\n#include <unordered_map>\n#include <unordered_set>\n\n#include \"sentinel-core/flow/defau"
},
{
"path": "sentinel-core/flow/flow_rule_manager.h",
"chars": 2128,
"preview": "#pragma once\n\n#include <mutex>\n#include <string>\n#include <unordered_map>\n#include <vector>\n\n#include \"absl/synchronizat"
},
{
"path": "sentinel-core/flow/flow_slot.cc",
"chars": 1363,
"preview": "#include <thread>\n\n#include \"sentinel-core/flow/flow_rule_manager.h\"\n#include \"sentinel-core/flow/flow_slot.h\"\n\nnamespac"
},
{
"path": "sentinel-core/flow/flow_slot.h",
"chars": 836,
"preview": "#pragma once\n#include <thread>\n\n#include \"sentinel-core/flow/flow_rule_checker.h\"\n#include \"sentinel-core/slot/base/rule"
},
{
"path": "sentinel-core/flow/flow_slot_test.cc",
"chars": 2228,
"preview": "#include <memory>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/test/mock/statistic/node/m"
},
{
"path": "sentinel-core/flow/throttling_traffic_shaping_checker.cc",
"chars": 1550,
"preview": "#include <cmath>\n\n#include \"sentinel-core/flow/throttling_traffic_shaping_checker.h\"\n#include \"sentinel-core/utils/time_"
},
{
"path": "sentinel-core/flow/throttling_traffic_shaping_checker.h",
"chars": 734,
"preview": "#pragma once\n\n#include <atomic>\n\n#include \"sentinel-core/flow/flow_rule_constants.h\"\n#include \"sentinel-core/flow/traffi"
},
{
"path": "sentinel-core/flow/traffic_shaping_calculator.h",
"chars": 429,
"preview": "#pragma once\n\n#include \"sentinel-core/statistic/node/node.h\"\n\nnamespace Sentinel {\nnamespace Flow {\n\nclass TrafficShapin"
},
{
"path": "sentinel-core/flow/traffic_shaping_checker.h",
"chars": 533,
"preview": "#pragma once\n\n#include \"sentinel-core/slot/base/token_result.h\"\n#include \"sentinel-core/statistic/node/node.h\"\n\nnamespac"
},
{
"path": "sentinel-core/flow/traffic_shaping_controller.cc",
"chars": 464,
"preview": "#include <memory>\n\n#include \"sentinel-core/flow/traffic_shaping_controller.h\"\n\nnamespace Sentinel {\nnamespace Flow {\n\nSl"
},
{
"path": "sentinel-core/flow/traffic_shaping_controller.h",
"chars": 880,
"preview": "#pragma once\n\n#include <memory>\n\n#include \"sentinel-core/flow/traffic_shaping_calculator.h\"\n#include \"sentinel-core/flow"
},
{
"path": "sentinel-core/flow/traffic_shaping_controller_test.cc",
"chars": 2080,
"preview": "#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/test/mock/flow/mock.h\"\n#include \"sentinel-cor"
},
{
"path": "sentinel-core/init/BUILD",
"chars": 697,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/init/init_target.h",
"chars": 190,
"preview": "#pragma once\n\nnamespace Sentinel {\nnamespace Init {\nclass Target {\n public:\n virtual ~Target() = default;\n virtual voi"
},
{
"path": "sentinel-core/init/init_target_registry.h",
"chars": 1093,
"preview": "#pragma once\n\n#include \"sentinel-core/utils/utils.h\"\n\nnamespace Sentinel {\nnamespace Init {\n\ntemplate <typename T>\nclass"
},
{
"path": "sentinel-core/init/init_target_registry_test.cc",
"chars": 471,
"preview": "#include <iostream>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/test/mock/init/mock.h\"\n\n"
},
{
"path": "sentinel-core/log/BUILD",
"chars": 1202,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/log/block/BUILD",
"chars": 729,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/log/block/block_log_task.cc",
"chars": 2628,
"preview": "#include \"sentinel-core/log/block/block_log_task.h\"\n\n#include <iostream>\n#include <memory>\n#include <thread>\n\n#include \""
},
{
"path": "sentinel-core/log/block/block_log_task.h",
"chars": 1249,
"preview": "#pragma once\n\n#include <atomic>\n#include <memory>\n#include <string>\n\n#include \"absl/container/flat_hash_map.h\"\n#include "
},
{
"path": "sentinel-core/log/block/block_log_task_test.cc",
"chars": 1205,
"preview": "#include <cstdio>\n#include <fstream>\n#include <iostream>\n#include <string>\n#include <thread>\n\n#include \"gmock/gmock.h\"\n#"
},
{
"path": "sentinel-core/log/log_base.cc",
"chars": 1589,
"preview": "#include \"sentinel-core/log/log_base.h\"\n\n#include <cstdlib>\n#include <iostream>\n\n#include \"absl/strings/match.h\"\n#includ"
},
{
"path": "sentinel-core/log/log_base.h",
"chars": 782,
"preview": "#pragma once\n\n#include <string>\n\nnamespace Sentinel {\nnamespace Log {\n\nstatic constexpr auto kEnvLogDir = \"CSP_SENTINEL_"
},
{
"path": "sentinel-core/log/log_base_test.cc",
"chars": 373,
"preview": "#include \"gtest/gtest.h\"\n\n#define private public\n\n#include \"sentinel-core/log/log_base.h\"\n\nnamespace Sentinel {\nnamespac"
},
{
"path": "sentinel-core/log/logger.cc",
"chars": 1718,
"preview": "#include \"logger.h\"\n\n#include <iostream>\n\n#include <spdlog/async.h>\n#include <spdlog/sinks/daily_file_sink.h>\n\nnamespace"
},
{
"path": "sentinel-core/log/logger.h",
"chars": 1938,
"preview": "#pragma once\n\n#include <string>\n\n#include \"sentinel-core/log/log_base.h\"\n#include \"sentinel-core/utils/macros.h\"\n\n#inclu"
},
{
"path": "sentinel-core/log/logger_test.cc",
"chars": 2119,
"preview": "#include <stdio.h>\n\n#include <memory>\n#include <string>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include <al"
},
{
"path": "sentinel-core/log/metric/BUILD",
"chars": 1598,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/log/metric/metric_log_task.cc",
"chars": 2099,
"preview": "#include <assert.h>\n#include <map>\n#include <string>\n#include <thread>\n#include <vector>\n\n#include \"sentinel-core/config"
},
{
"path": "sentinel-core/log/metric/metric_log_task.h",
"chars": 890,
"preview": "#pragma once\n\n#include <atomic>\n#include <map>\n#include <memory>\n#include <unordered_map>\n#include <vector>\n\n#include \"s"
},
{
"path": "sentinel-core/log/metric/metric_reader.cc",
"chars": 3525,
"preview": "#include \"sentinel-core/log/metric/metric_reader.h\"\n\n#include <fstream>\n#include <iostream>\n#include <istream>\n\nnamespac"
},
{
"path": "sentinel-core/log/metric/metric_reader.h",
"chars": 1087,
"preview": "#pragma once\n\n#include <string>\n#include <vector>\n\n#include \"sentinel-core/statistic/base/metric_item.h\"\n\nnamespace Sent"
},
{
"path": "sentinel-core/log/metric/metric_reader_test.cc",
"chars": 2300,
"preview": "#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include <cstdio>\n#include <fstream>\n#include <sstream>\n\n#define priv"
},
{
"path": "sentinel-core/log/metric/metric_searcher.cc",
"chars": 4161,
"preview": "#include \"sentinel-core/log/metric/metric_searcher.h\"\n\n#include <algorithm>\n#include <iostream>\n\n#include \"sentinel-core"
},
{
"path": "sentinel-core/log/metric/metric_searcher.h",
"chars": 1180,
"preview": "#pragma once\n\n#include <mutex>\n#include <string>\n#include <vector>\n\n#include \"sentinel-core/log/metric/metric_reader.h\"\n"
},
{
"path": "sentinel-core/log/metric/metric_searcher_test.cc",
"chars": 3163,
"preview": "#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include <cstdio>\n#include <fstream>\n#include <iomanip>\n#include <sst"
},
{
"path": "sentinel-core/log/metric/metric_test_utils.h",
"chars": 1397,
"preview": "#pragma once\n\n#include <cstdio>\n#include <fstream>\n#include <iomanip>\n#include <memory>\n#include <sstream>\n\n#include \"se"
},
{
"path": "sentinel-core/log/metric/metric_writer.cc",
"chars": 8696,
"preview": "#include \"sentinel-core/log/metric/metric_writer.h\"\n\n#include <dirent.h>\n#include <unistd.h>\n\n#include <ctime>\n#include "
},
{
"path": "sentinel-core/log/metric/metric_writer.h",
"chars": 1893,
"preview": "#pragma once\n\n#include <cstdint>\n#include <fstream>\n#include <mutex>\n#include <string>\n#include <vector>\n\n#include \"sent"
},
{
"path": "sentinel-core/log/metric/metric_writer_test.cc",
"chars": 6344,
"preview": "#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include <cstdio>\n#include <fstream>\n\n#define private public\n\n#includ"
},
{
"path": "sentinel-core/param/BUILD",
"chars": 2699,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/param/param_flow_item.cc",
"chars": 1402,
"preview": "#include \"sentinel-core/param/param_flow_item.h\"\n#include \"absl/strings/str_format.h\"\n\nnamespace Sentinel {\nnamespace Pa"
},
{
"path": "sentinel-core/param/param_flow_item.h",
"chars": 1426,
"preview": "#pragma once\n\n#include <initializer_list>\n#include <string>\n#include <vector>\n#include \"absl/types/any.h\"\n#include \"sent"
},
{
"path": "sentinel-core/param/param_flow_rule.cc",
"chars": 1559,
"preview": "#include \"sentinel-core/param/param_flow_rule.h\"\n#include \"absl/strings/str_format.h\"\n\nnamespace Sentinel {\nnamespace Pa"
},
{
"path": "sentinel-core/param/param_flow_rule.h",
"chars": 3843,
"preview": "#pragma once\n\n#include <functional>\n#include <memory>\n#include <string>\n#include <vector>\n\n#include \"absl/types/any.h\"\n#"
},
{
"path": "sentinel-core/param/param_flow_rule_checker.cc",
"chars": 1980,
"preview": "#include \"sentinel-core/param/param_flow_rule_checker.h\"\n\nnamespace Sentinel {\nnamespace Param {\n\nbool ParamFlowChecker:"
},
{
"path": "sentinel-core/param/param_flow_rule_checker.h",
"chars": 1009,
"preview": "#pragma once\n#include \"sentinel-core/common/entry.h\"\n#include \"sentinel-core/param/param_flow_rule.h\"\n#include \"sentinel"
},
{
"path": "sentinel-core/param/param_flow_rule_constants.h",
"chars": 714,
"preview": "#pragma once\n\nnamespace Sentinel {\nnamespace Param {\n\nenum class ParamFlowMetricType {\n kThreadCount = 0,\n kQps = 1, "
},
{
"path": "sentinel-core/param/param_flow_rule_manager.cc",
"chars": 3620,
"preview": "#include \"sentinel-core/param/param_flow_rule_manager.h\"\n\nnamespace Sentinel {\nnamespace Param {\n\nconstexpr auto kParamP"
},
{
"path": "sentinel-core/param/param_flow_rule_manager.h",
"chars": 1990,
"preview": "#pragma once\n\n#include <mutex>\n#include <string>\n#include <unordered_map>\n#include <vector>\n\n#include \"absl/synchronizat"
},
{
"path": "sentinel-core/param/param_flow_slot.cc",
"chars": 2659,
"preview": "#include \"sentinel-core/param/param_flow_slot.h\"\n#include <iostream>\n\nnamespace Sentinel {\nnamespace Slot {\n\nMetricMapSh"
},
{
"path": "sentinel-core/param/param_flow_slot.h",
"chars": 1508,
"preview": "#pragma once\n\n#include \"sentinel-core/param/param_flow_rule_checker.h\"\n#include \"sentinel-core/param/param_flow_rule_man"
},
{
"path": "sentinel-core/param/param_flow_slot_test.cc",
"chars": 5430,
"preview": "#include <iostream>\n#include <memory>\n#include <string>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"se"
},
{
"path": "sentinel-core/param/statistic/BUILD",
"chars": 2058,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/param/statistic/any_cmp.cc",
"chars": 1394,
"preview": "#include \"sentinel-core/param/statistic/any_cmp.h\"\n#include \"sentinel-core/log/logger.h\"\n\nnamespace Sentinel {\nnamespace"
},
{
"path": "sentinel-core/param/statistic/any_cmp.h",
"chars": 1358,
"preview": "#pragma once\n\n#include <string>\n#include \"absl/types/any.h\"\n\nnamespace Sentinel {\nnamespace Param {\n\nextern const std::s"
},
{
"path": "sentinel-core/param/statistic/any_cmp_test.cc",
"chars": 242,
"preview": "#include \"sentinel-core/param/statistic/any_cmp.h\"\n#include <iostream>\n\nint main() {\n absl::any a;\n std::cout << a.has"
},
{
"path": "sentinel-core/param/statistic/lru_cache.h",
"chars": 16522,
"preview": "/*\n * Copyright (c) 2014 Tim Starling\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
},
{
"path": "sentinel-core/param/statistic/param_bucket.cc",
"chars": 1135,
"preview": "#include \"sentinel-core/param/statistic/param_bucket.h\"\n\nnamespace Sentinel {\nnamespace Param {\n\nParamBucket::ParamBucke"
},
{
"path": "sentinel-core/param/statistic/param_bucket.h",
"chars": 911,
"preview": "#pragma once\n\n#include <atomic>\n#include <memory>\n#include <unordered_map>\n#include <vector>\n\n#include \"absl/types/any.h"
},
{
"path": "sentinel-core/param/statistic/param_event.h",
"chars": 202,
"preview": "#pragma once\n\nnamespace Sentinel {\nnamespace Param {\n\nenum class ParamMetricEvent {\n PASS = 0,\n BLOCK,\n\n Count, // h"
},
{
"path": "sentinel-core/param/statistic/param_leap_array.cc",
"chars": 1528,
"preview": "#include \"sentinel-core/param/statistic/param_leap_array.h\"\n\nnamespace Sentinel {\nnamespace Param {\n\nint ParamLeapArray:"
},
{
"path": "sentinel-core/param/statistic/param_leap_array.h",
"chars": 948,
"preview": "#pragma once\n#include <algorithm>\n#include \"sentinel-core/param/statistic/param_bucket.h\"\n#include \"sentinel-core/statis"
},
{
"path": "sentinel-core/param/statistic/param_leap_array_key.h",
"chars": 1371,
"preview": "#pragma once\n#include <memory>\n\nnamespace Sentinel {\nnamespace Param {\n\nclass ParamLeapArrayKey {\n public:\n int32_t par"
},
{
"path": "sentinel-core/param/statistic/param_metric.cc",
"chars": 5942,
"preview": "#include \"sentinel-core/param/statistic/param_metric.h\"\nnamespace Sentinel {\nnamespace Param {\n\nvoid ParamMetric::AddThr"
},
{
"path": "sentinel-core/param/statistic/param_metric.h",
"chars": 2331,
"preview": "#pragma once\n\n#include <memory.h>\n#include <algorithm>\n#include <vector>\n#include \"sentinel-core/param/statistic/param_l"
},
{
"path": "sentinel-core/param/statistic/param_metric_test.cc",
"chars": 2318,
"preview": "#include <iostream>\n#include <memory>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/param/"
},
{
"path": "sentinel-core/param/statistic/scalable_cache.h",
"chars": 7814,
"preview": "/*\n * Copyright (c) 2014 Tim Starling\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may n"
},
{
"path": "sentinel-core/property/BUILD",
"chars": 1037,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/property/dynamic_sentinel_property.h",
"chars": 1204,
"preview": "#pragma once\n\n#include <string>\n#include <unordered_map>\n#include <utility>\n\n#include \"sentinel-core/log/logger.h\"\n#incl"
},
{
"path": "sentinel-core/property/dynamic_sentinel_property_test.cc",
"chars": 829,
"preview": "#include <string>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/property/dynamic_sentinel_"
},
{
"path": "sentinel-core/property/property_listener.h",
"chars": 447,
"preview": "#pragma once\n\n#include <memory>\n#include <string>\n\nnamespace Sentinel {\nnamespace Property {\n\ntemplate <typename T>\nclas"
},
{
"path": "sentinel-core/property/sentinel_property.h",
"chars": 579,
"preview": "#pragma once\n\n#include <memory>\n#include <string>\n\n#include \"sentinel-core/property/property_listener.h\"\n\nnamespace Sent"
},
{
"path": "sentinel-core/public/BUILD",
"chars": 713,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/public/sph_u.h",
"chars": 3509,
"preview": "#pragma once\n\n#include <string>\n#include \"sentinel-core/common/constants.h\"\n#include \"sentinel-core/common/entry.h\"\n#inc"
},
{
"path": "sentinel-core/public/sph_u_test.cc",
"chars": 1837,
"preview": "#include <memory>\n#include <string>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/flow/flo"
},
{
"path": "sentinel-core/slot/BUILD",
"chars": 2152,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/slot/base/BUILD",
"chars": 1729,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/slot/base/default_slot_chain_impl.cc",
"chars": 1281,
"preview": "#include \"sentinel-core/slot/base/default_slot_chain_impl.h\"\n\n#include <assert.h>\n\nnamespace Sentinel {\nnamespace Slot {"
},
{
"path": "sentinel-core/slot/base/default_slot_chain_impl.h",
"chars": 919,
"preview": "#pragma once\n\n#include <assert.h>\n#include <deque>\n#include <memory>\n\n#include \"sentinel-core/slot/base/slot_chain.h\"\n#i"
},
{
"path": "sentinel-core/slot/base/default_slot_chain_impl_test.cc",
"chars": 2768,
"preview": "#include <memory>\n#include <string>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/common/s"
},
{
"path": "sentinel-core/slot/base/rule_checker_slot.h",
"chars": 594,
"preview": "#pragma once\n\n#include <string>\n\n#include \"sentinel-core/slot/base/slot.h\"\n\nnamespace Sentinel {\nnamespace Slot {\n\nclass"
},
{
"path": "sentinel-core/slot/base/slot.h",
"chars": 516,
"preview": "#pragma once\n\n#include \"sentinel-core/slot/base/slot_base.h\"\n\nnamespace Sentinel {\nnamespace Slot {\n\nenum class SlotType"
},
{
"path": "sentinel-core/slot/base/slot_base.h",
"chars": 779,
"preview": "#pragma once\n\n#include <memory>\n#include <vector>\n\n#include \"sentinel-core/common/entry.h\"\n#include \"sentinel-core/commo"
},
{
"path": "sentinel-core/slot/base/slot_chain.h",
"chars": 417,
"preview": "#pragma once\n\n#include <memory>\n\n#include \"sentinel-core/slot/base/slot.h\"\n\nnamespace Sentinel {\nnamespace Slot {\n\nclass"
},
{
"path": "sentinel-core/slot/base/stats_slot.h",
"chars": 913,
"preview": "#pragma once\n\n#include <assert.h>\n#include <string>\n\n#include \"sentinel-core/slot/base/slot.h\"\n\nnamespace Sentinel {\nnam"
},
{
"path": "sentinel-core/slot/base/token_result.cc",
"chars": 747,
"preview": "\n#include \"sentinel-core/slot/base/token_result.h\"\n\nnamespace Sentinel {\nnamespace Slot {\n\nTokenResultSharedPtr TokenRes"
},
{
"path": "sentinel-core/slot/base/token_result.h",
"chars": 1292,
"preview": "#pragma once\n\n#include <chrono>\n#include <string>\n\n#include \"absl/types/optional.h\"\n\nnamespace Sentinel {\nnamespace Slot"
},
{
"path": "sentinel-core/slot/global_slot_chain.cc",
"chars": 1305,
"preview": "#include <memory>\n\n#include \"sentinel-core/circuitbreaker/slot.h\"\n#include \"sentinel-core/flow/flow_slot.h\"\n#include \"se"
},
{
"path": "sentinel-core/slot/global_slot_chain.h",
"chars": 209,
"preview": "#pragma once\n\n#include <memory>\n\n#include \"sentinel-core/slot/base/slot_chain.h\"\n\nnamespace Sentinel {\nnamespace Slot {\n"
},
{
"path": "sentinel-core/slot/log_slot.cc",
"chars": 1189,
"preview": "#include \"sentinel-core/slot/log_slot.h\"\n\n#include \"sentinel-core/log/log_base.h\"\n#include \"sentinel-core/utils/time_uti"
},
{
"path": "sentinel-core/slot/log_slot.h",
"chars": 1040,
"preview": "#pragma once\n\n#include <memory>\n\n#include \"sentinel-core/log/block/block_log_task.h\"\n#include \"sentinel-core/log/log_bas"
},
{
"path": "sentinel-core/slot/resource_node_builder_slot.cc",
"chars": 980,
"preview": "#include <memory>\n#include <string>\n\n#include \"sentinel-core/slot/resource_node_builder_slot.h\"\n\nnamespace Sentinel {\nna"
},
{
"path": "sentinel-core/slot/resource_node_builder_slot.h",
"chars": 1004,
"preview": "#pragma once\n\n#include <memory>\n#include <string>\n\n#include \"sentinel-core/slot/base/stats_slot.h\"\n#include \"sentinel-co"
},
{
"path": "sentinel-core/slot/resource_node_builder_slot_test.cc",
"chars": 2632,
"preview": "#include <memory>\n#include <string>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/common/e"
},
{
"path": "sentinel-core/slot/statistic_slot.cc",
"chars": 4318,
"preview": "#include \"sentinel-core/slot/statistic_slot.h\"\n#include \"sentinel-core/common/constants.h\"\n#include \"sentinel-core/commo"
},
{
"path": "sentinel-core/slot/statistic_slot.h",
"chars": 1939,
"preview": "#pragma once\n\n#include \"sentinel-core/common/constants.h\"\n#include \"sentinel-core/param/param_flow_slot.h\"\n#include \"sen"
},
{
"path": "sentinel-core/slot/statistic_slot_test.cc",
"chars": 2021,
"preview": "#include <chrono>\n#include <memory>\n#include <thread>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sent"
},
{
"path": "sentinel-core/statistic/base/BUILD",
"chars": 2745,
"preview": "load(\"//bazel:copts.bzl\", \"DEFAULT_COPTS\", \"TEST_COPTS\")\n\npackage(default_visibility = [\"//visibility:public\"])\n\ncc_libr"
},
{
"path": "sentinel-core/statistic/base/bucket_leap_array.cc",
"chars": 499,
"preview": "#include \"sentinel-core/statistic/base/bucket_leap_array.h\"\n\nnamespace Sentinel {\nnamespace Stat {\n\nstd::shared_ptr<Metr"
},
{
"path": "sentinel-core/statistic/base/bucket_leap_array.h",
"chars": 645,
"preview": "#pragma once\n\n#include <memory>\n\n#include \"sentinel-core/statistic/base/leap_array.h\"\n#include \"sentinel-core/statistic/"
},
{
"path": "sentinel-core/statistic/base/bucket_leap_array_test.cc",
"chars": 3237,
"preview": "#include <vector>\n\n#include \"gmock/gmock.h\"\n#include \"gtest/gtest.h\"\n\n#include \"sentinel-core/statistic/base/bucket_leap"
},
{
"path": "sentinel-core/statistic/base/leap_array.h",
"chars": 5690,
"preview": "#pragma once\n\n#include <chrono>\n#include <memory>\n#include <mutex>\n#include <vector>\n\n#include \"sentinel-core/log/logger"
},
{
"path": "sentinel-core/statistic/base/metric.h",
"chars": 1897,
"preview": "#pragma once\n\n#include <vector>\n\n#include \"sentinel-core/statistic/base/metric_bucket.h\"\n#include \"sentinel-core/statist"
},
{
"path": "sentinel-core/statistic/base/metric_bucket.cc",
"chars": 847,
"preview": "#include <atomic>\n\n#include \"sentinel-core/statistic/base/metric_bucket.h\"\n\nnamespace Sentinel {\nnamespace Stat {\n\nMetri"
},
{
"path": "sentinel-core/statistic/base/metric_bucket.h",
"chars": 718,
"preview": "#pragma once\n\n#include <atomic>\n#include <memory>\n\n#include \"sentinel-core/common/constants.h\"\n#include \"sentinel-core/s"
},
{
"path": "sentinel-core/statistic/base/metric_event.h",
"chars": 222,
"preview": "#pragma once\n\nnamespace Sentinel {\nnamespace Stat {\n\nenum class MetricEvent {\n PASS,\n BLOCK,\n EXCEPTION,\n COMPLETE,\n"
},
{
"path": "sentinel-core/statistic/base/metric_item.cc",
"chars": 2529,
"preview": "#include <algorithm>\n#include <sstream>\n#include <string>\n#include <vector>\n\n#include \"absl/strings/numbers.h\"\n#include "
}
]
// ... and 105 more files (download for full content)
About this extraction
This page contains the full source code of the alibaba/sentinel-cpp GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 305 files (1.1 MB), approximately 296.4k tokens, and a symbol index with 1255 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.