peak_flow_utils 0.1.17 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/app/controllers/peak_flow_utils/application_controller.rb +1 -1
- data/app/controllers/peak_flow_utils/pings/sidekiq_controller.rb +1 -2
- data/app/services/peak_flow_utils/parse_json.rb +39 -0
- data/lib/peak_flow_utils/notifier.rb +1 -1
- data/lib/peak_flow_utils/version.rb +1 -1
- data/lib/peak_flow_utils.rb +1 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbb8a48ea294481df8df3c87b5b17eca7c7b2715027a512655f66a318acb8e2e
|
4
|
+
data.tar.gz: 1970d5b4843db5df6396e12d6cacfa70049af0ac8946f4e7243d3a7f70b5d981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1866c116955f38e9f2dc3c2e06fbeca908ed4c0bb425348a82fa8f1522fcfb1e47d1c96fe1a32328bd44f439f26dfddb97285dd0c19b0725f5241dcdb671d51
|
7
|
+
data.tar.gz: ac9fa1d930c30b5d32d450b10bd2af6ec95ead713b64e686ab07de7cbec5db94e5b4048e0a16e13657d06f1d483a5d4252d1c3d4068e188cfcd4586cc55a1349
|
data/README.md
CHANGED
@@ -58,6 +58,26 @@ If you want the job name and its arguments logged in parameters you can execute
|
|
58
58
|
PeakFlowUtils::SidekiqParametersLogging.execute!
|
59
59
|
```
|
60
60
|
|
61
|
+
### Sidekiq and Postgres pings
|
62
|
+
|
63
|
+
Add this to `routes.rb`:
|
64
|
+
```ruby
|
65
|
+
Rails.application.routes.draw do
|
66
|
+
mount PeakFlowUtils::Engine => "/peakflow_utils"
|
67
|
+
```
|
68
|
+
|
69
|
+
Add these to .env variables:
|
70
|
+
```
|
71
|
+
PEAKFLOW_PINGS_USERNAME=username
|
72
|
+
PEAKFLOW_PINGS_PASSWORD=secret-password
|
73
|
+
```
|
74
|
+
|
75
|
+
You can now add a HTTP ping on this path:
|
76
|
+
`/peakflow_utils/pings/sidekiq`
|
77
|
+
|
78
|
+
And this for Postgres:
|
79
|
+
`/pings/postgres_connections`
|
80
|
+
|
61
81
|
## Contributing
|
62
82
|
Contribution directions go here.
|
63
83
|
|
@@ -9,7 +9,7 @@ private
|
|
9
9
|
authenticate_or_request_with_http_basic do |username, password|
|
10
10
|
if ENV["PEAKFLOW_PINGS_USERNAME"].blank? || ENV["PEAKFLOW_PINGS_PASSWORD"].blank?
|
11
11
|
Rails.logger.error "Peakflow utils: Pings called but PEAKFLOW_PINGS_USERNAME or PEAKFLOW_PINGS_PASSWORD wasn't set"
|
12
|
-
false
|
12
|
+
return false
|
13
13
|
end
|
14
14
|
|
15
15
|
username == ENV.fetch("PEAKFLOW_PINGS_USERNAME") && password == ENV.fetch("PEAKFLOW_PINGS_PASSWORD")
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class PeakFlowUtils::ParseJson
|
2
|
+
def initialize(object)
|
3
|
+
@object = object
|
4
|
+
end
|
5
|
+
|
6
|
+
def parse
|
7
|
+
parse_to_json(@object)
|
8
|
+
end
|
9
|
+
|
10
|
+
def active_record?(object)
|
11
|
+
object.class.ancestors.any? do |ancestor|
|
12
|
+
ancestor.name == "ActiveRecord::Base"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse_to_json(object)
|
17
|
+
if object.is_a?(Hash)
|
18
|
+
result = {}
|
19
|
+
|
20
|
+
object.each do |key, value|
|
21
|
+
result[key] = parse_to_json(value)
|
22
|
+
end
|
23
|
+
|
24
|
+
return result
|
25
|
+
elsif object.is_a?(Array)
|
26
|
+
return object.map do |value|
|
27
|
+
parse_to_json(value)
|
28
|
+
end
|
29
|
+
elsif active_record?(object)
|
30
|
+
result = "#<#{object.class.name} id: #{object.id}"
|
31
|
+
result << " name: \"#{object.name}\"" if object.respond_to?(:name)
|
32
|
+
result << ">"
|
33
|
+
|
34
|
+
return result
|
35
|
+
end
|
36
|
+
|
37
|
+
object
|
38
|
+
end
|
39
|
+
end
|
data/lib/peak_flow_utils.rb
CHANGED
@@ -16,6 +16,7 @@ module PeakFlowUtils
|
|
16
16
|
autoload :NotifierResponse, "#{path}/notifier_response"
|
17
17
|
autoload :NotifierSidekiq, "#{path}/notifier_sidekiq"
|
18
18
|
autoload :HandlerHelper, "#{path}/handler_helper"
|
19
|
+
autoload :ParseJson, "#{path}/parse_json"
|
19
20
|
|
20
21
|
autoload :ApplicationRecord, "#{models_path}/application_record"
|
21
22
|
autoload :Group, "#{models_path}/group"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: peak_flow_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.19
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kaspernj
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -138,7 +138,7 @@ dependencies:
|
|
138
138
|
version: '0'
|
139
139
|
description: Utilities to be used with PeakFlow.
|
140
140
|
email:
|
141
|
-
-
|
141
|
+
- k@spernj.org
|
142
142
|
executables: []
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- app/services/peak_flow_utils/group_service.rb
|
171
171
|
- app/services/peak_flow_utils/handlers_finder_service.rb
|
172
172
|
- app/services/peak_flow_utils/model_inspector.rb
|
173
|
+
- app/services/peak_flow_utils/parse_json.rb
|
173
174
|
- app/services/peak_flow_utils/sidekiq_parameters_logging.rb
|
174
175
|
- app/services/peak_flow_utils/translation_service.rb
|
175
176
|
- app/services/peak_flow_utils/translations_parser_service.rb
|
@@ -219,7 +220,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
219
220
|
- !ruby/object:Gem::Version
|
220
221
|
version: '0'
|
221
222
|
requirements: []
|
222
|
-
rubygems_version: 3.
|
223
|
+
rubygems_version: 3.5.3
|
223
224
|
signing_key:
|
224
225
|
specification_version: 4
|
225
226
|
summary: Utilities to be used with PeakFlow.
|