Skip to content

Commit

Permalink
Merge pull request #9 from TogetherCrew/temperoray-add-saga-env-logs
Browse files Browse the repository at this point in the history
Fixed publish-on-success args passing!
  • Loading branch information
cyri113 authored Oct 3, 2023
2 parents a6fd118 + 97783de commit 3f875df
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bot/saga/extract_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def find_saga_and_fire_extract_profiles(sagaId: str):
else:
twitter_username = saga.data["twitter_username"]
twitter_user = get_twitter_user(username=twitter_username)
twitter_id = twitter_user.id
twitter_id = str(twitter_user.id)

def extract_and_save_user_information_wrapper(**kwargs):
extract_and_save_user_information(user_id=twitter_id)
Expand Down
12 changes: 6 additions & 6 deletions bot/saga/saga.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import logging

import numpy as np
from bot.utils.rabbitmq_connection import prepare_rabbit_mq
from bot.utils.mongo_connection import get_saga_db_location
from bot.utils.rabbitmq_connection import get_rabbit_mq_credentials, prepare_rabbit_mq
from tc_messageBroker.rabbit_mq.saga.saga_base import Status, get_saga


Expand Down Expand Up @@ -55,11 +56,10 @@ def sort_transactions(transactions: list):


def publish_on_success(connection, result, *args, **kwargs):
# we must get these three things
try:
rabbit_creds = args[0][0]
sagaId = args[0][1]
mongo_creds = args[0][2]
sagaId = args[0][0]
mongo_creds = get_saga_db_location()
rabbit_creds = get_rabbit_mq_credentials()
logging.info(f"SAGAID: {sagaId}: ON_SUCCESS callback! ")

saga = get_saga_instance(
Expand Down Expand Up @@ -87,7 +87,7 @@ def publish_on_success(connection, result, *args, **kwargs):
content={"uuid": sagaId, "data": saga.data},
)
except Exception as exp:
logging.info(f"Exception occured in job on_success callback: {exp}")
logging.error(f"Exception occured in job on_success callback: {exp}")


def sort_transactions_orderly(transactions: list):
Expand Down
3 changes: 2 additions & 1 deletion bot/services/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import functools
import logging
from itertools import count


Expand All @@ -13,7 +14,7 @@ def retry_function_if_fail(func, /, *args, **keywords):
return response

except Exception as ex:
print("[Exception(retry_function_if_fail)]", ex)
logging.error(f"[Exception(retry_function_if_fail)]: {ex}")

finally:
if counter == retry_number:
Expand Down
2 changes: 1 addition & 1 deletion bot/utils/mongo_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_mongo_connection(mongo_creds: dict[str, Any] | None = None) -> str:

def get_saga_db_location(mongo_creds: dict[str, Any] | None = None):
"""
get the saga location in database
get the saga location in database and the mongo connection string
"""
if mongo_creds is None:
mongo_creds = get_mongo_credentials()
Expand Down

0 comments on commit 3f875df

Please sign in to comment.