-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
from sqlalchemy import MetaData, StaticPool, create_engine | ||
from sqlalchemy.orm import Session, as_declarative | ||
|
||
with NamedTemporaryFile() as f: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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]: |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
No description provided.