Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 61 additions & 61 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
# NOTE: if this CI check breaks, just remove it, docker checks are enough anyway.

name: CI

'on':
schedule:
- cron: '30 5 * * 1' # Every Monday at 5:30
pull_request:
push:
branches:
- develop

env:
UBSAN_OPTIONS: print_stacktrace=1

jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
make: test-debug
info: g++-11 + test-debug

- os: ubuntu-24.04
make: test-release
info: g++-11 + test-release

name: '${{matrix.os}}: ${{matrix.info}}'
runs-on: ${{matrix.os}}

steps:
- uses: actions/checkout@v4
with:
submodules: true

- name: Reuse ccache directory
uses: actions/cache@v4
with:
path: ~/.cache/ccache
key: '${{matrix.os}} ${{matrix.info}} ccache-dir ${{github.ref}} run-${{github.run_number}}'
restore-keys: |
${{matrix.os}} ${{matrix.info}} ccache-dir ${{github.ref}} run-'
${{matrix.os}} ${{matrix.info}} ccache-

- name: Install packages
run: |
DEPS_FILE="https://raw.githubusercontent.com/userver-framework/userver/refs/heads/develop/scripts/docs/en/deps/${{matrix.os}}.md"
sudo apt update
sudo apt install --allow-downgrades -y $(wget -q -O - ${DEPS_FILE})
python3 -m pip install -r requirements.txt

- name: Setup ccache
run: |
ccache -M 2.0GB
ccache -s

- name: Run ${{matrix.make}}
run: |
make ${{matrix.make}}
# # NOTE: if this CI check breaks, just remove it, docker checks are enough anyway.

# name: CI

# 'on':
# schedule:
# - cron: '30 5 * * 1' # Every Monday at 5:30
# pull_request:
# push:
# branches:
# - develop

# env:
# UBSAN_OPTIONS: print_stacktrace=1

# jobs:
# posix:
# strategy:
# fail-fast: false
# matrix:
# include:
# - os: ubuntu-24.04
# make: test-debug
# info: g++-11 + test-debug

# - os: ubuntu-24.04
# make: test-release
# info: g++-11 + test-release

# name: '${{matrix.os}}: ${{matrix.info}}'
# runs-on: ${{matrix.os}}

# steps:
# - uses: actions/checkout@v4
# with:
# submodules: true

# - name: Reuse ccache directory
# uses: actions/cache@v4
# with:
# path: ~/.cache/ccache
# key: '${{matrix.os}} ${{matrix.info}} ccache-dir ${{github.ref}} run-${{github.run_number}}'
# restore-keys: |
# ${{matrix.os}} ${{matrix.info}} ccache-dir ${{github.ref}} run-'
# ${{matrix.os}} ${{matrix.info}} ccache-

# - name: Install packages
# run: |
# DEPS_FILE="https://raw.githubusercontent.com/userver-framework/userver/refs/heads/develop/scripts/docs/en/deps/${{matrix.os}}.md"
# sudo apt update
# sudo apt install --allow-downgrades -y $(wget -q -O - ${DEPS_FILE})
# python3 -m pip install -r requirements.txt

# - name: Setup ccache
# run: |
# ccache -M 2.0GB
# ccache -s

# - name: Run ${{matrix.make}}
# run: |
# make ${{matrix.make}}
66 changes: 33 additions & 33 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
name: Docker build
# name: Docker build

'on':
schedule:
- cron: '30 5 * * 1' # Every Monday at 5:30
pull_request:
push:
branches:
- master
- develop
- feature/**
# 'on':
# schedule:
# - cron: '30 5 * * 1' # Every Monday at 5:30
# pull_request:
# push:
# branches:
# - master
# - develop
# - feature/**

env:
UBSAN_OPTIONS: print_stacktrace=1
# env:
# UBSAN_OPTIONS: print_stacktrace=1

jobs:
tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
# jobs:
# tests:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: true

- name: Reuse ccache directory
uses: actions/cache@v4
with:
path: .ccache
key: 'ccache-dir-${{github.ref}}_run-${{github.run_number}}'
restore-keys: |
ccache-dir-${{github.ref}}_run-
ccache-
# - name: Reuse ccache directory
# uses: actions/cache@v4
# with:
# path: .ccache
# key: 'ccache-dir-${{github.ref}}_run-${{github.run_number}}'
# restore-keys: |
# ccache-dir-${{github.ref}}_run-
# ccache-

- name: Cmake
run: make docker-cmake-debug
# - name: Cmake
# run: make docker-cmake-debug

- name: Build
run: make docker-build-debug
# - name: Build
# run: make docker-build-debug

- name: Test
run: make docker-test-debug
# - name: Test
# run: make docker-test-debug
21 changes: 16 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ include(DownloadUserver)

find_package(
userver
COMPONENTS core #
COMPONENTS
core
QUIET
)
if(NOT userver_FOUND)
Expand All @@ -18,17 +19,25 @@ endif()
userver_setup_environment()

# Common sources

file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.[hc]pp)
file(GLOB_RECURSE UNIT_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*_test.cpp)
file(GLOB_RECURSE BENCHMARK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*_benchmark.cpp)
file(GLOB_RECURSE LIBUBENCH_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/benchmarks_main.cpp)
list(REMOVE_ITEM SOURCES ${BENCH_SOURCES} ${LIBUBENCH_SOURCES})
list(REMOVE_ITEM SOURCES ${UNIT_TEST_SOURCES} ${BENCHMARK_SOURCES} ${LIBUBENCH_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)

include_directories(src)
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.[hc]pp)
file(GLOB_RECURSE UNIT_TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*_ut.cpp)
list(REMOVE_ITEM SOURCES ${UNIT_TEST_SOURCES} ${BENCHMARK_SOURCES} ${LIBUBENCH_SOURCES} ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)


add_library(${PROJECT_NAME}_objs OBJECT ${SOURCES})

include_directories(src)
target_link_libraries(
${PROJECT_NAME}_objs
PUBLIC userver::core #
PUBLIC userver::core userver::ydb
)


Expand All @@ -42,7 +51,9 @@ target_link_libraries(${PROJECT_NAME}_unittest PRIVATE ${PROJECT_NAME}_objs user
add_google_tests(${PROJECT_NAME}_unittest)

# Functional testing
userver_testsuite_add_simple()
userver_testsuite_add_simple(
REQUIREMENTS ${CMAKE_CURRENT_SOURCE_DIR}/tests/requirements.txt
)

# Install
include(GNUInstallDirs)
Expand All @@ -64,4 +75,4 @@ install(
FILES ${CONFIGS_FILES}
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/${PROJECT_NAME}
COMPONENT ${PROJECT_NAME}
)
)
2 changes: 2 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
"hidden": true,
"generator": "Ninja",
"cacheVariables": {
"USERVER_FEATURE_GRPC": "ON",
"USERVER_FEATURE_YDB": "ON",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
}
Expand Down
1 change: 1 addition & 0 deletions configs/secure_data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
31 changes: 31 additions & 0 deletions configs/static_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ components_manager:
# See userver "dynamic config" docs for what configs exist.
defaults:
HTTP_CLIENT_CONNECTION_POOL_SIZE: 1000

default-secdist-provider:
config: secure_data.json

testsuite-support: {}

Expand All @@ -48,6 +51,34 @@ components_manager:
method: POST
task_processor: main-task-processor

ydb:
operation-settings:
cancel-after: 1000ms
client-timeout: 1100ms
operation-timeout: 1000ms
retries: 3
databases:
chat_db:
database: chat_db
max_pool_size: 10
min_pool_size: 5

coordination-repository:
dbname: chat_db

coordination-gateway:
dbname: chat_db
coordination-node: chat-coordination
partition-map-semaphore: partition-map-lock
discovery-semaphore: discovery-lock
initial-setup: true

coordination-dist-lock:
database-settings:
dbname: chat_db
coordination-node: chat-coordination
semaphore-name: partition-map-lock

handler-ping:
path: /ping
method: GET
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
pycodestyle
pycodestyle
ydb >= 3.5.2
25 changes: 25 additions & 0 deletions src/core/coordination/coordination_gateway.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include <core/common/hub_params.hpp>
#include <core/partition/partition_map.hpp>

#include <optional>
#include <vector>

namespace NCoordinator::NCore::NDomain {

////////////////////////////////////////////////////////////////////////////////

class ICoordinationGateway {
public:
virtual std::optional<TPartitionMap> GetPartitionMap() const = 0;
virtual void BroadcastPartitionMap(const TPartitionMap& partitionMap) const = 0;

virtual std::vector<THubEndpoint> GetHubDiscovery() const = 0;

virtual ~ICoordinationGateway() = default;
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NCoordinator::NCore::NDomain
15 changes: 15 additions & 0 deletions src/core/coordination/coordination_repository.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#pragma once

#include "coordination_context.hpp"

namespace NCoordinator::NCore::NDomain {

class ICoordinationRepository {
public:
virtual TCoordinationContext GetCoordinationContext() const = 0;
virtual void SetCoordinationContext(const TCoordinationContext& context) const = 0;

virtual ~ICoordinationRepository() = default;
};

} // namespace NCoordinator::NCore::NDomain
20 changes: 20 additions & 0 deletions src/core/hub/hub_gateway.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#pragma once

#include "hub_report.hpp"

#include <vector>

namespace NCoordinator::NCore::NDomain {

////////////////////////////////////////////////////////////////////////////////

class IHubGateway {
public:
virtual std::vector<THubReport> GetHubReports(const std::vector<THubEndpoint>& hubs) const = 0;

virtual ~IHubGateway() = default;
};

////////////////////////////////////////////////////////////////////////////////

} // namespace NCoordinator::NCore::NDomain
Loading