macaw_framework 1.2.1 → 1.2.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: b0919e302e01808498550b142306c3c1049f3a295c8791cdf86aea193d80ca62
4
- data.tar.gz: 7bef47be0b370ba9d70261af9e43c74394405fb104e961e18feed48a9ac2cdc9
3
+ metadata.gz: 75201cbb67c0e3d1f913751ed085cf3102f42794a3d5f3721b4acd00234ac257
4
+ data.tar.gz: 1b15fe1043c6213fe8a7f5be7ea22f2ed1bd6c917215de79edf66b622e6c2e85
5
5
  SHA512:
6
- metadata.gz: 8b2b8b21bb72242f92d984cc274fc76aea1854c62a32c8bbf6200b8d597ea30004cf21dcc7bb9a92b739ea1e22691c987feb9e60df5e2432e23271cd3ab0ef13
7
- data.tar.gz: 1b61ebd99268cd0b288bb1cb2bd6c1cc223ed3387d4437ec4fec8d1026d6f6eca033e9279d0324b0c563fa6b02854e9e87cc0b5d5706eb174ca87947ad84b73a
6
+ metadata.gz: 0f6feb4910080a14c3908a8f5d89d5768fbf40e40882f8d98e6ecfdcf99475ec86e0522bd09f0db9b73577e2e1b72912f1db9da169271ac5b403bc680e09a0a4
7
+ data.tar.gz: 2417693c644f10af4c4a23186dde6451405c1a34c595ec507292f5eba1f7451193a4e728b9cd28195bc1010ab22f8f4a7368240e016e3f871515cb3ec22ea242
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,7 @@
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
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.2"
5
5
  end
@@ -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, :port, :bind, :threads, :macaw_log, :config, :jobs
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
- @server = server.new(self, @endpoints_to_cache, @cache, @prometheus, @prometheus_middleware)
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: 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.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-06 00:00:00.000000000 Z
11
+ date: 2023-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prometheus-client