workmesh 1.0.4 → 1.0.6

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
  SHA256:
3
- metadata.gz: 41375949fd691423ac3b677de62b756450c29f1992fdf032667de7d10beaf092
4
- data.tar.gz: 32c1dbeef3502c7a4fe23dfc555adaa507a48a3e8b14e26cf849215a2e6a964a
3
+ metadata.gz: 255b5cf5609d4a94c1a6ddeb7ae7a0cdcc448999c25f7d86e0714d4882ae66dc
4
+ data.tar.gz: ab3bd85f5e3b7c8944c5680a79d3d07be5256b3ce5d36a86abdfe2413d86443c
5
5
  SHA512:
6
- metadata.gz: d2c231f9d54f104e16a11308e4060c805763973d5d188f58dba6b5d6af87e5db3206e0bb21d105518f2627bef7227d155e1036623a99246deeed4716636b8152
7
- data.tar.gz: 2bda3a87ccab98c3d6df49b6ec578c40d69f29bb25b8a4cf2910cd9fb38a00b24cc73d987bf374c0fe81ab3e00d0144f0aa3d6a4ef764fabb8034d6ca129a9d9
6
+ metadata.gz: 3fd0f3ecac7a857015e3d26670e43e76344ba57569137b198782af8810450d89c214824c0e0f5c7c7548abaaf3753a6ccfef3105edc23888a62f84d34178c73a
7
+ data.tar.gz: e255c8ce3f9bb80090589f29f551bc509ab50e30a4624f9d258ff046c9f5ea626bd109491dfd4f2f6b093deacadfc5d8857dade51f7e86cc2eac614c0c43203c
@@ -6,10 +6,15 @@ BlackStack::Deployer::add_routine({
6
6
  :command => 'mkdir ~/code;',
7
7
  :matches => [ /^$/i, /File exists/i ],
8
8
  :sudo => false,
9
+ }, {
10
+ :command => 'mkdir -p ~/code/%workmesh_service%;',
11
+ :matches => [ /^$/i, /File exists/i ],
12
+ :sudo => false,
9
13
  }, {
10
14
  :command => '
11
- cd ~/code;
12
- git clone https://github.com/%git_user%/%workmesh_service%;
15
+ cd ~/code/%workmesh_service%;
16
+ rm -r ./*;
17
+ git clone https://github.com/%workmesh_service% .;
13
18
  ',
14
19
  :matches => [
15
20
  /already exists and is not an empty directory/i,
data/lib/workmesh.rb CHANGED
@@ -2,7 +2,6 @@ require 'colorize'
2
2
  require 'sequel'
3
3
  require 'blackstack-core'
4
4
  require 'blackstack-nodes'
5
- require 'blackstack-deployer'
6
5
  require 'simple_command_line_parser'
7
6
  require 'simple_cloud_logging'
8
7
 
@@ -76,18 +75,6 @@ module BlackStack
76
75
  ret[:workmesh_service] = self.workmesh_service
77
76
  ret
78
77
  end
79
- # run deployment routines
80
- def deploy(l=nil)
81
- l = BlackStack::DummyLogger.new(nil) if l.nil?
82
-
83
- l.logs 'Updating config.rb... '
84
- BlackStack::Deployer::run_routine(self.name, 'workmesh-update-config')
85
- l.done
86
-
87
- l.logs 'Updating source... '
88
- BlackStack::Deployer::run_routine(self.name, 'workmesh-update-source')
89
- l.done
90
- end
91
78
  end # class Node
92
79
 
93
80
  class Protocol
@@ -95,7 +82,7 @@ module BlackStack
95
82
  attr_accessor :entity_table, :entity_field_id, :entity_field_sort
96
83
  attr_accessor :push_function, :entity_field_push_time, :entity_field_push_success, :entity_field_push_error_description
97
84
  attr_accessor :pull_status_access_point
98
- attr_accessor :pull_function, :enttity_field_pull_time, :entity_field_pull_success, :entity_field_pull_error_description
85
+ attr_accessor :pull_function #, :enttity_field_pull_time, :entity_field_pull_success, :entity_field_pull_error_description
99
86
 
100
87
  def self.descriptor_errors(h)
101
88
  errors = []
@@ -122,14 +109,14 @@ module BlackStack
122
109
  errors << "The key :entity_field_push_error_description is missing" if h[:push_function] && h[:entity_field_push_error_description].nil?
123
110
 
124
111
  # valiudate: if :pull_function exists, the key :pull_status_access_point exists and it is a string
125
- errors << "The key :pull_status_access_point is missing" if h[:pull_function] && h[:pull_status_access_point].nil?
126
- errors << "The key :pull_status_access_point must be an String" unless h[:pull_function].nil? || h[:pull_status_access_point].is_a?(String)
112
+ #errors << "The key :pull_status_access_point is missing" if h[:pull_function] && h[:pull_status_access_point].nil?
113
+ #errors << "The key :pull_status_access_point must be an String" unless h[:pull_function].nil? || h[:pull_status_access_point].is_a?(String)
127
114
  # validate: if :pull_function exists, the key :entity_field_pull_time exists and it is a symbol
128
- errors << "The key :entity_field_pull_time is missing" if h[:pull_function] && h[:entity_field_pull_time].nil?
115
+ #errors << "The key :entity_field_pull_time is missing" if h[:pull_function] && h[:entity_field_pull_time].nil?
129
116
  # validate: if :pull_function exists, the key :entity_field_pull_success exists and it is a symbol
130
- errors << "The key :entity_field_pull_success is missing" if h[:pull_function] && h[:entity_field_pull_success].nil?
117
+ #errors << "The key :entity_field_pull_success is missing" if h[:pull_function] && h[:entity_field_pull_success].nil?
131
118
  # validate: if :pull_function exists, the key :entity_field_pull_error_description exists and it is a symbol
132
- errors << "The key :entity_field_pull_error_description is missing" if h[:pull_function] && h[:entity_field_pull_error_description].nil?
119
+ #errors << "The key :entity_field_pull_error_description is missing" if h[:pull_function] && h[:entity_field_pull_error_description].nil?
133
120
 
134
121
  # return list of errors
135
122
  errors.uniq
@@ -147,9 +134,9 @@ module BlackStack
147
134
  self.entity_field_push_success = h[:entity_field_push_success]
148
135
  self.entity_field_push_error_description = h[:entity_field_push_error_description]
149
136
  self.pull_function = h[:pull_function]
150
- self.enttity_field_pull_time = h[:entity_field_pull_time]
151
- self.entity_field_pull_success = h[:entity_field_pull_success]
152
- self.entity_field_pull_error_description = h[:entity_field_pull_error_description]
137
+ #self.enttity_field_pull_time = h[:entity_field_pull_time]
138
+ #self.entity_field_pull_success = h[:entity_field_pull_success]
139
+ #self.entity_field_pull_error_description = h[:entity_field_pull_error_description]
153
140
  end
154
141
 
155
142
  def to_hash()
@@ -163,18 +150,19 @@ module BlackStack
163
150
  ret[:entity_field_push_success] = self.entity_field_push_success
164
151
  ret[:entity_field_push_error_description] = self.entity_field_push_error_description
165
152
  ret[:pull_function] = self.pull_function
166
- ret[:enttity_field_pull_time] = self.enttity_field_pull_time
167
- ret[:entity_field_pull_success] = self.entity_field_pull_success
168
- ret[:entity_field_pull_error_description] = self.entity_field_pull_error_description
153
+ #ret[:enttity_field_pull_time] = self.enttity_field_pull_time
154
+ #ret[:entity_field_pull_success] = self.entity_field_pull_success
155
+ #ret[:entity_field_pull_error_description] = self.entity_field_pull_error_description
169
156
  ret
170
157
  end
171
158
 
172
159
  # execute the push function of this protocol, and update the push flags
173
- def push(entity, node)
160
+ def push(entity, node, l=nil)
161
+ l = BlackStack::DummyLogger.new(nil) if l.nil?
174
162
  raise 'The push function is not defined' if self.push_function.nil?
175
163
  entity[entity_field_push_time] = now()
176
164
  begin
177
- self.push_function.call(entity, node)
165
+ self.push_function.call(entity, node, l)
178
166
  entity[entity_field_push_success] = true
179
167
  entity[entity_field_push_error_description] = nil
180
168
  entity.save
@@ -184,7 +172,19 @@ module BlackStack
184
172
  entity.save
185
173
  raise e
186
174
  end
187
- end
175
+ end # def push(entity, node, l=nil)
176
+
177
+ # execute the pull function of this protocol, and update the push flags
178
+ def pull(node, l=nil)
179
+ l = BlackStack::DummyLogger.new(nil) if l.nil?
180
+ raise 'The pull function is not defined' if self.pull_function.nil?
181
+ begin
182
+ self.pull_function.call(node, l)
183
+ rescue => e
184
+ raise e
185
+ end
186
+ end # def pull(node, l=nil)
187
+
188
188
  end # class Protocol
189
189
 
190
190
  # stub worker class
@@ -209,7 +209,8 @@ module BlackStack
209
209
  if h[:protocols].is_a?(Array)
210
210
  h[:protocols].each do |protocol|
211
211
  errors << "The key :protocols must be an Array of valid hash descritors of the Protocol class" unless protocol.is_a?(Hash)
212
- errors << "The key :protocols must be an Array of valid hash descritors of the Protocol class" unless Protocol.descriptor_errors(protocol).length == 0
212
+ z = Protocol.descriptor_errors(protocol)
213
+ errors << "The key :protocols must be an Array of valid hash descritors of the Protocol class (errors: #{z.join('. ')})" unless z.length == 0
213
214
  end
214
215
  end
215
216
  # validate: the key :assignation is nil or it is a symbol belonging the array ASSIGANTIONS
@@ -223,7 +224,7 @@ module BlackStack
223
224
  # setup dispatcher configuration here
224
225
  def initialize(h)
225
226
  errors = BlackStack::Workmesh::Service.descriptor_errors(h)
226
- raise "The worker descriptor is not valid: #{errors.uniq.join(".\n")}" if errors.length > 0
227
+ raise "The service descriptor is not valid: #{errors.uniq.join(".\n")}" if errors.length > 0
227
228
  self.name = h[:name]
228
229
  self.entity_table = h[:entity_table]
229
230
  self.entity_field_assignation = h[:entity_field_assignation]
@@ -299,8 +300,6 @@ module BlackStack
299
300
  # add a node to the infrastructure
300
301
  def self.add_node(h)
301
302
  @@nodes << BlackStack::Workmesh::Node.new(h)
302
- # add to deployer
303
- BlackStack::Deployer.add_node(h) #if @@integrate_with_blackstack_deployer
304
303
  end
305
304
 
306
305
  def self.nodes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: workmesh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.6
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: 2023-06-28 00:00:00.000000000 Z
11
+ date: 2023-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sequel
@@ -70,26 +70,6 @@ dependencies:
70
70
  - - ">="
71
71
  - !ruby/object:Gem::Version
72
72
  version: 1.2.11
73
- - !ruby/object:Gem::Dependency
74
- name: blackstack-deployer
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - "~>"
78
- - !ruby/object:Gem::Version
79
- version: 1.2.24
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 1.2.24
83
- type: :runtime
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 1.2.24
90
- - - ">="
91
- - !ruby/object:Gem::Version
92
- version: 1.2.24
93
73
  - !ruby/object:Gem::Dependency
94
74
  name: simple_command_line_parser
95
75
  requirement: !ruby/object:Gem::Requirement