blackstack_commons 1.1.11 → 1.1.12

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 138ed01e758c54c9c961aea4fc2eda4883a1c735
4
- data.tar.gz: 3923a2a75d8a5bb19c4de591b92a919941cb66b0
3
+ metadata.gz: 2eb4b3074c8b8ef8d89c50ee7cfe10699dd95484
4
+ data.tar.gz: 2ab5225d2373f540c2e94fe007423ccd6cf82433
5
5
  SHA512:
6
- metadata.gz: 927363454d10c1d0333976222e60bfed35febe3f3dfeaaf9fa676f58e20388f17349743e3eb3660b07879f1831b5b4ddf9875fd22736ca669a8bcb8dd586ffbe
7
- data.tar.gz: dfb5bfa4a89f35fa6ff2a4bc3a9159058188013fc7dcfc1b266a660bf1d1e83e65923cb9fae9587db30ebfa747dc39078f42f0dd9671e55ab7e531f8dd0f9053
6
+ metadata.gz: 3536ae93830a5e7b960f4dcdf6179edfed77d7d32c6098369ffba1721341aafd57eed6ce7c66e3bf4ea5ac0211c021f79b63ec07654bd6659a9426ed0356f295
7
+ data.tar.gz: 0ec05a6ae12404d0f596ca5728aef5e84cb4f77159a1db6687c9151e7116fe66e2f74576d9a6609ad76746419fdc639ec7f8f700a44829b6fdb4586880b12328
@@ -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
- 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
- ]
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::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
-
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
- LOCKFILES[x].flock(File::LOCK_EX)
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
- LOCKFILES[x].flock(File::LOCK_UN)
538
+ BlackStack::Netting.lockfiles[x].flock(File::LOCK_UN)
528
539
  rescue => e
529
540
  # release the file
530
- LOCKFILES[x].flock(File::LOCK_UN)
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
- LOCKFILES[x].flock(File::LOCK_UN)
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.11
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-05 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: content_spinning