Skip to content

Commit bfc5550

Browse files
v0.7.3
1 parent 6eca0b1 commit bfc5550

File tree

19 files changed

+465
-157
lines changed

19 files changed

+465
-157
lines changed

README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="https://static.wikia.nocookie.net/arnelify/images/c/c8/Arnelify-logo-2024.png/revision/latest?cb=20240701012515" style="width:336px;" alt="Arnelify Logo" />
22

3-
![Arnelify Server for Python](https://img.shields.io/badge/Arnelify%20Server%20for%20Python-0.7.2-yellow) ![C++](https://img.shields.io/badge/C++-2b-red) ![G++](https://img.shields.io/badge/G++-14.2.0-blue) ![Python](https://img.shields.io/badge/Python-3.11.2-blue) ![Nuitka](https://img.shields.io/badge/Nuitka-2.6.4-blue)
3+
![Arnelify Server for Python](https://img.shields.io/badge/Arnelify%20Server%20for%20Python-0.7.3-yellow) ![C++](https://img.shields.io/badge/C++-2b-red) ![G++](https://img.shields.io/badge/G++-14.2.0-blue) ![Python](https://img.shields.io/badge/Python-3.11.2-blue) ![Nuitka](https://img.shields.io/badge/Nuitka-2.6.4-blue)
44

55
## 🚀 About
66
**Arnelify® Server for Python** - is a minimalistic dynamic library which is a powerful http-server written in C and C++.
@@ -62,6 +62,7 @@ You can find code examples <a href="https://github.com/arnelify/arnelify-server-
6262
| **SERVER_MAX_FILES_SIZE_TOTAL_MB** | Defines the maximum total size of all files in the form.|
6363
| **SERVER_MAX_FILE_SIZE_MB**| Defines the maximum size of a single file in the form.|
6464
| **SERVER_PORT**| Defines which port the server will listen on.|
65+
| **SERVER_THREAD_LIMIT**| Defines the maximum number of threads that will handle requests.|
6566
| **SERVER_QUEUE_LIMIT**| Defines the maximum size of the queue on the client socket.|
6667
| **SERVER_UPLOAD_DIR**| Specifies the upload directory for storage.|
6768

@@ -72,16 +73,16 @@ This software is licensed under the <a href="https://github.com/arnelify/arnelif
7273
Join us to help improve this software, fix bugs or implement new functionality. Active participation will help keep the software up-to-date, reliable, and aligned with the needs of its users.
7374

7475
## ⭐ Release Notes
75-
Version 0.7.2 - Minimalistic dynamic library
76+
Version 0.7.3 - Minimalistic dynamic library
7677

7778
We are excited to introduce the Arnelify Server dynamic library for Python! Please note that this version is raw and still in active development.
7879

7980
Change log:
8081

81-
* Minimalistic dynamic library
82+
* Multi-Threading
83+
* Minimalistic dynamic library for Python
8284
* Block processing in "on-the-fly" mode
8385
* GZIP support
84-
* Boost and Magic libraries have been removed
8586
* Significant refactoring and optimizations
8687

8788
Please use this version with caution, as it may contain bugs and unfinished features. We are actively working on improving and expanding the server's capabilities, and we welcome your feedback and suggestions.

arnelify_server/cpp/addon.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include "json.h"
99
#include "napi.h"
1010

11-
#include "uds/index.cpp"
11+
#include "uds/index.hpp"
1212
#include "index.cpp"
1313

1414
ArnelifyServer* server = nullptr;
@@ -150,6 +150,16 @@ Napi::Value server_create(const Napi::CallbackInfo& args) {
150150
return env.Undefined();
151151
}
152152

153+
const bool hasThreadLimit =
154+
json.isMember("SERVER_THREAD_LIMIT") && json["SERVER_THREAD_LIMIT"].isInt();
155+
if (!hasThreadLimit) {
156+
Napi::TypeError::New(env,
157+
"[Arnelify Server]: C++ error: "
158+
"'SERVER_THREAD_LIMIT' is missing.")
159+
.ThrowAsJavaScriptException();
160+
return env.Undefined();
161+
}
162+
153163
const bool hasQueueLimit =
154164
json.isMember("SERVER_QUEUE_LIMIT") && json["SERVER_QUEUE_LIMIT"].isInt();
155165
if (!hasQueueLimit) {
@@ -181,11 +191,11 @@ Napi::Value server_create(const Napi::CallbackInfo& args) {
181191
json["SERVER_MAX_FILES"].asInt(),
182192
json["SERVER_MAX_FILES_SIZE_TOTAL_MB"].asInt(),
183193
json["SERVER_MAX_FILE_SIZE_MB"].asInt(), json["SERVER_PORT"].asInt(),
184-
json["SERVER_QUEUE_LIMIT"].asInt(), json["SERVER_UPLOAD_DIR"].asString());
194+
json["SERVER_THREAD_LIMIT"].asInt(), json["SERVER_QUEUE_LIMIT"].asInt(),
195+
json["SERVER_UPLOAD_DIR"].asString());
185196

186197
server = new ArnelifyServer(opts);
187-
server->setHandler([](const ArnelifyServerReq& req, ArnelifyServerRes res)
188-
{
198+
server->setHandler([](const ArnelifyServerReq& req, ArnelifyServerRes res) {
189199
std::promise<const std::string> promise;
190200
std::future<const std::string> future = promise.get_future();
191201
std::thread thread(
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#ifndef ARNELIFY_SERVER_LOGGER_HPP
2+
#define ARNELIFY_SERVER_LOGGER_HPP
3+
4+
#include <functional>
5+
6+
using ArnelifyServerLogger =
7+
std::function<void(const std::string &, const bool &)>;
8+
9+
#endif

arnelify_server/cpp/contracts/opts.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@ struct ArnelifyServerOpts final {
1616
const std::size_t SERVER_MAX_FILES_SIZE_TOTAL_MB;
1717
const std::size_t SERVER_MAX_FILE_SIZE_MB;
1818
const int SERVER_PORT;
19+
const int SERVER_THREAD_LIMIT;
1920
const int SERVER_QUEUE_LIMIT;
2021
const std::filesystem::path SERVER_UPLOAD_DIR;
2122

2223
ArnelifyServerOpts(const bool &a, const int &b, const std::string &c,
2324
const bool &g, const bool &k, const int &mfd,
2425
const int &mfdst, const int &mfl, const int &mflst,
25-
const int &mfls, const int &p, const int &q,
26+
const int &mfls, const int &p, const int tl, const int &q,
2627
const std::string &u = "./src/storage/upload")
2728
: SERVER_ALLOW_EMPTY_FILES(a),
2829
SERVER_BLOCK_SIZE_KB(b),
@@ -35,6 +36,7 @@ struct ArnelifyServerOpts final {
3536
SERVER_MAX_FILES_SIZE_TOTAL_MB(mflst),
3637
SERVER_MAX_FILE_SIZE_MB(mfls),
3738
SERVER_PORT(p),
39+
SERVER_THREAD_LIMIT(tl),
3840
SERVER_QUEUE_LIMIT(q),
3941
SERVER_UPLOAD_DIR(u) {};
4042
};

arnelify_server/cpp/ffi.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,15 @@ void server_create(const char *cOpts) {
119119
exit(1);
120120
}
121121

122+
const bool hasThreadLimit =
123+
json.isMember("SERVER_THREAD_LIMIT") && json["SERVER_THREAD_LIMIT"].isInt();
124+
if (!hasThreadLimit) {
125+
std::cout << "[Arnelify Server FFI]: C error: "
126+
"'SERVER_THREAD_LIMIT' is missing."
127+
<< std::endl;
128+
exit(1);
129+
}
130+
122131
const bool hasQueueLimit =
123132
json.isMember("SERVER_QUEUE_LIMIT") && json["SERVER_QUEUE_LIMIT"].isInt();
124133
if (!hasQueueLimit) {
@@ -141,7 +150,8 @@ void server_create(const char *cOpts) {
141150
json["SERVER_MAX_FILES"].asInt(),
142151
json["SERVER_MAX_FILES_SIZE_TOTAL_MB"].asInt(),
143152
json["SERVER_MAX_FILE_SIZE_MB"].asInt(), json["SERVER_PORT"].asInt(),
144-
json["SERVER_QUEUE_LIMIT"].asInt(), json["SERVER_UPLOAD_DIR"].asString());
153+
json["SERVER_THREAD_LIMIT"].asInt(), json["SERVER_QUEUE_LIMIT"].asInt(),
154+
json["SERVER_UPLOAD_DIR"].asString());
145155

146156
server = new ArnelifyServer(opts);
147157
}
@@ -150,7 +160,8 @@ void server_destroy() { server = nullptr; }
150160

151161
void server_set_handler(const char *(*cHandler)(const char *),
152162
const int hasRemove) {
153-
server->setHandler([cHandler, hasRemove](const ArnelifyServerReq &req, ArnelifyServerRes res) -> void {
163+
server->setHandler([cHandler, hasRemove](const ArnelifyServerReq &req,
164+
ArnelifyServerRes res) -> void {
154165
Json::StreamWriterBuilder writer;
155166
writer["indentation"] = "";
156167
writer["emitUTF8"] = true;
@@ -191,7 +202,6 @@ void server_set_handler(const char *(*cHandler)(const char *),
191202
if (json.isMember("filePath") && json.isMember("isStatic") &&
192203
json["filePath"].isString() && json["isStatic"].isBool() &&
193204
!json["filePath"].asString().empty()) {
194-
195205
res->setFile(json["filePath"].asString(), json["isStatic"].asBool());
196206
res->end();
197207
return;

0 commit comments

Comments
 (0)