Skip to content

Commit 3e3ee3f

Browse files
committed
PR fixes, etc
1 parent e293621 commit 3e3ee3f

File tree

5 files changed

+17
-16
lines changed

5 files changed

+17
-16
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ celerybeat-schedule
150150
*.sage.py
151151

152152
# Environments
153-
.env
154153
.venv
155154
env/
156155
venv/

Dockerfile.consumer

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM senzing/senzingsdk-runtime:latest
1+
FROM senzing/senzingsdk-runtime:4.0.0
22

33
USER root
44

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ and run the consumer service on our local machine. This setup includes:
6060
1. Spinning up a consumer service:
6161

6262
```bash
63-
docker compose run --env AWS_PROFILE_NAME="some-profile-name" --env Q_URL="https://some-sqs-queue-url" consumer
63+
docker compose run --env AWS_PROFILE_NAME="some-profile-name" --env \
64+
Q_URL="http://sqs.us-east-1.localhost.localstack.cloud:4566/000000000000/sqs-senzing-local-ingest" \
65+
consumer
6466
```
6567

6668
### Using the services

docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ services:
2424
depends_on:
2525
- db
2626
environment:
27-
SENZING_TOOLS_DATASOURCES: PEOPLE
27+
SENZING_TOOLS_DATASOURCES: PEOPLE, CUSTOMERS
2828
SENZING_TOOLS_ENGINE_CONFIGURATION_JSON: >-
2929
{
3030
"PIPELINE": {

middleware/consumer.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
# TODO add DLQ logic (needs jira ticket probably).
1717

18-
AWS_PROFILE_NAME = os.environ['AWS_PROFILE_NAME']
1918
Q_URL = os.environ['Q_URL']
2019
SZ_CONFIG = json.loads(os.environ['SENZING_ENGINE_CONFIGURATION_JSON'])
2120

@@ -25,7 +24,11 @@
2524
#-------------------------------------------------------------------------------
2625

2726
def _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

4043
def _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

126126
def main():

0 commit comments

Comments
 (0)