lusnoc 1.0.1.134629 → 1.0.2.417513
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/lib/lusnoc/configuration.rb +11 -1
- data/lib/lusnoc/version.rb +1 -1
- data/lib/lusnoc.rb +2 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 74de0bd4a421afdc2d99137d88f32ff846f577be0f279ab670bd82206c9ed15c
|
|
4
|
+
data.tar.gz: 1ed7ae2763fc6d09e297a54d248876221244e71c555a9cf61d8bff64aaebfea0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f2971db111ccc87498b571096567f7dbe5608c9ea944d418e065c3780ff54122e0a75d9a856b48ac2a81c901676d729804d7f4809e603698afab12849beba4cf
|
|
7
|
+
data.tar.gz: a8760b8dbd7c809f98b03f72bfcf205da57b8139df2c3a627cedc4c3433e6188ba650e9e2f43f75ed4adc1f4f4bf2206bbd13aa1d4c0f18d65d3485e2a3d96bf
|
data/lib/lusnoc/configuration.rb
CHANGED
|
@@ -6,10 +6,20 @@ module Lusnoc
|
|
|
6
6
|
|
|
7
7
|
attr_accessor :url, :acl_token, :logger, :http_timeout
|
|
8
8
|
|
|
9
|
+
# Get the most appropriate consul agent value from env
|
|
10
|
+
# Parse the environment variable `CONSUL_HTTP_ADDR` and prefixes it with http:// if needed
|
|
11
|
+
# Return default http://localhost:8500 if not found
|
|
12
|
+
def self.parse_consul_addr
|
|
13
|
+
ret = ENV['CONSUL_HTTP_ADDR'] || 'http://localhost:8500'
|
|
14
|
+
ret = "http://#{ret}" unless ret.start_with?('http://', 'https://')
|
|
15
|
+
ret
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
9
19
|
# Override defaults for configuration
|
|
10
20
|
# @param url [String] consul's connection URL
|
|
11
21
|
# @param acl_token [String] a connection token used when making requests to consul
|
|
12
|
-
def initialize(url =
|
|
22
|
+
def initialize(url = Configuration.parse_consul_addr, acl_token = ENV['CONSUL_HTTP_TOKEN'])
|
|
13
23
|
@url = url
|
|
14
24
|
@acl_token = acl_token
|
|
15
25
|
@logger = Logger.new(STDOUT, level: Logger::INFO, progname: 'Lusnoc')
|
data/lib/lusnoc/version.rb
CHANGED
data/lib/lusnoc.rb
CHANGED
|
@@ -26,10 +26,9 @@ module Lusnoc
|
|
|
26
26
|
|
|
27
27
|
def http_get(url, timeout: Lusnoc.configuration.http_timeout)
|
|
28
28
|
uri = URI(url)
|
|
29
|
-
|
|
30
29
|
with_http(uri, timeout: timeout) do |http|
|
|
31
30
|
req = Net::HTTP::Get.new(uri)
|
|
32
|
-
|
|
31
|
+
req["X-Consul-Token"] = Lusnoc.configuration.acl_token if Lusnoc.configuration.acl_token&.present?
|
|
33
32
|
# configure http and request before send
|
|
34
33
|
yield(http, req) if block_given?
|
|
35
34
|
http.request(req)
|
|
@@ -39,13 +38,12 @@ module Lusnoc
|
|
|
39
38
|
def http_put(url, value = nil, timeout: Lusnoc.configuration.http_timeout)
|
|
40
39
|
uri = URI(url)
|
|
41
40
|
data = value.is_a?(String) ? value : JSON.generate(value) unless value.nil?
|
|
42
|
-
|
|
43
41
|
with_http(uri, timeout: timeout) do |http|
|
|
44
42
|
req = Net::HTTP::Put.new(uri).tap do |r|
|
|
45
43
|
r.body = data
|
|
46
44
|
r['Content-Type'] = 'application/json'
|
|
47
45
|
end
|
|
48
|
-
|
|
46
|
+
req["X-Consul-Token"] = Lusnoc.configuration.acl_token if Lusnoc.configuration.acl_token&.present?
|
|
49
47
|
# configure http and request before send
|
|
50
48
|
yield(http, req) if block_given?
|
|
51
49
|
http.request(req)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lusnoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2.417513
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Samoilenko Yuri
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|