Skip to content

Example #1

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Example #1

wants to merge 8 commits into from

Conversation

lzukowski
Copy link
Collaborator

No description provided.

from sqlalchemy import MetaData, StaticPool, create_engine
from sqlalchemy.orm import Session, as_declarative

with NamedTemporaryFile() as f:
Copy link

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

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

Base.metadata.create_all(bind=engine)


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

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]

def quantity_repository(
backend: Backend = Depends(backend),
) -> Generator[QuantityRepository, None, None]:
yield QuantityRepository(backend.event_store)
Copy link

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?

)


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

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 👍

units: int = Body(...),
backend: Backend = Depends(backend),
) -> None:
backend.event_store.append(
Copy link

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 ?

metadata: MetaData


configure_models(Base)
Copy link

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



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

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