-
Notifications
You must be signed in to change notification settings - Fork 1
asyncpg storage (not done yet) #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
codefather-labs
wants to merge
8
commits into
requestum-team:master
Choose a base branch
from
codefather-labs:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d2e6b45
not done yet
codefather-labs 38e6fdc
not done yet
codefather-labs 4fbb0b6
pg impl conflict fix
codefather-labs 19ebc6d
easy refactoring
codefather-labs d6b83f3
create_task refactoring
codefather-labs 777e6b9
AsyncPGStorage refactoring + AsyncPGConsumedTaskResult and AsyncPGTas…
codefather-labs 8c8b6fd
postgres pub/sub, + refactoring
codefather-labs 4fe6132
pull requests updates
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # pull official base image | ||
| FROM python:3.11.3-alpine as app | ||
|
|
||
| # set work directory | ||
| WORKDIR /usr/src/app | ||
|
|
||
| # set environment variables | ||
| ENV PYTHONDONTWRITEBYTECODE 1 | ||
| ENV PYTHONUNBUFFERED 1 | ||
|
|
||
| # install psycopg2 | ||
| RUN apk update \ | ||
| && apk add --virtual build-deps gcc python3-dev musl-dev \ | ||
| && apk add postgresql postgresql-contrib postgresql-dev \ | ||
| && pip install psycopg2 \ | ||
| && pip install -U pip setuptools wheel \ | ||
| && apk del build-deps | ||
|
|
||
| RUN apk update && apk add python3-dev \ | ||
| gcc \ | ||
| libc-dev \ | ||
| libffi-dev | ||
|
|
||
| # copy project | ||
| COPY . /usr/src/app/ | ||
|
|
||
| # install dependencies | ||
| RUN pip install --upgrade pip | ||
| RUN pip install pipenv | ||
| RUN pipenv install | ||
|
|
||
|
|
||
| EXPOSE $APP_PORT |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| [[source]] | ||
| url = "https://pypi.org/simple" | ||
| verify_ssl = true | ||
| name = "pypi" | ||
|
|
||
| [packages] | ||
| pydantic = "2.6" | ||
| aiohttp = "3.9" | ||
| asyncpg = "0.29" | ||
|
|
||
| [dev-packages] | ||
|
|
||
| [requires] | ||
| python_version = "3.11" | ||
| python_full_version = "3.11" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,21 @@ | ||
| # Task Manager | ||
| # Task Manager | ||
|
|
||
| ## Quick start | ||
| ```bash | ||
| # build | ||
| docker-compose build --no-cache | ||
| ``` | ||
| ```bash | ||
| # up | ||
| docker-compose up | ||
| ``` | ||
| It starts `synthetic_test.py` by default. | ||
|
|
||
|
|
||
| ## Docker env example | ||
| - POSTGRES_USER=task_manager | ||
| - POSTGRES_PASS=task_manager_password | ||
| - POSTGRES_NAME=task_manager | ||
| - POSTGRES_HOST=postgres | ||
| - POSTGRES_PORT=5432 | ||
| - POSTGRES_HOST_AUTH_METHOD=trust |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| version: '3' | ||
|
|
||
|
|
||
| services: | ||
| app: | ||
| # restart: always | ||
| volumes: | ||
| - .:/usr/src/app/ | ||
| env_file: .env | ||
| build: | ||
| context: . | ||
| dockerfile: Dockerfile | ||
|
|
||
| depends_on: | ||
| postgres: | ||
| condition: service_healthy | ||
| links: | ||
| - postgres | ||
| command: pipenv run python3 junk/synthetic_test.py asyncpg_storage | ||
|
|
||
| postgres: | ||
| image: postgres:15-alpine | ||
| container_name: "postgres" | ||
| volumes: | ||
| - .:/usr/src/app/ | ||
| - postgres_data:/var/lib/postgresql/data | ||
| env_file: | ||
| - .env | ||
| ports: | ||
| - "5432:5432" | ||
| working_dir: /usr/src/app/ | ||
| healthcheck: | ||
| test: [ "CMD-SHELL", "pg_isready -U task_manager" ] | ||
| interval: 1s | ||
| timeout: 10s | ||
| retries: 0 | ||
|
|
||
| volumes: | ||
| .: {} | ||
| postgres_data: {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| from dataclasses import dataclass | ||
|
|
||
|
|
||
| @dataclass | ||
| class ConsumedTask: | ||
| idn: str | ||
| topic: str | ||
| payload: dict | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| from .in_memory import InMemoryStorage | ||
| from .in_memory import InMemoryStorage | ||
| from .asyncpg_storage import AsyncPGStorage |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
if we want to move data types definitions to separate file, we should keep it in layer's package (task_manager.storage), for example we can consider next structure:
...or just keep it as it is in a single file for now
Uh oh!
There was an error while loading. Please reload this page.
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 think this will greatly disrupt the current structure. As I understand it,
task_manager.coreis a package of interfaces. I don’t see any point in transferring the storage interface fromcoretostoragespackage, since this is an implementations package