meshx-plugin-sdk 0.0.6 → 0.0.8
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/meshx-plugin-sdk.rb +55 -27
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 324bdc606fa363b714f4b52d3cad94e2f8ef648957833823e24a61dd51ae7ec5
|
4
|
+
data.tar.gz: 243470dc597feb819e8486e34cd30933a70f4bf181c0861c96a6c273e3eb554b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48b178421a55563f7f6fdaccda6c024c56110e705d060a14f6a95b2b9cf3e8cad5feaaa60afa956c82e3ff6e4737dc4e8c6c1c69bbc300b83f8017067927f322
|
7
|
+
data.tar.gz: c4af66a44536816ab3f3346bb87d9b89a0172bb8b19d724c77335fdc5ed531c3ab11b9adadf4fa88e3bec319a138cc508b40eb183006e6402339d6e75a9bdd0e
|
data/lib/meshx-plugin-sdk.rb
CHANGED
@@ -129,36 +129,56 @@ class Controller
|
|
129
129
|
end
|
130
130
|
|
131
131
|
def run()
|
132
|
+
exit_run = false
|
133
|
+
begin
|
134
|
+
@log.info("calling on_init()")
|
135
|
+
@plugin.on_init()
|
136
|
+
rescue StandardError => e
|
137
|
+
@log.error("error calling on_init(): #{e.message}")
|
138
|
+
end
|
139
|
+
|
140
|
+
begin
|
141
|
+
@log.info("calling on_start()")
|
142
|
+
@plugin.on_start()
|
143
|
+
rescue StandardError => e
|
144
|
+
@log.error("error calling on_start(): #{e.message}")
|
145
|
+
end
|
146
|
+
|
132
147
|
keep_reading = true
|
133
148
|
@log.info("starting controller loop")
|
134
|
-
while keep_reading
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
149
|
+
while keep_reading && exit_run == false
|
150
|
+
begin
|
151
|
+
exit_run = @plugin.exit?()
|
152
|
+
rtn = @api.get_messages()
|
153
|
+
@log.info("rtn: #{rtn.message} #{rtn.error} #{rtn.exit_code}")
|
154
|
+
# convert message to fileevent
|
155
|
+
if valid_json?(rtn.message)
|
156
|
+
hash = JSON.parse()
|
157
|
+
hash["items"].each do |item|
|
158
|
+
@log.info("message kind: #{item["kind"]}")
|
159
|
+
case item["kind"]
|
160
|
+
when "FileEvent"
|
161
|
+
@log.info("FileEvent")
|
162
|
+
event = FileEvent.new(item)
|
163
|
+
@plugin.on_file_event(event)
|
164
|
+
when "FolderEvent"
|
165
|
+
@log.info("FolderEvent")
|
166
|
+
event = FolderEvent.new(item)
|
167
|
+
@plugin.on_folder_event(event)
|
168
|
+
when "CompleteEvent"
|
169
|
+
@log.info("CompleteEvent")
|
170
|
+
event = CompleteEvent.new(item)
|
171
|
+
@plugin.on_complete_event(event)
|
172
|
+
keep_reading = false
|
173
|
+
else
|
174
|
+
@log.info("unknown event kind: #{item["kind"]}")
|
175
|
+
end
|
158
176
|
end
|
159
|
-
|
160
|
-
|
161
|
-
|
177
|
+
else
|
178
|
+
@log.info("invalid message [#{rtn.message}]")
|
179
|
+
end
|
180
|
+
rescue Exception => e
|
181
|
+
@log.error("error event processing: #{e.message}")
|
162
182
|
end
|
163
183
|
end
|
164
184
|
@log.info("ending controller loop sending complete event")
|
@@ -166,6 +186,14 @@ class Controller
|
|
166
186
|
if res2.exit_code != 0
|
167
187
|
@log.error("failed to send complete event: #{res2.error} #{res2.exit_code}")
|
168
188
|
end
|
189
|
+
|
190
|
+
begin
|
191
|
+
@log.info("calling on_end()")
|
192
|
+
@plugin.on_end()
|
193
|
+
rescue StandardError => e
|
194
|
+
@log.error("error calling on_end(): #{e.message}")
|
195
|
+
end
|
196
|
+
|
169
197
|
end
|
170
198
|
end
|
171
199
|
|