Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/lint-and-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
with:
path: ~/.cache
key: self-runner-${{ runner.os }}-python-3.11-poetry-${{ hashFiles('poetry.lock') }}-precommit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Set up Python 3.11.0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11.0-rc.2
python-version: '3.11'
- name: Install dependencies
run: |
cp env.sample .env
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
with:
path: ~/.cache
key: self-runner-${{ runner.os }}-python-3.11-poetry-${{ hashFiles('poetry.lock') }}-precommit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Set up Python 3.11.0
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11.0-rc.2
python-version: '3.11'
- name: Install dependencies
run: |
cp env.sample .env
Expand Down
32 changes: 16 additions & 16 deletions fastqueue/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def not_found_exception_handler(request: Request, exc: NotFoundError):

@app.post("/topics", response_model=TopicSchema, status_code=status.HTTP_201_CREATED, tags=["topics"])
def create_topic(data: CreateTopicSchema, session: Session = Depends(get_session)):
return TopicService.create(data=data, session=session)
return TopicService(session=session).create(data=data)


@app.get(
Expand All @@ -83,7 +83,7 @@ def create_topic(data: CreateTopicSchema, session: Session = Depends(get_session
responses={404: {"model": NotFoundSchema}},
)
def get_topic(topic_id: str, session: Session = Depends(get_session)):
return TopicService.get(id=topic_id, session=session)
return TopicService(session=session).get(id=topic_id)


@app.delete(
Expand All @@ -93,17 +93,17 @@ def get_topic(topic_id: str, session: Session = Depends(get_session)):
responses={404: {"model": NotFoundSchema}},
)
def delete_topic(topic_id: str, session: Session = Depends(get_session)):
return TopicService.delete(id=topic_id, session=session)
return TopicService(session=session).delete(id=topic_id)


@app.get("/topics", response_model=ListTopicSchema, status_code=status.HTTP_200_OK, tags=["topics"])
def list_topics(offset: int = 0, limit: int = 10, session: Session = Depends(get_session)):
return TopicService.list(filters=None, offset=offset, limit=limit, session=session)
return TopicService(session=session).list(filters=None, offset=offset, limit=limit)


@app.post("/queues", response_model=QueueSchema, status_code=status.HTTP_201_CREATED, tags=["queues"])
def create_queue(data: CreateQueueSchema, session: Session = Depends(get_session)):
return QueueService.create(data=data, session=session)
return QueueService(session=session).create(data=data)


@app.get(
Expand All @@ -114,7 +114,7 @@ def create_queue(data: CreateQueueSchema, session: Session = Depends(get_session
responses={404: {"model": NotFoundSchema}},
)
def get_queue(queue_id: str, session: Session = Depends(get_session)):
return QueueService.get(id=queue_id, session=session)
return QueueService(session=session).get(id=queue_id)


@app.put(
Expand All @@ -125,7 +125,7 @@ def get_queue(queue_id: str, session: Session = Depends(get_session)):
responses={404: {"model": NotFoundSchema}},
)
def update_queue(queue_id: str, data: UpdateQueueSchema, session: Session = Depends(get_session)):
return QueueService.update(id=queue_id, data=data, session=session)
return QueueService(session=session).update(id=queue_id, data=data)


@app.get(
Expand All @@ -136,7 +136,7 @@ def update_queue(queue_id: str, data: UpdateQueueSchema, session: Session = Depe
responses={404: {"model": NotFoundSchema}},
)
def get_queue_stats(queue_id: str, session: Session = Depends(get_session)):
return QueueService.stats(id=queue_id, session=session)
return QueueService(session=session).stats(id=queue_id)


@app.put(
Expand All @@ -146,7 +146,7 @@ def get_queue_stats(queue_id: str, session: Session = Depends(get_session)):
responses={404: {"model": NotFoundSchema}},
)
def purge_queue_messages(queue_id: str, session: Session = Depends(get_session)):
return QueueService.purge(id=queue_id, session=session)
return QueueService(session=session).purge(id=queue_id)


@app.put(
Expand All @@ -156,7 +156,7 @@ def purge_queue_messages(queue_id: str, session: Session = Depends(get_session))
responses={404: {"model": NotFoundSchema}},
)
def redrive_queue_messages(queue_id: str, data: RedriveQueueSchema, session: Session = Depends(get_session)):
return QueueService.redrive(id=queue_id, data=data, session=session)
return QueueService(session=session).redrive(id=queue_id, data=data)


@app.delete(
Expand All @@ -166,12 +166,12 @@ def redrive_queue_messages(queue_id: str, data: RedriveQueueSchema, session: Ses
responses={404: {"model": NotFoundSchema}},
)
def delete_queue(queue_id: str, session: Session = Depends(get_session)):
return QueueService.delete(id=queue_id, session=session)
return QueueService(session=session).delete(id=queue_id)


@app.get("/queues", response_model=ListQueueSchema, status_code=status.HTTP_200_OK, tags=["queues"])
def list_queues(offset: int = 0, limit: int = 10, session: Session = Depends(get_session)):
return QueueService.list(filters=None, offset=offset, limit=limit, session=session)
return QueueService(session=session).list(filters=None, offset=offset, limit=limit)


@app.post(
Expand All @@ -182,7 +182,7 @@ def list_queues(offset: int = 0, limit: int = 10, session: Session = Depends(get
responses={404: {"model": NotFoundSchema}},
)
def create_message(topic_id: str, data: CreateMessageSchema, session: Session = Depends(get_session)):
return MessageService.create(topic_id=topic_id, data=data, session=session)
return MessageService(session=session).create(topic_id=topic_id, data=data)


@app.get(
Expand All @@ -193,17 +193,17 @@ def create_message(topic_id: str, data: CreateMessageSchema, session: Session =
responses={404: {"model": NotFoundSchema}},
)
def list_messages_for_consume(queue_id: str, limit: int = 10, session: Session = Depends(get_session)):
return MessageService.list_for_consume(queue_id=queue_id, limit=limit, session=session)
return MessageService(session=session).list_for_consume(queue_id=queue_id, limit=limit)


@app.put("/messages/{message_id}/ack", status_code=status.HTTP_204_NO_CONTENT, tags=["messages"])
def ack_message(message_id: str, session: Session = Depends(get_session)):
return MessageService.ack(id=message_id, session=session)
return MessageService(session=session).ack(id=message_id)


@app.put("/messages/{message_id}/nack", status_code=status.HTTP_204_NO_CONTENT, tags=["messages"])
def nack_message(message_id: str, session: Session = Depends(get_session)):
return MessageService.nack(id=message_id, session=session)
return MessageService(session=session).nack(id=message_id)


def run_server():
Expand Down
Loading