file-processing-job 0.1.2 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/file-processing-job.rb +0 -1
- data/lib/fpj/client.rb +0 -4
- data/lib/fpj/connection.rb +10 -0
- data/lib/fpj/server.rb +16 -7
- metadata +3 -3
data/lib/file-processing-job.rb
CHANGED
data/lib/fpj/client.rb
CHANGED
data/lib/fpj/connection.rb
CHANGED
@@ -8,6 +8,15 @@ module FileProcessingJob
|
|
8
8
|
# set_comm_inactivity_timeout(120)
|
9
9
|
end
|
10
10
|
|
11
|
+
def self.logger
|
12
|
+
FileProcessingJob.logger
|
13
|
+
end
|
14
|
+
|
15
|
+
def logger
|
16
|
+
FileProcessingJob.logger
|
17
|
+
end
|
18
|
+
|
19
|
+
|
11
20
|
def receive_data(data)
|
12
21
|
@recv_buffer.extract(data).each do |msg|
|
13
22
|
receive_task(msg)
|
@@ -21,5 +30,6 @@ module FileProcessingJob
|
|
21
30
|
def receive_request
|
22
31
|
raise "receive_task not overridden by #{self.class.name}"
|
23
32
|
end
|
33
|
+
|
24
34
|
end
|
25
35
|
end
|
data/lib/fpj/server.rb
CHANGED
@@ -138,28 +138,37 @@ module FileProcessingJob
|
|
138
138
|
class Connection < FileProcessingJob::Connection
|
139
139
|
@@q = EM::Queue.new()
|
140
140
|
|
141
|
-
def self.push(
|
142
|
-
|
143
|
-
|
141
|
+
def self.push(filename)
|
142
|
+
if (filename.nil?)
|
143
|
+
#ignore
|
144
|
+
elsif (File.size(File.join(config.inbox_directory, filename)) == 0)
|
145
|
+
logger.error "Moving 0 byte file #{filename} to errors directory"
|
146
|
+
FileUtils.move(File.join(config.inbox_directory, filename), File.join(config.error_directory, filename))
|
147
|
+
else
|
148
|
+
FileProcessingJob.logger.debug "#{filename} discovered in inbox"
|
149
|
+
@@q.push(filename)
|
150
|
+
end
|
144
151
|
end
|
145
152
|
|
153
|
+
def self.config
|
154
|
+
FileProcessingJob::Server.config
|
155
|
+
end
|
156
|
+
|
146
157
|
def config
|
147
158
|
@config ||= FileProcessingJob::Server.config
|
148
159
|
end
|
149
160
|
|
150
|
-
def logger
|
151
|
-
FileProcessingJob.logger
|
152
|
-
end
|
153
|
-
|
154
161
|
def send_file(filename)
|
155
162
|
logger.debug "Sending #{filename} to client"
|
156
163
|
|
157
164
|
send_message("filename: #{filename}")
|
158
165
|
|
159
166
|
FileUtils.move(File.join(self.config.inbox_directory, filename), File.join(self.config.processing_directory, filename))
|
167
|
+
logger.debug "Sending file #{filename} to client"
|
160
168
|
streamer = EventMachine::FileStreamer.new(self, File.join(self.config.processing_directory, filename))
|
161
169
|
streamer.callback{
|
162
170
|
send_data TOKEN
|
171
|
+
logger.debug "\tsuccessfully sent #{filename}"
|
163
172
|
}
|
164
173
|
end
|
165
174
|
|
metadata
CHANGED
@@ -3,10 +3,10 @@ name: file-processing-job
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
-
- 0
|
7
6
|
- 1
|
8
7
|
- 2
|
9
|
-
|
8
|
+
- 5
|
9
|
+
version: 1.2.5
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- cj2
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-24 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|