macaw_framework 1.2.1 → 1.2.3

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: b0919e302e01808498550b142306c3c1049f3a295c8791cdf86aea193d80ca62
4
- data.tar.gz: 7bef47be0b370ba9d70261af9e43c74394405fb104e961e18feed48a9ac2cdc9
3
+ metadata.gz: 6b8d8af2c8dfcaf1b23ec98aa59552d18ba7922db8829ceb6d3969a13b780c16
4
+ data.tar.gz: d55ae5ebfe0d6cbb5019bcfaeb7aedbaa808c15a0ad13c7b6e5f96a036496d3f
5
5
  SHA512:
6
- metadata.gz: 8b2b8b21bb72242f92d984cc274fc76aea1854c62a32c8bbf6200b8d597ea30004cf21dcc7bb9a92b739ea1e22691c987feb9e60df5e2432e23271cd3ab0ef13
7
- data.tar.gz: 1b61ebd99268cd0b288bb1cb2bd6c1cc223ed3387d4437ec4fec8d1026d6f6eca033e9279d0324b0c563fa6b02854e9e87cc0b5d5706eb174ca87947ad84b73a
6
+ metadata.gz: 0a53413f64b5a2c25bb026d961690b78490cf45b1e58e03f695d7bfad54b0e4d461b04351a3b8aaf23ab991bb5b7450fd481f8f25bced1a6b3f818b035934635
7
+ data.tar.gz: 3a503e0618a7af98b43f26b284fedcbf238bb128c7bd1cb8013c8b36485c9539a2a0a242e78af675e51b7df23ad16e4d00e5cbe368ee9faf448359930892605c
data/.rubocop.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.7
3
+ SuggestExtensions: false
4
+ NewCops: disable
3
5
 
4
6
  Style/StringLiterals:
5
7
  Enabled: true
data/CHANGELOG.md CHANGED
@@ -115,3 +115,11 @@
115
115
  ## [1.2.1] - 2023-11-06
116
116
 
117
117
  - Simplifying logging aspect for readability
118
+
119
+ ## [1.2.2]
120
+
121
+ - Including possibility of setting port, bind and threads programmatically
122
+
123
+ ## [1.2.3]
124
+
125
+ - Fixing import of pathname
data/README.md CHANGED
@@ -137,12 +137,6 @@ end
137
137
  "port": 8080,
138
138
  "bind": "localhost",
139
139
  "threads": 200,
140
- "log": {
141
- "max_length": 1024,
142
- "sensitive_fields": [
143
- "password"
144
- ]
145
- },
146
140
  "cache": {
147
141
  "cache_invalidation": 3600,
148
142
  "ignore_headers": [
@@ -230,11 +224,24 @@ MacawFramework::Macaw.new(custom_log: nil)
230
224
  - URL parameters like `...endOfUrl?key1=value1&key2=value2` can be found in the `context[:params]`
231
225
 
232
226
  ```ruby
227
+ m = MacawFramework::Macaw.new
228
+
233
229
  m.get('/test_params') do |context|
234
230
  context[:params]["key1"] # returns: value1
235
231
  end
236
232
  ```
237
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
+
238
245
  - The default number of virtual threads in the thread pool is 200.
239
246
 
240
247
  - Rate Limit window should also be specified in seconds. Rate limit will be activated only if the `rate_limiting` config
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MacawFramework
4
- VERSION = "1.2.1"
4
+ VERSION = "1.2.3"
5
5
  end
@@ -9,6 +9,7 @@ require_relative "macaw_framework/core/thread_server"
9
9
  require_relative "macaw_framework/version"
10
10
  require "prometheus/client"
11
11
  require "securerandom"
12
+ require "pathname"
12
13
  require "logger"
13
14
  require "socket"
14
15
  require "json"
@@ -20,7 +21,8 @@ module MacawFramework
20
21
  class Macaw
21
22
  ##
22
23
  # Array containing the routes defined in the application
23
- attr_reader :routes, :port, :bind, :threads, :macaw_log, :config, :jobs
24
+ attr_reader :routes, :macaw_log, :config, :jobs
25
+ attr_accessor :port, :bind, :threads
24
26
 
25
27
  ##
26
28
  # @param {Logger} custom_log
@@ -49,7 +51,7 @@ module MacawFramework
49
51
  @endpoints_to_cache = []
50
52
  @prometheus ||= nil
51
53
  @prometheus_middleware ||= nil
52
- @server = server.new(self, @endpoints_to_cache, @cache, @prometheus, @prometheus_middleware)
54
+ @server_class = server
53
55
  end
54
56
 
55
57
  ##
@@ -161,6 +163,7 @@ module MacawFramework
161
163
  @macaw_log.info("Number of threads: #{@threads}")
162
164
  @macaw_log.info("---------------------------------")
163
165
  end
166
+ @server = @server_class.new(self, @endpoints_to_cache, @cache, @prometheus, @prometheus_middleware)
164
167
  server_loop(@server)
165
168
  rescue Interrupt
166
169
  if @macaw_log.nil?
@@ -9,18 +9,17 @@ module MacawFramework
9
9
 
10
10
  @prometheus: untyped
11
11
  @prometheus_middleware: untyped
12
- @server: Server
12
+ @server: untyped
13
13
 
14
14
  @threads: Integer
15
15
 
16
- attr_reader bind: String
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
- attr_reader port: Integer
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.1
4
+ version: 1.2.3
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-06 00:00:00.000000000 Z
11
+ date: 2023-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prometheus-client