blob: cebe36148a44b04510d9912841b5738a27e3e188 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
make DB connection
Validate client_id and token.
Client will also send a list of job_id's it already has. store as ids_client_already_has.
query = "SELECT * FROM jobs WHERE client_id="+client_id+" and status='pending' ORDER BY priority"
foreach row in results:
if job_id in ids_client_already_has: continue
Serialize job. keep in memory. as jobs[job_id]
write job to disk as XML. md5 it. store in memory as md5s[job_id]
push job_id onto list of jobs_to_send.
while jobs_to_send:
pop current_job from jobs_to_send
send jobs[current_job]
send md5s[current_job]
wait a bit for a response... if timeout, push current_job back onto jobs_to_send.
if response == "BadMD5":
log event to error log.
push current_job onto jobs_to_send
# job will get resent the next time around.
# moves to bottom of queue incase it is a recurring problem
# so it doesn't hold up all the other jobs?
# this is OK because it will be resorted by priority on the client's end.
if response == "OK":
query = "UPDATE jobs SET status='received' WHERE job_id="+current_job
continue #move onto next job. This is in the client's hands now.
close DB connection.
|