blackstack_commons 1.1.10 → 1.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blackstack_commons.rb +18 -0
- data/lib/functions.rb +3 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 138ed01e758c54c9c961aea4fc2eda4883a1c735
|
4
|
+
data.tar.gz: 3923a2a75d8a5bb19c4de591b92a919941cb66b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 927363454d10c1d0333976222e60bfed35febe3f3dfeaaf9fa676f58e20388f17349743e3eb3660b07879f1831b5b4ddf9875fd22736ca669a8bcb8dd586ffbe
|
7
|
+
data.tar.gz: dfb5bfa4a89f35fa6ff2a4bc3a9159058188013fc7dcfc1b266a660bf1d1e83e65923cb9fae9587db30ebfa747dc39078f42f0dd9671e55ab7e531f8dd0f9053
|
data/lib/blackstack_commons.rb
CHANGED
@@ -23,3 +23,21 @@ require_relative './extend_datetime'
|
|
23
23
|
require_relative './extend_fixnum'
|
24
24
|
require_relative './extend_float'
|
25
25
|
require_relative './extend_exception'
|
26
|
+
|
27
|
+
module BlackStack
|
28
|
+
|
29
|
+
module Commons
|
30
|
+
|
31
|
+
@@max_api_call_channels = 10
|
32
|
+
|
33
|
+
def self.max_api_call_channels()
|
34
|
+
@@max_api_call_channels
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.set(h)
|
38
|
+
@@max_api_call_channels = h[:max_api_call_channels]
|
39
|
+
end
|
40
|
+
|
41
|
+
end # module Commons
|
42
|
+
|
43
|
+
end # module BlackStack
|
data/lib/functions.rb
CHANGED
@@ -497,10 +497,10 @@ module BlackStack
|
|
497
497
|
# ssl_verify_mode: you can disabele SSL verification here.
|
498
498
|
# max_channels: this method use lockfiles to prevent an excesive number of API calls from each datacenter. There is not allowed more simultaneous calls than max_channels.
|
499
499
|
# TODO: setup max_simultaneus_calls in the configurtion file.
|
500
|
-
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE
|
500
|
+
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE)
|
501
501
|
# build the lockfile name
|
502
|
-
raise "Max Channels cannot be higher than #{BlackStack::Netting::MAX_CHANNELS.to_s}" if
|
503
|
-
x = rand(
|
502
|
+
raise "Max Channels cannot be higher than #{BlackStack::Netting::MAX_CHANNELS.to_s}" if BlackStack::Commons.max_api_call_channels > BlackStack::Netting::MAX_CHANNELS.to_i
|
503
|
+
x = rand(BlackStack::Commons.max_api_call_channels)
|
504
504
|
|
505
505
|
# lock the file
|
506
506
|
LOCKFILES[x].flock(File::LOCK_EX)
|