upfluence-utils 0.13.0 → 0.14.0
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 +4 -4
- data/.github/workflows/ci.yml +29 -0
- data/Makefile +4 -0
- data/Rakefile +23 -0
- data/lib/upfluence/http/middleware/active_record.rb +17 -0
- data/lib/upfluence/http/server.rb +30 -27
- data/lib/upfluence/utils/version.rb +1 -1
- data/upfluence_utils.gemspec +3 -1
- metadata +38 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e1429c611b80c503096df4c7e19d60866a40aa3042cd1a73d8ec39d76b3a164
|
|
4
|
+
data.tar.gz: fcb360825de59c3f0251400597977dacf27ae7c36f76533e750e83cbfd3ae6bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 45cbf134ed8f525e6b9ca2ac6e5dac7b063d0a69337e83bcff3f424bdcbf08f296aa3006d93f21dd0f4f5a88ada3e586aa01fa568daef4322fa122ff2b9df8c7
|
|
7
|
+
data.tar.gz: 6e681f3f08cdd2437c9968305702c325018d7760dcb590f2552247a99150dd56fcb74de5b5aabc74626c904af9a165d0b8567cdf0f711ab0c6c055457626856d
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: ci
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
pull_request:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
uses: upfluence/actions/.github/workflows/lib-ruby-test.yml@master
|
|
12
|
+
secrets: inherit
|
|
13
|
+
|
|
14
|
+
release:
|
|
15
|
+
needs: test
|
|
16
|
+
if: github.ref == 'refs/heads/master'
|
|
17
|
+
runs-on: ubuntu-24.04
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v6
|
|
21
|
+
with:
|
|
22
|
+
fetch-depth: 0
|
|
23
|
+
- name: Bump version
|
|
24
|
+
id: bump-version
|
|
25
|
+
uses: upfluence/actions/bump-version@master
|
|
26
|
+
- name: Create release
|
|
27
|
+
uses: upfluence/actions/create-github-release@master
|
|
28
|
+
with:
|
|
29
|
+
version: ${{ steps.bump-version.outputs.version }}
|
data/Makefile
ADDED
data/Rakefile
CHANGED
|
@@ -1,6 +1,29 @@
|
|
|
1
1
|
require "bundler/gem_tasks"
|
|
2
2
|
require "rspec/core/rake_task"
|
|
3
3
|
|
|
4
|
+
version_file = "lib/upfluence/utils/version.rb"
|
|
5
|
+
|
|
6
|
+
task :update_version do
|
|
7
|
+
version = (ENV['VERSION'] || `git describe --tag 2>/dev/null` || '').chomp.sub(/\Av/, '').then { |v| v.empty? ? '0.0.0' : v }
|
|
8
|
+
original_version = File.binread(version_file)
|
|
9
|
+
|
|
10
|
+
Bundler::GemHelper.gemspec.version = version
|
|
11
|
+
at_exit { File.binwrite(version_file, original_version) }
|
|
12
|
+
|
|
13
|
+
File.write(
|
|
14
|
+
version_file,
|
|
15
|
+
<<~RUBY
|
|
16
|
+
module Upfluence
|
|
17
|
+
module Utils
|
|
18
|
+
VERSION = '#{version}'.freeze
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
RUBY
|
|
22
|
+
)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Rake::Task[:build].enhance([:update_version])
|
|
26
|
+
|
|
4
27
|
RSpec::Core::RakeTask.new(:spec)
|
|
5
28
|
|
|
6
29
|
task :default => :spec
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module Upfluence
|
|
2
|
+
module HTTP
|
|
3
|
+
module Middleware
|
|
4
|
+
class ActiveRecord
|
|
5
|
+
def initialize(app)
|
|
6
|
+
@app = app
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def call(env)
|
|
10
|
+
::ActiveRecord::Base.connection_pool.with_connection do
|
|
11
|
+
@app.call(env)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -28,37 +28,36 @@ module Upfluence
|
|
|
28
28
|
REQUEST_CONTEXT_KEY = :uhttp_request_context
|
|
29
29
|
DEFAULT_MIDDLEWARES = []
|
|
30
30
|
DEFAULT_OPTIONS = {
|
|
31
|
-
server:
|
|
32
|
-
Port:
|
|
33
|
-
Host:
|
|
34
|
-
threaded:
|
|
35
|
-
interfaces:
|
|
36
|
-
push_gateway_url:
|
|
37
|
-
push_gateway_interval:
|
|
38
|
-
prometheus_endpoint:
|
|
39
|
-
app_name:
|
|
40
|
-
unit_name:
|
|
41
|
-
base_processor_klass:
|
|
42
|
-
base_handler_klass:
|
|
43
|
-
max_threads:
|
|
44
|
-
request_timeout:
|
|
45
|
-
|
|
46
|
-
|
|
31
|
+
server: :puma,
|
|
32
|
+
Port: ENV.fetch('PORT', 8080),
|
|
33
|
+
Host: '0.0.0.0',
|
|
34
|
+
threaded: true,
|
|
35
|
+
interfaces: [],
|
|
36
|
+
push_gateway_url: ENV.fetch('PUSH_GATEWAY_URL', nil),
|
|
37
|
+
push_gateway_interval: 15, # sec
|
|
38
|
+
prometheus_endpoint: ENV.fetch('PUSH_GATEWAY_URL', nil).eql?(nil),
|
|
39
|
+
app_name: ENV.fetch('APP_NAME', 'uhttp-rb-server'),
|
|
40
|
+
unit_name: ENV.fetch('UNIT_NAME', 'uhttp-rb-server-anonymous'),
|
|
41
|
+
base_processor_klass: nil,
|
|
42
|
+
base_handler_klass: nil,
|
|
43
|
+
max_threads: ENV.fetch('HTTP_SERVER_MAX_THREADS', 5).to_i,
|
|
44
|
+
request_timeout: ENV['HTTP_SERVER_REQUEST_TIMEOUT']&.to_i,
|
|
45
|
+
enable_active_record_middleware: true,
|
|
46
|
+
middlewares: [],
|
|
47
|
+
instrumentations: [
|
|
47
48
|
Instrumentation::PumaInstrumenter.new,
|
|
48
49
|
Instrumentation::GCInstrumenter.new,
|
|
49
50
|
Instrumentation::ActiveRecordPoolInstrumenter.new
|
|
50
51
|
],
|
|
51
|
-
admin_port:
|
|
52
|
-
debug:
|
|
53
|
-
}
|
|
52
|
+
admin_port: ENV.fetch('ADMIN_PORT', nil),
|
|
53
|
+
debug: ENV.fetch('DEBUG', nil)
|
|
54
|
+
}.freeze
|
|
54
55
|
|
|
55
56
|
def initialize(options = {}, &block)
|
|
56
57
|
@options = DEFAULT_OPTIONS.dup.merge(options)
|
|
57
58
|
opts = @options
|
|
58
59
|
|
|
59
|
-
if opts[:base_handler_klass]
|
|
60
|
-
@base_handler = opts[:base_handler_klass].new(opts[:interfaces])
|
|
61
|
-
end
|
|
60
|
+
@base_handler = opts[:base_handler_klass].new(opts[:interfaces]) if opts[:base_handler_klass]
|
|
62
61
|
|
|
63
62
|
@admin_builder = admin_builder(opts) if opts[:admin_port]
|
|
64
63
|
@production_builder = production_builder(opts, &block)
|
|
@@ -107,9 +106,7 @@ module Upfluence
|
|
|
107
106
|
|
|
108
107
|
# Thin does not recognize the max_thread argument, howerver it has a
|
|
109
108
|
# threadpool_size setter. Puma on the other hand recognize max_thread.
|
|
110
|
-
if server.respond_to?(:threadpool_size=) && opts[:max_threads]
|
|
111
|
-
server.threadpool_size = opts[:max_threads]
|
|
112
|
-
end
|
|
109
|
+
server.threadpool_size = opts[:max_threads] if server.respond_to?(:threadpool_size=) && opts[:max_threads]
|
|
113
110
|
end
|
|
114
111
|
end
|
|
115
112
|
|
|
@@ -125,10 +122,16 @@ module Upfluence
|
|
|
125
122
|
use Middleware::ApplicationHeaders, base_handler
|
|
126
123
|
use Middleware::HandleException
|
|
127
124
|
|
|
128
|
-
if opts[:
|
|
129
|
-
|
|
125
|
+
if opts[:enable_active_record_middleware] &&
|
|
126
|
+
defined?(ActiveRecord::Base) &&
|
|
127
|
+
ActiveRecord::Base.configurations.any?
|
|
128
|
+
require 'upfluence/http/middleware/active_record'
|
|
129
|
+
|
|
130
|
+
use Middleware::ActiveRecord
|
|
130
131
|
end
|
|
131
132
|
|
|
133
|
+
use Rack::Timeout, service_timeout: opts[:request_timeout] if opts[:request_timeout]
|
|
134
|
+
|
|
132
135
|
use Upfluence.error_logger.middleware
|
|
133
136
|
|
|
134
137
|
use Rack::ContentLength
|
data/upfluence_utils.gemspec
CHANGED
|
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.add_runtime_dependency 'sinatra-contrib'
|
|
28
28
|
spec.add_runtime_dependency 'activesupport'
|
|
29
29
|
spec.add_runtime_dependency 'puma'
|
|
30
|
-
spec.add_runtime_dependency 'rack'
|
|
30
|
+
spec.add_runtime_dependency 'rack', '< 3.0'
|
|
31
31
|
spec.add_runtime_dependency 'stackprof'
|
|
32
32
|
spec.add_runtime_dependency 'prometheus-client', '~> 2.1'
|
|
33
33
|
spec.add_runtime_dependency 'userializer'
|
|
@@ -35,4 +35,6 @@ Gem::Specification.new do |spec|
|
|
|
35
35
|
spec.add_runtime_dependency 'loofah'
|
|
36
36
|
spec.add_runtime_dependency 'rack-timeout'
|
|
37
37
|
spec.add_runtime_dependency 'mutex_m'
|
|
38
|
+
spec.add_runtime_dependency 'base64'
|
|
39
|
+
spec.add_runtime_dependency 'bigdecimal'
|
|
38
40
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: upfluence-utils
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.14.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Upfluence
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
10
|
+
date: 2026-08-19 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: bundler
|
|
@@ -154,16 +153,16 @@ dependencies:
|
|
|
154
153
|
name: rack
|
|
155
154
|
requirement: !ruby/object:Gem::Requirement
|
|
156
155
|
requirements:
|
|
157
|
-
- - "
|
|
156
|
+
- - "<"
|
|
158
157
|
- !ruby/object:Gem::Version
|
|
159
|
-
version: '0'
|
|
158
|
+
version: '3.0'
|
|
160
159
|
type: :runtime
|
|
161
160
|
prerelease: false
|
|
162
161
|
version_requirements: !ruby/object:Gem::Requirement
|
|
163
162
|
requirements:
|
|
164
|
-
- - "
|
|
163
|
+
- - "<"
|
|
165
164
|
- !ruby/object:Gem::Version
|
|
166
|
-
version: '0'
|
|
165
|
+
version: '3.0'
|
|
167
166
|
- !ruby/object:Gem::Dependency
|
|
168
167
|
name: stackprof
|
|
169
168
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -262,7 +261,34 @@ dependencies:
|
|
|
262
261
|
- - ">="
|
|
263
262
|
- !ruby/object:Gem::Version
|
|
264
263
|
version: '0'
|
|
265
|
-
|
|
264
|
+
- !ruby/object:Gem::Dependency
|
|
265
|
+
name: base64
|
|
266
|
+
requirement: !ruby/object:Gem::Requirement
|
|
267
|
+
requirements:
|
|
268
|
+
- - ">="
|
|
269
|
+
- !ruby/object:Gem::Version
|
|
270
|
+
version: '0'
|
|
271
|
+
type: :runtime
|
|
272
|
+
prerelease: false
|
|
273
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
274
|
+
requirements:
|
|
275
|
+
- - ">="
|
|
276
|
+
- !ruby/object:Gem::Version
|
|
277
|
+
version: '0'
|
|
278
|
+
- !ruby/object:Gem::Dependency
|
|
279
|
+
name: bigdecimal
|
|
280
|
+
requirement: !ruby/object:Gem::Requirement
|
|
281
|
+
requirements:
|
|
282
|
+
- - ">="
|
|
283
|
+
- !ruby/object:Gem::Version
|
|
284
|
+
version: '0'
|
|
285
|
+
type: :runtime
|
|
286
|
+
prerelease: false
|
|
287
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
288
|
+
requirements:
|
|
289
|
+
- - ">="
|
|
290
|
+
- !ruby/object:Gem::Version
|
|
291
|
+
version: '0'
|
|
266
292
|
email:
|
|
267
293
|
- dev@upfluence.com
|
|
268
294
|
executables: []
|
|
@@ -270,11 +296,13 @@ extensions: []
|
|
|
270
296
|
extra_rdoc_files: []
|
|
271
297
|
files:
|
|
272
298
|
- ".github/pull_request_template.md"
|
|
299
|
+
- ".github/workflows/ci.yml"
|
|
273
300
|
- ".gitignore"
|
|
274
301
|
- ".rspec"
|
|
275
302
|
- ".travis.yml"
|
|
276
303
|
- Gemfile
|
|
277
304
|
- LICENSE.txt
|
|
305
|
+
- Makefile
|
|
278
306
|
- README.md
|
|
279
307
|
- Rakefile
|
|
280
308
|
- lib/test.rb
|
|
@@ -291,6 +319,7 @@ files:
|
|
|
291
319
|
- lib/upfluence/http/endpoint/healthcheck.rb
|
|
292
320
|
- lib/upfluence/http/endpoint/profiler.rb
|
|
293
321
|
- lib/upfluence/http/endpoint/validation_error.rb
|
|
322
|
+
- lib/upfluence/http/middleware/active_record.rb
|
|
294
323
|
- lib/upfluence/http/middleware/application_headers.rb
|
|
295
324
|
- lib/upfluence/http/middleware/cors.rb
|
|
296
325
|
- lib/upfluence/http/middleware/handle_exception.rb
|
|
@@ -331,7 +360,6 @@ homepage: https://github.com/upfluence/upfluence_utils
|
|
|
331
360
|
licenses:
|
|
332
361
|
- MIT
|
|
333
362
|
metadata: {}
|
|
334
|
-
post_install_message:
|
|
335
363
|
rdoc_options: []
|
|
336
364
|
require_paths:
|
|
337
365
|
- lib
|
|
@@ -346,8 +374,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
346
374
|
- !ruby/object:Gem::Version
|
|
347
375
|
version: '0'
|
|
348
376
|
requirements: []
|
|
349
|
-
rubygems_version: 3.
|
|
350
|
-
signing_key:
|
|
377
|
+
rubygems_version: 3.6.2
|
|
351
378
|
specification_version: 4
|
|
352
379
|
summary: Upfluence common utils for Ruby projects
|
|
353
380
|
test_files: []
|