Skip to content

Commit 29c17ef

Browse files
authored
Merge branch 'develop' into init_etcd_client
2 parents f4b316a + 20d95eb commit 29c17ef

File tree

1,150 files changed

+24393
-6838
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,150 files changed

+24393
-6838
lines changed

.clang-tidy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,11 @@ Checks:
7272
,-hicpp-special-member-functions\
7373
,-hicpp-uppercase-literal-suffix\
7474
,-hicpp-vararg\
75+
,-misc-const-correctness\
7576
,-misc-include-cleaner\
7677
,-misc-no-recursion\
7778
,-misc-unconventional-assign-operator\
79+
,-misc-use-anonymous-namespace\
7880
,-modernize-avoid-c-arrays\
7981
,-modernize-pass-by-value\
8082
,-modernize-return-braced-init-list\

.github/workflows/ci-conan.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,20 @@ jobs:
4545
4646
sudo apt update
4747
sudo apt install -y postgresql redis mongodb-org mongodb-mongosh
48-
sudo ./scripts/kafka/ubuntu_install_kafka.sh
48+
49+
sudo ./scripts/kafka/install_kafka.sh
50+
4951
./scripts/rabbitmq/ubuntu_install_rabbitmq_server.sh
5052
5153
- name: Install MacOS packages
5254
if: matrix.os == 'macos-latest'
5355
run: |
5456
brew update
5557
brew tap mongodb/brew
56-
brew install clang-format postgresql redis kafka rabbitmq mongodb-community
58+
brew install clang-format postgresql redis rabbitmq mongodb-community
59+
60+
sudo ./scripts/kafka/install_kafka.sh
61+
5762
brew install [email protected]
5863
5964
- name: Install common packages

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ jobs:
180180
181181
- name: Install Kafka
182182
run: |
183-
sudo ./scripts/kafka/ubuntu_install_kafka.sh
183+
sudo ./scripts/kafka/install_kafka.sh
184184
185185
- name: Install RabbitMQ packages
186186
run: |
@@ -315,3 +315,8 @@ jobs:
315315
run: |
316316
cd build_debug/scripts/gdb/tests
317317
ctest -V
318+
319+
- name: Run tests (sqlite)
320+
run: |
321+
cd build_debug/sqlite
322+
ctest -V

.github/workflows/macos.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ jobs:
6666
brew link --force curl # keg-only
6767
brew link --force cyrus-sasl # keg-only
6868
brew link --force openldap # keg-only
69+
brew link --force sqlite # keg-only
6970
brew remove --ignore-dependencies abseil
7071
7172
- name: Install test dependencies
7273
run: |
7374
brew tap mongodb/brew
74-
brew install clickhouse redis kafka mongodb-community rabbitmq
75+
brew install clickhouse redis mongodb-community rabbitmq
76+
77+
./scripts/kafka/install_kafka.sh
7578
7679
- name: Setup ccache
7780
run: |
@@ -170,3 +173,7 @@ jobs:
170173
cd build_debug/postgresql
171174
ulimit -n 4096 && GTEST_FILTER="-PostgreCluster.TransactionTimeouts" ctest -V -E testsuite-userver-postgresql-tests-basic-chaos
172175
176+
- name: Run tests (sqlite)
177+
run: |
178+
cd build_debug/sqlite
179+
ctest -V -E "userver-sqlite-unittest" # unittests failed with fs access

.github/workflows/publish-ubuntu-22.04-images.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ jobs:
3434
docker push ghcr.io/userver-framework/ubuntu-22.04-userver-pg:${USERVER_IMAGE_TAG}
3535
- name: Build the ubuntu-22.04-userver-pg-dev Docker image
3636
run: |
37-
docker build -t ghcr.io/userver-framework/ubuntu-22.04-userver-pg-dev:${USERVER_IMAGE_TAG} -f scripts/docker/ubuntu-22.04-pg-dev.dockerfile .
38-
docker push ghcr.io/userver-framework/ubuntu-22.04-userver-pg-dev:${USERVER_IMAGE_TAG}
37+
docker build -t ghcr.io/userver-framework/ubuntu-22.04-userver-pg-dev:${USERVER_IMAGE_TAG} -f scripts/docker/ubuntu-22.04-pg-dev.dockerfile .
38+
docker push ghcr.io/userver-framework/ubuntu-22.04-userver-pg-dev:${USERVER_IMAGE_TAG}

.mapping.json

Lines changed: 244 additions & 10 deletions
Large diffs are not rendered by default.

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
1515
set(CMAKE_POLICY_DEFAULT_CMP0074 NEW)
1616
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
1717

18-
project(userver)
18+
project(userver CXX)
1919

2020
set(USERVER_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}")
2121

@@ -146,6 +146,8 @@ option(USERVER_FEATURE_MYSQL "Provide asynchronous driver for MariaDB/MySQL" "${
146146
option(USERVER_FEATURE_ROCKS "Provide asynchronous driver for Rocks" "${USERVER_LIB_ENABLED_DEFAULT}")
147147
option(USERVER_FEATURE_YDB "Provide asynchronous driver for YDB" "${USERVER_YDB_DEFAULT}")
148148
option(USERVER_FEATURE_OTLP "Provide asynchronous OTLP exporters" "${USERVER_LIB_ENABLED_DEFAULT}")
149+
option(USERVER_FEATURE_SQLITE "Provide asynchronous driver for SQLite" "${USERVER_LIB_ENABLED_DEFAULT}")
150+
option(USERVER_FEATURE_ODBC "Provide asynchronous wrapper around ODBC" "${USERVER_LIB_ENABLED_DEFAULT}")
149151
option(USERVER_FEATURE_ETCD "Provide asynchronous driver for etcd" "${USERVER_LIB_ENABLED_DEFAULT}")
150152

151153
set(CMAKE_DEBUG_POSTFIX d)
@@ -299,6 +301,18 @@ if (USERVER_FEATURE_YDB)
299301
list(APPEND USERVER_AVAILABLE_COMPONENTS ydb)
300302
endif()
301303

304+
if (USERVER_FEATURE_SQLITE)
305+
_require_userver_core("USERVER_FEATURE_SQLITE")
306+
add_subdirectory(sqlite)
307+
list(APPEND USERVER_AVAILABLE_COMPONENTS sqlite)
308+
endif()
309+
310+
if (USERVER_FEATURE_ODBC)
311+
_require_userver_core("USERVER_FEATURE_ODBC")
312+
add_subdirectory(odbc)
313+
list(APPEND USERVER_AVAILABLE_COMPONENTS odbc)
314+
endif()
315+
302316
if (USERVER_FEATURE_ETCD)
303317
_require_userver_core("USERVER_FEATURE_ETCD")
304318
add_subdirectory(etcd)

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,22 @@ CMAKE_RELEASE_FLAGS += -DCMAKE_BUILD_TYPE=Release $(CMAKE_COMMON_FLAGS)
1515
.PHONY: all
1616
all: test-debug test-release
1717

18+
.PHONY: docs
19+
docs:
20+
BUILD_DIR=$(BUILD_DIR) ./scripts/docs/make_docs.sh
21+
22+
.PHONY: docs-upload
23+
docs-upload:
24+
BUILD_DIR=$(BUILD_DIR) ./scripts/docs/upload_docs.sh
25+
26+
.PHONY: docs-internal
27+
docs-internal:
28+
BUILD_DIR=$(BUILD_DIR) ../scripts/userver/docs/make_docs.sh
29+
30+
.PHONY: docs-internal-upload
31+
docs-internal-upload:
32+
BUILD_DIR=$(BUILD_DIR) OAUTH_TOKEN=$(OAUTH_TOKEN) ../scripts/userver/docs/upload_docs.sh
33+
1834
# Run cmake
1935
.PHONY: cmake-debug
2036
cmake-debug:

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# userver [<img src="./scripts/docs/img/logo.svg" align='right' width="10%">](https://userver.tech/)
22

3-
| Service Templates | Develop / Green Trunk | v2.0 | v1.0 |
4-
|-------------------|------------------------|------|------|
5-
| Core: | [![CI](https://github.com/userver-framework/service_template/actions/workflows/ci.yml/badge.svg) ![Docker build](https://github.com/userver-framework/service_template/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/service_template/) | [[]](https://github.com/userver-framework/service_template/tree/v2.0) | [[]](https://github.com/userver-framework/service_template/tree/v1.0.0) |
6-
| PostgreSQL: | [![CI](https://github.com/userver-framework/pg_service_template/actions/workflows/ci.yml/badge.svg) ![Docker build](https://github.com/userver-framework/pg_service_template/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/pg_service_template/) | [[]](https://github.com/userver-framework/pg_service_template/tree/v2.0) | [[]](https://github.com/userver-framework/pg_service_template/tree/v1.0.0) |
7-
| gRPC+PostgreSQL: | [![CI](https://github.com/userver-framework/pg_grpc_service_template/actions/workflows/ci.yml/badge.svg) ![Docker build](https://github.com/userver-framework/pg_grpc_service_template/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/pg_grpc_service_template)| [[]](https://github.com/userver-framework/pg_grpc_service_template/tree/v2.0) | [[]](https://github.com/userver-framework/pg_grpc_service_template/tree/v1.0.0) |
8-
| gRPC+Mongo: | [![CI](https://github.com/userver-framework/mongo_grpc_service_template/actions/workflows/ci.yml/badge.svg) ![Docker build](https://github.com/userver-framework/mongo_grpc_service_template/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/mongo_grpc_service_template)|||
3+
[![Ubuntu](https://github.com/userver-framework/userver/actions/workflows/ci.yml/badge.svg)](https://github.com/userver-framework/userver/actions/workflows/ci.yml)
4+
[![MacOS](https://github.com/userver-framework/userver/actions/workflows/macos.yml/badge.svg)](https://github.com/userver-framework/userver/actions/workflows/macos.yml)
5+
[![Alpine](https://github.com/userver-framework/userver/actions/workflows/alpine.yml/badge.svg)](https://github.com/userver-framework/userver/actions/workflows/alpine.yml)
6+
[![Docker CI](https://github.com/userver-framework/userver/actions/workflows/docker.yaml/badge.svg)](https://github.com/userver-framework/userver/actions/workflows/docker.yaml)
7+
[![Conan](https://github.com/userver-framework/userver/actions/workflows/ci-conan.yml/badge.svg)](https://github.com/userver-framework/userver/actions/workflows/ci-conan.yml)
8+
[![CodeQL](https://github.com/userver-framework/userver/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/userver-framework/userver/actions/workflows/codeql-analysis.yml)
9+
10+
[![Build and publish ubuntu-24.04-userver images](https://github.com/userver-framework/userver/actions/workflows/publish-ubuntu-24.04-images.yaml/badge.svg)](https://github.com/userver-framework/userver/actions/workflows/publish-ubuntu-24.04-images.yaml)
11+
[![Build and publish ubuntu-22.04-userver images](https://github.com/userver-framework/userver/actions/workflows/publish-ubuntu-22.04-images.yaml/badge.svg)](https://github.com/userver-framework/userver/actions/workflows/publish-ubuntu-22.04-images.yaml)
912

1013
**userver** is an open source asynchronous framework with a rich set of abstractions
1114
for fast and comfortable creation of C++ microservices, services and utilities.
@@ -56,7 +59,7 @@ You can learn more about history and key features of userver from our
5659
## Other Features
5760
5861
* Efficient asynchronous drivers for databases (MongoDB, PostgreSQL, Valkey,
59-
Redis, ClickHouse, MySQL/MariaDB, YDB ...) and data transfer protocols
62+
Redis, ClickHouse, MySQL/MariaDB, YDB, SQLite ...) and data transfer protocols
6063
(HTTP/{1.1, 2.0}, gRPC, AMQP 0-9-1, Kafka, TCP, TLS,
6164
WebSocket ...), tasks construction and cancellation.
6265
* Rich set of high-level components for caches, tasks, distributed locking,
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
import collections
2+
import pathlib
3+
from typing import Dict
4+
from typing import List
5+
from typing import Optional
6+
7+
import yaml
8+
9+
from . import renderer
10+
11+
TYPES_INCLUDES = [
12+
'cstdint',
13+
'fmt/core.h',
14+
'optional',
15+
'string',
16+
]
17+
18+
19+
def _get_template_includes(name: str, client_name: str, graph: Dict[str, List[str]]) -> List[str]:
20+
includes = {
21+
'client.cpp': [
22+
f'client/{client_name}/client.hpp',
23+
],
24+
'client.hpp': [
25+
'requests.hpp',
26+
'responses.hpp',
27+
'userver/chaotic/openapi/client/command_control.hpp',
28+
],
29+
'client_fwd.hpp': [],
30+
'client_impl.cpp': [
31+
f'client/{client_name}/client_impl.hpp',
32+
'userver/chaotic/openapi/middlewares/follow_redirects_middleware.hpp',
33+
'userver/chaotic/openapi/middlewares/qos_middleware.hpp',
34+
'userver/components/component_context.hpp',
35+
'userver/components/component_base.hpp',
36+
'userver/yaml_config/merge_schemas.hpp',
37+
],
38+
'client_impl.hpp': [
39+
f'client/{client_name}/client.hpp',
40+
'userver/chaotic/openapi/client/config.hpp',
41+
'userver/chaotic/openapi/middlewares/manager.hpp',
42+
'userver/clients/http/client.hpp',
43+
'userver/components/component_config.hpp',
44+
'userver/yaml_config/schema.hpp',
45+
],
46+
'exceptions.cpp': [
47+
f'client/{client_name}/exceptions.hpp',
48+
'userver/clients/http/error_kind.hpp',
49+
],
50+
'exceptions.hpp': [
51+
'userver/chaotic/openapi/client/exceptions.hpp',
52+
],
53+
'component.cpp': [
54+
f'client/{client_name}/component.hpp',
55+
'userver/chaotic/openapi/client/config.hpp',
56+
'userver/components/component_context.hpp',
57+
'userver/clients/http/component.hpp',
58+
],
59+
'component.hpp': [
60+
'userver/components/component_base.hpp',
61+
'userver/yaml_config/schema.hpp',
62+
f'client/{client_name}/client_impl.hpp',
63+
],
64+
'requests.cpp': [
65+
f'client/{client_name}/requests.hpp',
66+
'userver/chaotic/openapi/parameters_write.hpp',
67+
'userver/formats/json/value_builder.hpp',
68+
'userver/http/common_headers.hpp',
69+
'userver/http/url.hpp',
70+
'userver/clients/http/form.hpp',
71+
'userver/chaotic/openapi/form.hpp',
72+
],
73+
'requests.hpp': [
74+
'string',
75+
'variant',
76+
*[f'client/{client_name}/{dep}' for dep in graph],
77+
# TODO
78+
],
79+
'responses.cpp': [
80+
f'client/{client_name}/responses.hpp',
81+
'userver/clients/http/response.hpp',
82+
'userver/formats/json/serialize.hpp',
83+
'userver/http/common_headers.hpp',
84+
'userver/http/content_type.hpp',
85+
'userver/logging/log.hpp',
86+
],
87+
'responses.hpp': [
88+
'variant',
89+
f'client/{client_name}/exceptions.hpp',
90+
'userver/chaotic/openapi/client/exceptions.hpp',
91+
*[f'client/{client_name}/{dep}' for dep in graph],
92+
# TODO
93+
],
94+
}
95+
return includes[name]
96+
97+
98+
def trim_suffix(string: str, suffix: str) -> Optional[str]:
99+
if string.endswith(suffix):
100+
return string[: -len(suffix)]
101+
return None
102+
103+
104+
def extract_includes(name: str, path: pathlib.Path) -> Optional[List[str]]:
105+
with open(path) as ifile:
106+
content = yaml.safe_load(ifile)
107+
108+
includes: List[str] = []
109+
110+
def visit(data) -> None:
111+
if isinstance(data, dict):
112+
for v in data.values():
113+
visit(v)
114+
if '$ref' in data:
115+
ref = data['$ref']
116+
ref = ref.split('#')[0]
117+
ref_fname = ref.rsplit('/', 1)[-1]
118+
if ref_fname:
119+
stem = ref_fname.rsplit('.', 1)[0]
120+
includes.append(f'client/{name}/{stem}.hpp')
121+
if 'x-taxi-cpp-type' in data:
122+
pass
123+
if 'x-usrv-cpp-type' in data:
124+
pass
125+
elif isinstance(data, list):
126+
for v in data:
127+
visit(v)
128+
129+
if 'definitions' in content or 'components' in content or 'paths' in content:
130+
visit(content)
131+
return includes
132+
else:
133+
return None
134+
135+
136+
def include_graph(name: str, schemas_dir: pathlib.Path) -> Dict[str, List[str]]:
137+
result = {}
138+
for root, _, filenames in schemas_dir.walk():
139+
for filename in filenames:
140+
filepath = pathlib.Path(root) / filename
141+
if filepath == schemas_dir / 'client.yaml' or filename == 'a.yaml':
142+
continue
143+
result[filepath.stem + '.hpp'] = extract_includes(name, filepath)
144+
145+
return {key: result[key] for key in result if result[key] is not None} # type: ignore
146+
147+
148+
def get_includes(client_name: str, schemas_dir: str) -> Dict[str, List[str]]:
149+
graph = include_graph(client_name, pathlib.Path(schemas_dir))
150+
151+
output = collections.defaultdict(list)
152+
for name in renderer.TEMPLATE_NAMES:
153+
if name.endswith('.hpp'):
154+
rel_path = f'include/client/{client_name}/{name}'
155+
else:
156+
rel_path = f'src/client/{client_name}/{name}'
157+
output[rel_path] = _get_template_includes(name, client_name, graph)
158+
159+
for file in graph:
160+
stem = pathlib.Path(file).stem
161+
output[f'include/client/{client_name}/{stem}_fwd.hpp'] = []
162+
output[f'include/client/{client_name}/{stem}.hpp'] = [
163+
f'client/{client_name}/{stem}_fwd.hpp',
164+
'userver/chaotic/type_bundle_hpp.hpp',
165+
*TYPES_INCLUDES,
166+
*graph[file],
167+
]
168+
169+
return output
170+
171+
172+
def external_libraries(schemas_dir: str) -> List[str]:
173+
types = set()
174+
175+
def visit(data) -> None:
176+
if isinstance(data, dict):
177+
for v in data.values():
178+
visit(v)
179+
if 'x-taxi-cpp-type' in data:
180+
types.add(data['x-taxi-cpp-type'])
181+
if 'x-usrv-cpp-type' in data:
182+
types.add(data['x-usrv-cpp-type'])
183+
elif isinstance(data, list):
184+
for v in data:
185+
visit(v)
186+
187+
for file in pathlib.Path(schemas_dir).rglob('*.yaml'):
188+
with open(file) as ifile:
189+
content = yaml.safe_load(ifile)
190+
visit(content)
191+
192+
libraries = []
193+
for type_ in types:
194+
libraries.append(type_.split('::')[0].replace('_', '-'))
195+
return libraries

0 commit comments

Comments
 (0)