macaw_framework 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e463859dd8c04003288cb088a93a4bd664e3c321eb4bd49144e945e5e1582fdd
4
- data.tar.gz: fdb469e8f36de341cfc2b63ea6e9c684f8e8d3c7209521269899be340d3cad29
3
+ metadata.gz: b99afc6c030d78802a79875fad25f4739d0a5cc6789ad02d42faaa5699320e43
4
+ data.tar.gz: e1e3f6b720367cab7767b09d7c7169db61ccd38cac5c0acfaf15c9e8f475b7e7
5
5
  SHA512:
6
- metadata.gz: ef1722de3015b0b53ba18a969053f8593fa42e0f1b7f16471d474e97833f2341c1070d151e0d213ebcc6174a5bffda96424dccf5923279b1e4c896407c255a47
7
- data.tar.gz: b336869a06aff82b34147f0d76f0c51f5d526c8f8b5da0a7b77c3488f56938b719318e2e538e4bc37eea9b2d936332aa6ec68e2236d596a072cc885e7e2a443f
6
+ metadata.gz: 1f27c7790bde337380fe1a103a4512c3eda23258e8394bbea25fec07c3f30b6dbf3daa43956d84e7c4608d6a5d0d485c81cac06c4c3bb7bec5510b6b7f6abace
7
+ data.tar.gz: 93d87525ce2a24d16b46ce2e5377917facf98cb52dc2d63e4858d397a80fa5c53c7f7c1406e6b9b29488c711cb0e6f57ec43c688aa770483b2c279b0fa84dd58
data/CHANGELOG.md CHANGED
@@ -160,3 +160,6 @@
160
160
 
161
161
  ## [1.4.1] - 2026-02-01
162
162
  - Fixing issue when re-spawning new threads
163
+
164
+ ## [1.4.1] - 2026-02-24
165
+ - Removing unused Rate Limiting Middleware
data/README.md CHANGED
@@ -15,7 +15,7 @@ MacawFramework provides developers with the essential tools to quickly build and
15
15
  + [Basic routing: Define routes with support for GET, POST, PUT, PATCH, and DELETE HTTP methods](#basic-routing-define-routes-with-support-for-get-post-put-patch-and-delete-http-methods)
16
16
  + [Caching: Improve performance by caching responses and configuring cache invalidation](#caching-improve-performance-by-caching-responses-and-configuring-cache-invalidation)
17
17
  + [Session management: Handle user sessions securely with server-side in-memory storage](#session-management-handle-user-sessions-securely-with-server-side-in-memory-storage)
18
- + [Configuration: Customize various aspects of the framework through the application.json configuration file, such as rate limiting, SSL support, and Prometheus integration](#configuration-customize-various-aspects-of-the-framework-through-the-applicationjson-configuration-file-such-as-rate-limiting-ssl-support-and-prometheus-integration)
18
+ + [Configuration: Customize various aspects of the framework through the application.json configuration file, such as SSL support and Prometheus integration](#configuration-customize-various-aspects-of-the-framework-through-the-applicationjson-configuration-file-such-as-ssl-support-and-prometheus-integration)
19
19
  + [Monitoring: Easily monitor your application performance and metrics with built-in Prometheus support](#monitoring-easily-monitor-your-application-performance-and-metrics-with-built-in-prometheus-support)
20
20
  + [Routing for "public" Folder: Serve Static Assets](#routing-for-public-folder-serve-static-assets)
21
21
  + [Periodic Jobs](#periodic-jobs)
@@ -29,7 +29,7 @@ MacawFramework provides developers with the essential tools to quickly build and
29
29
  - Simple routing with support for GET, POST, PUT, PATCH, and DELETE HTTP methods
30
30
  - Caching middleware for improved performance
31
31
  - Session management with server-side in-memory storage
32
- - Basic rate limiting and SSL support
32
+ - SSL support
33
33
  - Prometheus integration for monitoring and metrics
34
34
  - Less than 26Kb
35
35
  - Easy to learn
@@ -154,7 +154,7 @@ m.get('/dashboard') do |context|
154
154
  end
155
155
  ```
156
156
 
157
- ### Configuration: Customize various aspects of the framework through the application.json configuration file, such as rate limiting, SSL support, and Prometheus integration
157
+ ### Configuration: Customize various aspects of the framework through the application.json configuration file, such as SSL support and Prometheus integration
158
158
 
159
159
  ```json
160
160
  {
@@ -168,10 +168,6 @@ end
168
168
  "prometheus": {
169
169
  "endpoint": "/metrics"
170
170
  },
171
- "rate_limiting": {
172
- "window": 10,
173
- "max_requests": 3
174
- },
175
171
  "ssl": {
176
172
  "min": "SSL3",
177
173
  "max": "TLS1.3",
@@ -271,9 +267,6 @@ m.threads = 300
271
267
 
272
268
  - The default number of virtual threads in the thread pool is 200.
273
269
 
274
- - Rate Limit window should also be specified in seconds. Rate limit will be activated only if the `rate_limiting` config
275
- exists inside `application.json`.
276
-
277
270
  - If the SSL configuration is provided in the `application.json` file with valid certificate and key files, the TCP server
278
271
  will be wrapped with HTTPS security using the provided certificate.
279
272
 
@@ -1,9 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative '../../middlewares/memory_invalidation_middleware'
4
- require_relative '../../middlewares/rate_limiter_middleware'
5
4
  require_relative '../../data_filters/response_data_filter'
6
- require_relative '../../errors/too_many_requests_error'
7
5
  require_relative '../../utils/supported_ssl_versions'
8
6
  require_relative '../../aspects/prometheus_aspect'
9
7
  require_relative '../../aspects/logging_aspect'
@@ -41,7 +39,6 @@ module ServerBase
41
39
  def handle_client(client)
42
40
  _path, method_name, headers, body, parameters = RequestDataFiltering.parse_request_data(client, @macaw.routes)
43
41
  raise EndpointNotMappedError unless @macaw.respond_to?(method_name)
44
- raise TooManyRequestsError unless @rate_limit.nil? || @rate_limit.allow?(client.peeraddr[3])
45
42
 
46
43
  client_data = get_client_data(body, headers, parameters)
47
44
  session_id = declare_client_session(client_data[:headers], @macaw.secure_header) if @macaw.session
@@ -56,8 +53,6 @@ module ServerBase
56
53
  client.puts ResponseDataFilter.mount_response(status, response_headers, message)
57
54
  rescue IOError, Errno::EPIPE => e
58
55
  @macaw_log&.error("Error writing to client: #{e.message}")
59
- rescue TooManyRequestsError
60
- client.print "HTTP/1.1 429 Too Many Requests\r\n\r\n"
61
56
  rescue EndpointNotMappedError
62
57
  client.print "HTTP/1.1 404 Not Found\r\n\r\n"
63
58
  rescue StandardError => e
@@ -78,15 +73,6 @@ module ServerBase
78
73
  session_id
79
74
  end
80
75
 
81
- def set_rate_limiting
82
- return unless @macaw.config&.dig('macaw', 'rate_limiting')
83
-
84
- @rate_limit = RateLimiterMiddleware.new(
85
- @macaw.config['macaw']['rate_limiting']['window'].to_i || 1,
86
- @macaw.config['macaw']['rate_limiting']['max_requests'].to_i || 60
87
- )
88
- end
89
-
90
76
  def set_ssl
91
77
  ssl_config = @macaw.config['macaw']['ssl'] if @macaw.config&.dig('macaw', 'ssl')
92
78
  ssl_config ||= nil
@@ -127,7 +113,6 @@ module ServerBase
127
113
 
128
114
  def set_features
129
115
  @is_shutting_down = false
130
- set_rate_limiting
131
116
  set_session
132
117
  set_ssl
133
118
  end
@@ -33,7 +33,6 @@ class ThreadServer
33
33
  @num_threads = macaw.threads
34
34
  @work_queue = Queue.new
35
35
  set_features
36
- @rate_limit ||= nil
37
36
  @cache = {
38
37
  cache: cache,
39
38
  endpoints_to_cache: endpoints_to_cache || [],
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MacawFramework
4
- VERSION = '1.4.1'
4
+ VERSION = '1.4.2'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macaw_framework
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aria Diniz
@@ -53,11 +53,9 @@ files:
53
53
  - lib/macaw_framework/data_filters/request_data_filtering.rb
54
54
  - lib/macaw_framework/data_filters/response_data_filter.rb
55
55
  - lib/macaw_framework/errors/endpoint_not_mapped_error.rb
56
- - lib/macaw_framework/errors/too_many_requests_error.rb
57
56
  - lib/macaw_framework/macaw.rb
58
57
  - lib/macaw_framework/middlewares/memory_invalidation_middleware.rb
59
58
  - lib/macaw_framework/middlewares/prometheus_middleware.rb
60
- - lib/macaw_framework/middlewares/rate_limiter_middleware.rb
61
59
  - lib/macaw_framework/utils/http_status_code.rb
62
60
  - lib/macaw_framework/utils/supported_ssl_versions.rb
63
61
  - lib/macaw_framework/version.rb
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class TooManyRequestsError < StandardError
4
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ##
4
- # Middleware responsible for implementing
5
- # rate limiting
6
- class RateLimiterMiddleware
7
- attr_reader :window_size, :max_requests
8
-
9
- def initialize(window_size, max_requests)
10
- @window_size = window_size
11
- @max_requests = max_requests
12
- @client_timestamps = Hash.new { |key, value| key[value] = [] }
13
- @mutex = Mutex.new
14
- end
15
-
16
- def allow?(client_id)
17
- @mutex.synchronize do
18
- now = Time.now.to_i
19
- timestamps = @client_timestamps[client_id]
20
-
21
- timestamps.reject! { |timestamp| timestamp <= now - window_size }
22
-
23
- if timestamps.length < max_requests
24
- timestamps << now
25
- true
26
- else
27
- false
28
- end
29
- end
30
- end
31
- end