macaw_framework 1.2.0 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/CHANGELOG.md +9 -1
- data/README.md +18 -6
- data/lib/macaw_framework/aspects/logging_aspect.rb +2 -7
- data/lib/macaw_framework/version.rb +1 -1
- data/lib/macaw_framework.rb +4 -2
- data/sig/macaw_framework/macaw.rbs +4 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75201cbb67c0e3d1f913751ed085cf3102f42794a3d5f3721b4acd00234ac257
|
4
|
+
data.tar.gz: 1b15fe1043c6213fe8a7f5be7ea22f2ed1bd6c917215de79edf66b622e6c2e85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f6feb4910080a14c3908a8f5d89d5768fbf40e40882f8d98e6ecfdcf99475ec86e0522bd09f0db9b73577e2e1b72912f1db9da169271ac5b403bc680e09a0a4
|
7
|
+
data.tar.gz: 2417693c644f10af4c4a23186dde6451405c1a34c595ec507292f5eba1f7451193a4e728b9cd28195bc1010ab22f8f4a7368240e016e3f871515cb3ec22ea242
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -108,6 +108,14 @@
|
|
108
108
|
- Optimizing bug report template on GitHub
|
109
109
|
- Optimizing return clause of the get_files_public_folder method
|
110
110
|
|
111
|
-
## [1.2.0] - 2023-
|
111
|
+
## [1.2.0] - 2023-10-05
|
112
112
|
|
113
113
|
- Fixing bug where the server would accept new connections during shutdown
|
114
|
+
|
115
|
+
## [1.2.1] - 2023-11-06
|
116
|
+
|
117
|
+
- Simplifying logging aspect for readability
|
118
|
+
|
119
|
+
## [1.2.2]
|
120
|
+
|
121
|
+
- Including possibility of setting port, bind and threads programmatically
|
data/README.md
CHANGED
@@ -8,6 +8,7 @@ provides developers with the essential tools to quickly build and deploy their a
|
|
8
8
|
- [MacawFramework](#macawframework)
|
9
9
|
* [Features](#features)
|
10
10
|
* [Installation](#installation)
|
11
|
+
* [Performance](#performance)
|
11
12
|
* [Compatibility](#compatibility)
|
12
13
|
* [MacawFramework's Built-In Web Server](#macawframeworks-built-in-web-server)
|
13
14
|
* [Usage](#usage)
|
@@ -42,6 +43,10 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
42
43
|
|
43
44
|
$ gem install macaw_framework
|
44
45
|
|
46
|
+
## Performance
|
47
|
+
|
48
|
+
We evaluated MacawFramework (Version 1.2.0) to assess its ability to handle simultaneous requests under heavy load. Disabling non-essential features, such as cache and logging, we observed remarkable results. The framework demonstrated efficient memory usage (243.3 MB average) and handled an impressive 600,000 HTTP requests with an average response time of just 1 millisecond. Throughput reached an outstanding 10,196.45 requests per second. These findings suggest that MacawFramework is well-equipped to handle substantial HTTP traffic without significant performance degradation. For detailed results, please refer to the [full report](https://github.com/ariasdiniz/macaw_performance_test).
|
49
|
+
|
45
50
|
## Compatibility
|
46
51
|
|
47
52
|
MacawFramework is built to be highly compatible, since it uses only native Ruby code:
|
@@ -132,12 +137,6 @@ end
|
|
132
137
|
"port": 8080,
|
133
138
|
"bind": "localhost",
|
134
139
|
"threads": 200,
|
135
|
-
"log": {
|
136
|
-
"max_length": 1024,
|
137
|
-
"sensitive_fields": [
|
138
|
-
"password"
|
139
|
-
]
|
140
|
-
},
|
141
140
|
"cache": {
|
142
141
|
"cache_invalidation": 3600,
|
143
142
|
"ignore_headers": [
|
@@ -225,11 +224,24 @@ MacawFramework::Macaw.new(custom_log: nil)
|
|
225
224
|
- URL parameters like `...endOfUrl?key1=value1&key2=value2` can be found in the `context[:params]`
|
226
225
|
|
227
226
|
```ruby
|
227
|
+
m = MacawFramework::Macaw.new
|
228
|
+
|
228
229
|
m.get('/test_params') do |context|
|
229
230
|
context[:params]["key1"] # returns: value1
|
230
231
|
end
|
231
232
|
```
|
232
233
|
|
234
|
+
- You can also set `port`, `bind` and `threads` programmatically as shown below. This will override values set in the
|
235
|
+
`application.json` file
|
236
|
+
|
237
|
+
```ruby
|
238
|
+
m = MacawFramework::Macaw.new
|
239
|
+
|
240
|
+
m.port = 3000
|
241
|
+
m.bind = '0.0.0.0'
|
242
|
+
m.threads = 300
|
243
|
+
```
|
244
|
+
|
233
245
|
- The default number of virtual threads in the thread pool is 200.
|
234
246
|
|
235
247
|
- Rate Limit window should also be specified in seconds. Rate limit will be activated only if the `rate_limiting` config
|
@@ -12,17 +12,12 @@ module LoggingAspect
|
|
12
12
|
return super(*args) if logger.nil?
|
13
13
|
|
14
14
|
endpoint_name = args[1].split(".")[1..].join("/")
|
15
|
-
logger.info(
|
16
|
-
"Request received for #{endpoint_name} with arguments: #{args[2..]}"
|
17
|
-
))
|
15
|
+
logger.info("Request received for [#{endpoint_name}] from [#{args[-1]}]")
|
18
16
|
|
19
17
|
begin
|
20
18
|
response = super(*args)
|
21
|
-
logger.info(LogDataFilter.sanitize_for_logging("Response for #{endpoint_name}: #{response}"))
|
22
19
|
rescue StandardError => e
|
23
|
-
logger.error(
|
24
|
-
LogDataFilter.sanitize_for_logging("Error processing #{endpoint_name}: #{e.message}\n#{e.backtrace.join("\n")}")
|
25
|
-
)
|
20
|
+
logger.error("#{e.message}\n#{e.backtrace.join("\n")}")
|
26
21
|
raise e
|
27
22
|
end
|
28
23
|
|
data/lib/macaw_framework.rb
CHANGED
@@ -20,7 +20,8 @@ module MacawFramework
|
|
20
20
|
class Macaw
|
21
21
|
##
|
22
22
|
# Array containing the routes defined in the application
|
23
|
-
attr_reader :routes, :
|
23
|
+
attr_reader :routes, :macaw_log, :config, :jobs
|
24
|
+
attr_accessor :port, :bind, :threads
|
24
25
|
|
25
26
|
##
|
26
27
|
# @param {Logger} custom_log
|
@@ -49,7 +50,7 @@ module MacawFramework
|
|
49
50
|
@endpoints_to_cache = []
|
50
51
|
@prometheus ||= nil
|
51
52
|
@prometheus_middleware ||= nil
|
52
|
-
@
|
53
|
+
@server_class = server
|
53
54
|
end
|
54
55
|
|
55
56
|
##
|
@@ -161,6 +162,7 @@ module MacawFramework
|
|
161
162
|
@macaw_log.info("Number of threads: #{@threads}")
|
162
163
|
@macaw_log.info("---------------------------------")
|
163
164
|
end
|
165
|
+
@server = @server_class.new(self, @endpoints_to_cache, @cache, @prometheus, @prometheus_middleware)
|
164
166
|
server_loop(@server)
|
165
167
|
rescue Interrupt
|
166
168
|
if @macaw_log.nil?
|
@@ -9,18 +9,17 @@ module MacawFramework
|
|
9
9
|
|
10
10
|
@prometheus: untyped
|
11
11
|
@prometheus_middleware: untyped
|
12
|
-
@server:
|
12
|
+
@server: untyped
|
13
13
|
|
14
14
|
@threads: Integer
|
15
15
|
|
16
|
-
|
16
|
+
attr_accessor bind: String
|
17
17
|
attr_reader config: Hash[String, untyped]
|
18
18
|
attr_reader jobs: Array[String]
|
19
19
|
attr_reader macaw_log: Logger?
|
20
|
-
|
20
|
+
attr_accessor port: Integer
|
21
21
|
attr_reader routes: Array[String]
|
22
|
-
|
23
|
-
attr_reader threads: Integer
|
22
|
+
attr_accessor threads: Integer
|
24
23
|
|
25
24
|
def delete: -> nil
|
26
25
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macaw_framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aria Diniz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prometheus-client
|