blackstack_commons 1.1.9 → 1.1.10
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/functions.rb +21 -7
- 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: 2e9df93155dc46a4db2e702f2ede6af77151f1bd
|
4
|
+
data.tar.gz: 12ad3c508f8343d9983e11b20d0ca4bc365f684d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3724c7beea130aa65abb01f911840b6b3a51f4cde56591279a927aa6ab26e65f9f9196706384fa3affb32ed54c1116f586be2192ee8980212ac53bfecf02abea
|
7
|
+
data.tar.gz: 15a760c7e6efc160bf83704198cc9bc62674110d5782a0eacef78d5483cdfc46973b651edbe8755c6ca9be722b582b41575bc4d23f3508223b4bf766d11295b3
|
data/lib/functions.rb
CHANGED
@@ -447,6 +447,21 @@ module BlackStack
|
|
447
447
|
DEFAULT_SSL_VERIFY_MODE = OpenSSL::SSL::VERIFY_NONE
|
448
448
|
SUCCESS = 'success'
|
449
449
|
|
450
|
+
MAX_CHANNELS=10
|
451
|
+
LOCKFILES = [
|
452
|
+
File.open("./apicall.channel_0.lock", "w"),
|
453
|
+
File.open("./apicall.channel_1.lock", "w"),
|
454
|
+
File.open("./apicall.channel_2.lock", "w"),
|
455
|
+
File.open("./apicall.channel_3.lock", "w"),
|
456
|
+
File.open("./apicall.channel_4.lock", "w"),
|
457
|
+
File.open("./apicall.channel_5.lock", "w"),
|
458
|
+
File.open("./apicall.channel_6.lock", "w"),
|
459
|
+
File.open("./apicall.channel_7.lock", "w"),
|
460
|
+
File.open("./apicall.channel_8.lock", "w"),
|
461
|
+
File.open("./apicall.channel_9.lock", "w"),
|
462
|
+
]
|
463
|
+
|
464
|
+
|
450
465
|
class ApiCallException < StandardError
|
451
466
|
attr_accessor :description
|
452
467
|
|
@@ -484,12 +499,11 @@ module BlackStack
|
|
484
499
|
# TODO: setup max_simultaneus_calls in the configurtion file.
|
485
500
|
def self.call_post(url, params = {}, ssl_verify_mode=BlackStack::Netting::DEFAULT_SSL_VERIFY_MODE, max_channels=10)
|
486
501
|
# build the lockfile name
|
487
|
-
|
488
|
-
|
489
|
-
lockfile = File.open(lockfilename, "w")
|
502
|
+
raise "Max Channels cannot be higher than #{BlackStack::Netting::MAX_CHANNELS.to_s}" if max_channels > BlackStack::Netting::MAX_CHANNELS.to_i
|
503
|
+
x = rand(max_channels)
|
490
504
|
|
491
505
|
# lock the file
|
492
|
-
|
506
|
+
LOCKFILES[x].flock(File::LOCK_EX)
|
493
507
|
|
494
508
|
begin
|
495
509
|
|
@@ -510,16 +524,16 @@ module BlackStack
|
|
510
524
|
end
|
511
525
|
|
512
526
|
# release the file
|
513
|
-
|
527
|
+
LOCKFILES[x].flock(File::LOCK_UN)
|
514
528
|
rescue => e
|
515
529
|
# release the file
|
516
|
-
|
530
|
+
LOCKFILES[x].flock(File::LOCK_UN)
|
517
531
|
|
518
532
|
# elevo la excepcion
|
519
533
|
raise e
|
520
534
|
ensure
|
521
535
|
# release the file
|
522
|
-
|
536
|
+
LOCKFILES[x].flock(File::LOCK_UN)
|
523
537
|
end
|
524
538
|
|
525
539
|
# 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.10
|
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-
|
11
|
+
date: 2020-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: content_spinning
|