QueueMessage.py 1.55 KB
Newer Older
jtchilders's avatar
jtchilders committed
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
30
31
32
33
34
35
36
37
38
39
# errors from Transition function
TransitionComplete                        = 10
TransitionDbConnectionFailed              = 11
TransitionDbRetrieveFailed                = 12
TransitionFunctionException               = 13
# errors from JobStatusReceiver
JobStatusReceiverRetrieveArgoSubJobFailed = 21
JobStatusReceiverRetrieveArgoJobFailed    = 22
JobStatusReceiverBalsamStateMapFailure    = 23
JobStatusReceiverCompleted                = 24
JobStatusReceiverMessageNoBody            = 25
JobStatusReceiverFailed                   = 26
msg_codes = {
   0:'NoMessageCode',
   TransitionComplete:'TransitionComplete',
   TransitionDbConnectionFailed:'TransitionDbConnectionFailed',
   TransitionDbRetrieveFailed:'TransitionDbRetrieveFailed',
   TransitionFunctionException:'TransitionFunctionException',
   JobStatusReceiverRetrieveArgoSubJobFailed:'JobStatusReceiverRetrieveArgoSubJobFailed',
   JobStatusReceiverRetrieveArgoJobFailed:'JobStatusReceiverRetrieveArgoJobFailed',
   JobStatusReceiverBalsamStateMapFailure:'JobStatusReceiverBalsamStateMapFailure',
   JobStatusReceiverCompleted:'JobStatusReceiverCompleted',
   JobStatusReceiverMessageNoBody:'JobStatusReceiverMessageNoBody',
   JobStatusReceiverFailed:'JobStatusReceiverFailed',
}

class QueueMessage:
   ''' a message used to communicate with the balsam_service main loop '''


   def __init__(self,pk=0,code=0,message=''):
      self.pk = pk
      self.code = code
      self.message = message

   def __str__(self):
      s = ''
      s = '%i:%s:%s' % (self.pk,self.msg_codes[self.msg_code],self.message)
      return s