blackstack_commons 1.1.9 → 1.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/functions.rb +21 -7
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32905a6b6f94e5ca2db7f19b129a799ea0a574fb
4
- data.tar.gz: b769f3f76aa7366728631575a663247e365613a9
3
+ metadata.gz: 2e9df93155dc46a4db2e702f2ede6af77151f1bd
4
+ data.tar.gz: 12ad3c508f8343d9983e11b20d0ca4bc365f684d
5
5
  SHA512:
6
- metadata.gz: 02e0ccd33684a7ae96d88d206f9635471635782cd01244a668fec2fae6bc238e0013d968de8812c4414ddeda4af1d5bd64737ad747d8cf732715279148978b5d
7
- data.tar.gz: 03dbc44154bd7429f1872493304fd222966ff464eac1b7d0ec45a6aa94707132bf27b6e353d1d9cacd0ed899e714c1a82a71660c26a4e82b35e28addc40af506
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
- x = rand(max_channels.to_i)
488
- lockfilename = "./apicall.channel_#{x.to_s}.lock"
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
- lockfile.flock(File::LOCK_EX)
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
- lockfile.flock(File::LOCK_UN)
527
+ LOCKFILES[x].flock(File::LOCK_UN)
514
528
  rescue => e
515
529
  # release the file
516
- lockfile.flock(File::LOCK_UN)
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
- lockfile.flock(File::LOCK_UN)
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.9
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-03-24 00:00:00.000000000 Z
11
+ date: 2020-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning