echo-web-server
☁️ A C++20 echo web server using a thread pool, an epoll and non-blocking sockets to process requests, consisting of a YAML-based configuration, a customizable logger and a min-heap-based timer.(使用C++20开发的Web回声服务器,使用线程池、epoll和非阻塞套接字处理网络请求,并包含YAML配置、日志记录和基于最小堆的定时器。)
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.6%) to scientific vocabulary
Keywords
Repository
☁️ A C++20 echo web server using a thread pool, an epoll and non-blocking sockets to process requests, consisting of a YAML-based configuration, a customizable logger and a min-heap-based timer.(使用C++20开发的Web回声服务器,使用线程池、epoll和非阻塞套接字处理网络请求,并包含YAML配置、日志记录和基于最小堆的定时器。)
Basic Info
Statistics
- Stars: 54
- Watchers: 1
- Forks: 0
- Open Issues: 0
- Releases: 0
Topics
Metadata Files
README.md
Echo Web Server
Introduction
A C++20 echo web server running on Linux.
If a user inputs a name <user> and a message <msg>, the server will reply with <user> said "<msg>".
- Using a YAML-based configuration system, supporting the notification of value changes and parsing containers and custom types.
- Using a customizable logging system, supporting synchronous and asynchronous modes.
- Using auto-expandable buffers to store data.
- Using a state machine to parse HTTP requests.
- Using a thread pool, an epoll and non-blocking sockets to process HTTP requests.
- Using a timer system based on a min-heap to close timed-out connections.
- Unit tests using GoogleTest.
Getting Started
Prerequisites
- Install and start Docker.
Building
Set the location to the project folder and run:
bash
docker image build . -t <image>
<image> should be replaced with a custom Docker image name.
Running Tests
bash
docker container run <image> ctest --test-dir .. -VV
Usage
Configuration
config.yaml is the default configuration. It will be copied to Docker during the building.
yaml
server:
# The TCP listening port.
port: 10000
# The website folder.
asset_folder: "assets"
# The maximum alive time for client timers (in seconds).
# When a client's timer reaches zero and it has no activity, it will disconnect.
alive_time: 60
loggers:
- name: root
level: info
appenders:
- type: stdout
Here are two ways to make a new configuration effective.
- Change
config.yamland build a new Docker image. - Enter an existing Docker container and change
build/bin/config.yaml.
See src/log/README.md for more details if you want to change logger configuration.
Running the Server
bash
docker container run -p <container-port>:<host-port> <image>
<container-port> should be equal to server.port in config.yaml. <host-port> can be any available port of the host machine. -p <container-port>:<host-port> binds <container-port> of the container to <host-port> of the host machine.
After the server is running, open a browser and access http://localhost:<host-port> on the host machine to use it.
You can run the following command and access http://localhost:10000 if you are using the default configuration.
bash
docker container run -p 10000:10000 <image>
Unit Tests
The unit tests perform using the GoogleTest framework, consisting of public and private tests.
- Public tests are in the
testsfolder. - Private tests are in the same folder as the corresponding modules.
The name of an unit test file ends with _test.
Documents
The code comment style follows the Doxygen specification.
The class diagram follows the Mermaid specification.
Structure
.
├── CITATION.cff
├── CMakeLists.txt
├── Dockerfile
├── LICENSE
├── README.md
├── .github
│ └── workflows
│ └── cmake-gtest.yaml
├── assets
│ ├── favicon.ico
│ ├── http-status.html
│ └── index.html
├── config.yaml
├── docs
│ └── badges
│ ├── C++.svg
│ ├── License-MIT.svg
│ ├── Linux.svg
│ ├── Made-with-CMake.svg
│ ├── Made-with-GitHub-Actions.svg
│ └── Made-with-Docker.svg
├── include
│ ├── config.h
│ ├── containers
│ │ ├── block_deque.h
│ │ ├── buffer.h
│ │ ├── epoller.h
│ │ ├── heap_timer.h
│ │ └── thread_pool.h
│ ├── http.h
│ ├── io.h
│ ├── ip.h
│ ├── log.h
│ ├── test_util.h
│ ├── util.h
│ └── web_server.h
├── src
│ ├── CMakeLists.txt
│ ├── config
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ └── config.cpp
│ ├── containers
│ │ ├── CMakeLists.txt
│ │ ├── buffer
│ │ │ ├── CMakeLists.txt
│ │ │ ├── README.md
│ │ │ └── buffer.cpp
│ │ ├── epoller
│ │ │ ├── CMakeLists.txt
│ │ │ └── epoller.cpp
│ │ └── thread_pool
│ │ ├── CMakeLists.txt
│ │ └── thread_pool.cpp
│ ├── http
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── http.cpp
│ │ ├── request.cpp
│ │ ├── request.h
│ │ ├── request_test.cpp
│ │ ├── response.cpp
│ │ ├── response.h
│ │ └── response_test.cpp
│ ├── io
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ └── io.cpp
│ ├── ip
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ └── ip.cpp
│ ├── log
│ │ ├── CMakeLists.txt
│ │ ├── README.md
│ │ ├── appender.cpp
│ │ ├── config_init.cpp
│ │ ├── config_init.h
│ │ ├── config_init_test.cpp
│ │ ├── field.cpp
│ │ ├── field.h
│ │ ├── field_test.cpp
│ │ └── log.cpp
│ ├── main.cpp
│ ├── test_util
│ │ ├── CMakeLists.txt
│ │ └── test_util.cpp
│ └── util
│ ├── CMakeLists.txt
│ └── util.cpp
└── tests
├── CMakeLists.txt
├── config_test.cpp
├── containers
│ ├── block_deque_test.cpp
│ ├── buffer_test.cpp
│ ├── heap_timer_test.cpp
│ └── thread_pool_test.cpp
├── http_test.cpp
├── io_test.cpp
├── ip_test.cpp
├── log_test.cpp
└── util_test.cpp
Dependencies
References
License
Distributed under the MIT License. See LICENSE for more information.
Owner
- Name: Zhuagenborn
- Login: Zhuagenborn
- Kind: organization
- Location: Ireland
- Repositories: 3
- Profile: https://github.com/Zhuagenborn
Software Development | Artificial Intelligence | Reverse Engineering.
Citation (CITATION.cff)
cff-version: 1.2.0 authors: - family-names: Chen given-names: Zhenshuo orcid: https://orcid.org/0000-0003-2091-4160 - family-names: Liu given-names: Guowen orcid: https://orcid.org/0000-0002-8375-5729 title: Echo Web Server date-released: 2023-01-08 url: https://github.com/Zhuagenborn/Echo-Web-Server
GitHub Events
Total
- Watch event: 1
- Push event: 5
Last Year
- Watch event: 1
- Push event: 5
Issues and Pull Requests
Last synced: about 1 year ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- actions/checkout main composite
- actions/download-artifact main composite
- actions/upload-artifact main composite
- ubuntu latest build