1515
1616# TODO add DLQ logic (needs jira ticket probably).
1717
18- AWS_PROFILE_NAME = os .environ ['AWS_PROFILE_NAME' ]
1918Q_URL = os .environ ['Q_URL' ]
2019SZ_CONFIG = json .loads (os .environ ['SENZING_ENGINE_CONFIGURATION_JSON' ])
2120
2524#-------------------------------------------------------------------------------
2625
2726def _make_boto_session (fpath = None ):
28- '''fpath is path to json file with keys:
27+ '''
28+ If `AWS_PROFILE` environment variable is set, then `Session()` can be
29+ called with no arguments.
30+
31+ fpath is path to json file with keys:
2932 - aws_access_key_id
3033 - aws_secret_access_key
3134 - aws_session_token
@@ -35,7 +38,7 @@ def _make_boto_session(fpath=None):
3538 if fpath :
3639 return boto3 .Session (** json .load (open (fpath )))
3740 else :
38- return boto3 .Session (profile_name = AWS_PROFILE_NAME )
41+ return boto3 .Session ()
3942
4043def _make_sqs_client (boto_session ):
4144 return boto_session .client ('sqs' )
@@ -87,15 +90,6 @@ def go():
8790 try :
8891 sz_factory = sz_core .SzAbstractFactoryCore ("ERS" , SZ_CONFIG )
8992
90- # Init data source list.
91- # TODO data source registry logic should be set up as a one-time task
92- # outside of this app somewhere else.
93- sz_config_mgr = sz_factory .create_configmanager ()
94- sz_config = sz_config_mgr .create_config_from_config_id (
95- sz_config_mgr .get_default_config_id ())
96- sz_config .register_data_source ("CUSTOMERS" )
97- sz_config_mgr .set_default_config (sz_config .export (), 'default' )
98-
9993 # Init senzing engine object.
10094 # Senzing engine object cannot be passed around between functions,
10195 # else it will be eagerly cleaned up / destroyed and no longer usable.
@@ -108,7 +102,11 @@ def go():
108102 # TODO log ReceiptHandle, other *generic* debug-facing information as appropriate.
109103 while 1 :
110104 print ('Starting primary loop iteration . . .' )
105+
106+ # Get next message.
111107 msg = next (msgs )
108+
109+ # Process and send to Senzing.
112110 receipt_handle , body = msg ['ReceiptHandle' ], msg ['Body' ]
113111 rcd = json .loads (body )
114112 try :
@@ -121,6 +119,8 @@ def go():
121119 except sz .SzError as err :
122120 # TODO log / handle
123121 print (err )
122+
123+ # Delete msg from queue.
124124 del_msg (sqs , Q_URL , receipt_handle )
125125
126126def main ():
0 commit comments