blackstack_commons 1.1.11 → 1.1.12
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 +0 -18
- data/lib/functions.rb +31 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2eb4b3074c8b8ef8d89c50ee7cfe10699dd95484
|
4
|
+
data.tar.gz: 2ab5225d2373f540c2e94fe007423ccd6cf82433
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3536ae93830a5e7b960f4dcdf6179edfed77d7d32c6098369ffba1721341aafd57eed6ce7c66e3bf4ea5ac0211c021f79b63ec07654bd6659a9426ed0356f295
|
7
|
+
data.tar.gz: 0ec05a6ae12404d0f596ca5728aef5e84cb4f77159a1db6687c9151e7116fe66e2f74576d9a6609ad76746419fdc639ec7f8f700a44829b6fdb4586880b12328
|
data/lib/blackstack_commons.rb
CHANGED
@@ -23,21 +23,3 @@ 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
@@ -447,19 +447,28 @@ module BlackStack
|
|
447
447
|
DEFAULT_SSL_VERIFY_MODE = OpenSSL::SSL::VERIFY_NONE
|
448
448
|
SUCCESS = 'success'
|
449
449
|
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
450
|
+
@@lockfiles = []
|
451
|
+
|
452
|
+
@@max_api_call_channels = 10
|
453
|
+
|
454
|
+
def self.max_api_call_channels()
|
455
|
+
@@max_api_call_channels
|
456
|
+
end
|
457
|
+
|
458
|
+
def self.lockfiles()
|
459
|
+
@@lockfiles
|
460
|
+
end
|
461
|
+
|
462
|
+
def self.set(h)
|
463
|
+
@@max_api_call_channels = h[:max_api_call_channels]
|
464
|
+
@@lockfiles = []
|
465
|
+
|
466
|
+
i = 0
|
467
|
+
while i<@@max_api_call_channels
|
468
|
+
@@lockfiles << File.open("./apicall.channel_#{i.to_s}.lock", "w")
|
469
|
+
i+=1
|
470
|
+
end
|
471
|
+
end
|
463
472
|
|
464
473
|
|
465
474
|
class ApiCallException < StandardError
|
@@ -499,11 +508,13 @@ module BlackStack
|
|
499
508
|
# TODO: setup max_simultaneus_calls in the configurtion file.
|
500
509
|
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE)
|
501
510
|
# build the lockfile name
|
502
|
-
raise "Max Channels cannot be higher than #{BlackStack::Netting
|
503
|
-
|
504
|
-
|
511
|
+
raise "Max Channels cannot be higher than #{BlackStack::Netting.lockfiles.size.to_s}" if BlackStack::Netting.max_api_call_channels > BlackStack::Netting.BlackStack::Netting.lockfiles.size
|
512
|
+
#puts ''
|
513
|
+
#puts "BlackStack::Netting.max_api_call_channels:#{BlackStack::Netting.max_api_call_channels.to_s}."
|
514
|
+
x = rand(BlackStack::Netting.max_api_call_channels)
|
515
|
+
#puts "x:#{x.to_s}."
|
505
516
|
# lock the file
|
506
|
-
|
517
|
+
BlackStack::Netting.lockfiles[x].flock(File::LOCK_EX)
|
507
518
|
|
508
519
|
begin
|
509
520
|
|
@@ -524,16 +535,16 @@ module BlackStack
|
|
524
535
|
end
|
525
536
|
|
526
537
|
# release the file
|
527
|
-
|
538
|
+
BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN)
|
528
539
|
rescue => e
|
529
540
|
# release the file
|
530
|
-
|
541
|
+
BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN)
|
531
542
|
|
532
543
|
# elevo la excepcion
|
533
544
|
raise e
|
534
545
|
ensure
|
535
546
|
# release the file
|
536
|
-
|
547
|
+
BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN)
|
537
548
|
end
|
538
549
|
|
539
550
|
# return
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blackstack_commons
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leandro Daniel Sardi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: content_spinning
|