Skip to content

Example - #1

Open
lzukowski wants to merge 8 commits into
mainfrom
example
Open

lzukowski wants to merge 8 commits into
mainfrom
example

Conversation

@lzukowski

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/backend.py
from sqlalchemy import MetaData, StaticPool, create_engine
from sqlalchemy.orm import Session, as_declarative

with NamedTemporaryFile() as f:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

err does it work? NamedTemporaryFile by default deletes the file either when one exits context manager or file is closed

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU, it'll reuse the file name but right after this context manager file will be removed.

Since SQLAlchemy's engine is lazy, I wouldn't be surprised if it would touch the file on first use

Comment thread src/backend.py
Base.metadata.create_all(bind=engine)


def session() -> Generator[Session, None, None]:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[trivia] can be Iterator[Session]

Comment thread src/inventory.py
def quantity_repository(
backend: Backend = Depends(backend),
) -> Generator[QuantityRepository, None, None]:
yield QuantityRepository(backend.event_store)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[trivia] does it have to yield?

Comment thread src/outbox.py
)


@router.post("/process", name="outbox:process", status_code=200)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense for an example 👍

Comment thread src/ordering.py
units: int = Body(...),
backend: Backend = Depends(backend),
) -> None:
backend.event_store.append(

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about injecting just event_store ?

Comment thread src/backend.py
metadata: MetaData


configure_models(Base)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments explaining the setup might be useful

Comment thread src/inventory.py


class QuantityRepository(Repository[Quantity]):
def publish(self, record: Recorded) -> None:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit lost. How does record get into this method after outbox processing? I can't find any subscription

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants