Forward the lab 4 foundation and migrate the lab 5 pipeline to SQLAlchemy
This commit is contained in:
@@ -9,6 +9,7 @@ from messenger.messaging.application.ports import (
|
||||
AttachmentStates,
|
||||
ChatDirectory,
|
||||
CursorCodec,
|
||||
MessageLog,
|
||||
MessagingUnitOfWork,
|
||||
)
|
||||
from messenger.messaging.application.queries import GetChat, ListChats, ReadHistory
|
||||
@@ -16,6 +17,7 @@ from messenger.messaging.config import MessagingSettings
|
||||
from messenger.messaging.infrastructure.cursor import SignedCursorCodec
|
||||
from messenger.messaging.infrastructure.postgres import (
|
||||
PostgresChatDirectory,
|
||||
PostgresMessageLog,
|
||||
PostgresMessagingUnitOfWork,
|
||||
)
|
||||
from messenger.shared.application.commands import Command
|
||||
@@ -37,6 +39,10 @@ class MessagingProvider(Provider):
|
||||
def directory(self, database: Database) -> ChatDirectory:
|
||||
return PostgresChatDirectory(database)
|
||||
|
||||
@provide(scope=Scope.APP)
|
||||
def log(self, database: Database, attachments: AttachmentStates) -> MessageLog:
|
||||
return PostgresMessageLog(database, attachments)
|
||||
|
||||
@provide(scope=Scope.APP)
|
||||
def cursors(self, settings: MessagingSettings) -> CursorCodec:
|
||||
return SignedCursorCodec(settings.cursor_secret.get_secret_value().encode())
|
||||
@@ -61,7 +67,8 @@ class MessagingProvider(Provider):
|
||||
def command_bus(
|
||||
self,
|
||||
uow: MessagingUnitOfWork,
|
||||
attachments: AttachmentStates,
|
||||
log: MessageLog,
|
||||
directory: ChatDirectory,
|
||||
publisher: EventPublisher,
|
||||
clock: Clock,
|
||||
ids: IdGenerator,
|
||||
@@ -70,6 +77,6 @@ class MessagingProvider(Provider):
|
||||
ttl = timedelta(seconds=settings.idempotency_ttl_seconds)
|
||||
handlers: dict[type[Command], CommandHandler] = {
|
||||
CreateChat: CreateChatHandler(uow, clock, ids),
|
||||
PostMessage: PostMessageHandler(uow, attachments, clock, ids, ttl),
|
||||
PostMessage: PostMessageHandler(uow, log, directory, clock, ids, ttl=ttl),
|
||||
}
|
||||
return MessagingCommandBus(handlers, uow, publisher)
|
||||
|
||||
@@ -37,7 +37,7 @@ class CreateMessageRequest(BaseModel):
|
||||
|
||||
class PageQuery(BaseModel):
|
||||
limit: int = Field(default=50, ge=1, le=100)
|
||||
cursor: str | None = None
|
||||
cursor: str | None = Field(default=None, min_length=1)
|
||||
|
||||
|
||||
class ChatOut(BaseModel):
|
||||
|
||||
Reference in New Issue
Block a user