Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get nonce from DB #162

Draft
wants to merge 3 commits into
base: development
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions worker/worker/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
from dataclasses import dataclass
from typing import List, Optional, Tuple, Union

import requests
from sqlalchemy import create_engine, select
from sqlalchemy import create_engine, select, desc
from sqlalchemy.orm import Session, joinedload, scoped_session, sessionmaker

from common import logger
Expand Down Expand Up @@ -142,7 +141,11 @@ def handle(event, context):
sess = scoped_session(sessionmaker(bind=engine))
uuid_list = [x.body.get("uuid") for x in message.Records if x.body.get("uuid") is not None]
receipt_dict = {str(x.uuid): x for x in sess.scalars(select(Receipt).where(Receipt.uuid.in_(uuid_list)))}
nonce = None
nonce = sess.scalar(select(Receipt.nonce).order_by(desc(Receipt.nonce)))
if nonce:
# Use next nonce
nonce += 1

for i, record in enumerate(message.Records):
# Always 1 record in message since IAP sends one record at a time.
# TODO: Handle exceptions and send messages to DLQ
Expand Down