pampa 2.1.4 → 2.1.5
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/pampa.rb +81 -0
- data/pampa.gemspec +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4e863bdb28e3b9204917ef6d94111490ce37f024859474b3914f6ec1d5b48e63
|
|
4
|
+
data.tar.gz: ef3c4d42b5338a4eebed3fe94e2ca6fe7390ad2aa3839a60295b5e4702db0c8d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a773609dbf576aa1ffc9b40454053cf4e47c873fe28b8893d0e671ec097448a43660b10e2713ac28a8aabd7d26aa55d8ccca024138a3143ff7a853ac5a1aaff9
|
|
7
|
+
data.tar.gz: 67410b752e36055057b956bb6719b66caa7e0afe1e223ca0ad64f05619fe4b48d4f5be2e357271e985e52103ba619b5ce776551d8c8936e04d1016f610e2a7ed
|
data/lib/pampa.rb
CHANGED
|
@@ -731,5 +731,86 @@ module BlackStack
|
|
|
731
731
|
end
|
|
732
732
|
end # def failed
|
|
733
733
|
end # class Job
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
# This method is used to run a stand alone process.
|
|
737
|
+
# Parameters:
|
|
738
|
+
# - h[:log_filename] - the name of the log file. If nil, the log won't be printed.
|
|
739
|
+
# - h[:delay] - the minimum delay between loops. A minimum of 10 seconds is recommended, in order to don't hard the database server. Default is 30 seconds.
|
|
740
|
+
# - h[:run_once] - avoid infinite loop. Default is false.
|
|
741
|
+
# - h[:function] - the Proc to be executed in each loop.
|
|
742
|
+
#
|
|
743
|
+
def self.run_stand_alone(h, *args)
|
|
744
|
+
err = []
|
|
745
|
+
#err << "The parameter 'log_filename' is required." if h[:log_filename].nil? || h[:log_filename].to_s.empty?
|
|
746
|
+
err << "The parameter 'delay' is required." if h[:delay].nil? || h[:delay].to_s.empty?
|
|
747
|
+
err << "The parameter 'run_once' is required." if h[:run_once].nil? || h[:run_once].to_s.empty?
|
|
748
|
+
err << "The parameter 'function' is required." if h[:function].nil? || h[:function].to_s.empty?
|
|
749
|
+
|
|
750
|
+
err << "The parameter 'log_filename' must be a string." if h[:log_filename] && !h[:log_filename].is_a?(String)
|
|
751
|
+
err << "The parameter 'delay' must be an integer." if h[:delay] && !h[:delay].is_a?(Integer)
|
|
752
|
+
err << "The parameter 'run_once' must be a boolean." if h[:run_once] && ![true, false].include?(h[:run_once])
|
|
753
|
+
err << "The parameter 'function' must be a Proc." if h[:function] && !h[:function].is_a?(Proc)
|
|
754
|
+
|
|
755
|
+
log_filename = h[:log_filename]
|
|
756
|
+
delay = h[:delay]
|
|
757
|
+
run_once = h[:run_once]
|
|
758
|
+
function = h[:function]
|
|
759
|
+
|
|
760
|
+
l = log_filename.nil? ? BlackStack::DummyLogger.new(nil) : BlackStack::LocalLogger.new(log_filename)
|
|
761
|
+
|
|
762
|
+
while true
|
|
763
|
+
# get the start loop time
|
|
764
|
+
l.logs 'Starting loop... '
|
|
765
|
+
start = Time.now()
|
|
766
|
+
l.logf 'done'.green
|
|
767
|
+
|
|
768
|
+
begin
|
|
769
|
+
function.call(l)
|
|
770
|
+
# catch general exceptions
|
|
771
|
+
rescue => e
|
|
772
|
+
l.logf "Error: #{e.to_console.red}"
|
|
773
|
+
# CTRL+C will be catched here
|
|
774
|
+
rescue Interrupt => e
|
|
775
|
+
l.logf "Interrupted".red
|
|
776
|
+
exit(0)
|
|
777
|
+
end
|
|
778
|
+
|
|
779
|
+
l.logs 'Releasing resources... '
|
|
780
|
+
GC.start
|
|
781
|
+
l.logf 'done'.green
|
|
782
|
+
|
|
783
|
+
if run_once
|
|
784
|
+
l.log "Finished Loop!\n".blue
|
|
785
|
+
exit(0)
|
|
786
|
+
end
|
|
787
|
+
|
|
788
|
+
# get the end loop time
|
|
789
|
+
l.logs 'Ending loop... '
|
|
790
|
+
finish = Time.now()
|
|
791
|
+
l.logf 'done'.green
|
|
792
|
+
|
|
793
|
+
# get different in seconds between start and finish
|
|
794
|
+
# if diff > 30 seconds
|
|
795
|
+
l.logs 'Calculating loop duration... '
|
|
796
|
+
diff = finish - start
|
|
797
|
+
l.logf 'done ('+diff.to_s.blue+')'
|
|
798
|
+
|
|
799
|
+
l.log "Finished Loop!\n".blue
|
|
800
|
+
|
|
801
|
+
if diff < delay
|
|
802
|
+
# sleep for 30 seconds
|
|
803
|
+
n = delay-diff
|
|
804
|
+
|
|
805
|
+
l.logs 'Sleeping for '+n.to_label.blue+' seconds... '
|
|
806
|
+
sleep n
|
|
807
|
+
l.logf 'done'.green
|
|
808
|
+
else
|
|
809
|
+
l.log 'No sleeping. The loop took '+diff.to_label.blue+' seconds.'
|
|
810
|
+
end # if diff < delay
|
|
811
|
+
|
|
812
|
+
end # while (true)
|
|
813
|
+
end # def self.run_stand_alone
|
|
814
|
+
|
|
734
815
|
end # module Pampa
|
|
735
816
|
end # module BlackStack
|
data/pampa.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'pampa'
|
|
3
|
-
s.version = '2.1.
|
|
4
|
-
s.date = '2024-
|
|
3
|
+
s.version = '2.1.5'
|
|
4
|
+
s.date = '2024-08-03'
|
|
5
5
|
s.summary = "Ruby library for async & distributed computing, supporting dynamic reconfiguration, distribution of the computation jobs, error handling, job-retry and fault tolerance, and fast (non-direct) communication to ensure real-time capabilities."
|
|
6
6
|
s.description = "Pampa is a Ruby library for async & distributing computing providing the following features:
|
|
7
7
|
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pampa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.1.
|
|
4
|
+
version: 2.1.5
|
|
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: 2024-
|
|
11
|
+
date: 2024-08-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rubygems-bundler
|