Reorganizes imports

This commit is contained in:
Oleg Silkin 2019-05-21 07:54:52 -04:00
parent 39cebd1d6b
commit 5fe55ffaa5
10 changed files with 64 additions and 34 deletions

23
README.md Normal file
View file

@ -0,0 +1,23 @@
# LBRY Comment Server v2
This is a rewrite & update of the server
[written by myself and Grayson Burton here](https://github.com/ocornoc/lbry-comments)
A lot of the design is more or less the same with the original,
except this version focuses less on performance and more on scalability.
Rewritten with python because it's easier to adjust
and maintain. Instead of doing any multithreading,
this implementation just delegates a single
database connection for write operations.
The server was originally implemented with `aiohttp`
and uses `aiojobs` for scheduling write operations.
As pointed out by several people, Python is a dinosaur
in comparison to SQLite's execution speed,
so there is no sensibility in multi-threading from the
perspective of the server code itself.
The schema for

View file

@ -1,6 +1,3 @@
from lbry_comment_server.database import obtain_connection, validate_input, get_claim_comments
from lbry_comment_server.database import get_comments_by_id, get_comment_ids, create_comment
from lbry_comment_server.handles import api_endpoint
from lbry_comment_server.settings import config

View file

@ -1,10 +1,12 @@
import sqlite3
import aiosqlite
import typing
import re
import nacl.hash
import time
import logging import logging
import re
import sqlite3
import time
import typing
import aiosqlite
import nacl.hash
from lbry_comment_server.settings import config from lbry_comment_server.settings import config
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,13 +1,14 @@
import json import json
import asyncio
from aiojobs.aiohttp import atomic
from aiohttp import web
import logging import logging
from lbry_comment_server.database import obtain_connection
import asyncio
from aiohttp import web
from aiojobs.aiohttp import atomic
import lbry_comment_server.writes as writes
from lbry_comment_server import get_claim_comments from lbry_comment_server import get_claim_comments
from lbry_comment_server import get_comments_by_id, get_comment_ids from lbry_comment_server import get_comments_by_id, get_comment_ids
import lbry_comment_server.writes as writes from lbry_comment_server.database import obtain_connection
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,14 +1,14 @@
import asyncio
from aiohttp import web
import aiojobs.aiohttp
import logging import logging
import schema.db_helpers as helpers import aiojobs.aiohttp
import lbry_comment_server.writes as writes import asyncio
from lbry_comment_server.settings import config from aiohttp import web
from lbry_comment_server.handles import api_endpoint
from lbry_comment_server.database import obtain_connection
import lbry_comment_server.writes as writes
import schema.db_helpers as helpers
from lbry_comment_server.database import obtain_connection
from lbry_comment_server.handles import api_endpoint
from lbry_comment_server.settings import config
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG) logger.setLevel(logging.DEBUG)

View file

@ -1,6 +1,6 @@
import json import json
import pathlib
import logging import logging
import pathlib
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View file

@ -1,10 +1,11 @@
import aiojobs
import atexit import atexit
from asyncio import coroutine
import lbry_comment_server.database as db
import logging import logging
import aiojobs
from asyncio import coroutine
import lbry_comment_server.database as db
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

5
requirements.txt Normal file
View file

@ -0,0 +1,5 @@
faker
asyncio
aiohttp
aiojobs
aiosqlite

View file

@ -1,10 +1,10 @@
from random import randint from random import randint
import faker import faker
from faker.providers import internet from faker.providers import internet
from faker.providers import lorem from faker.providers import lorem
from faker.providers import misc from faker.providers import misc
import lbry_comment_server.database as db import lbry_comment_server.database as db
import schema.db_helpers as schema import schema.db_helpers as schema
from lbry_comment_server.settings import config from lbry_comment_server.settings import config

View file

@ -1,11 +1,12 @@
import asyncio
from asyncio.runners import _cancel_all_tasks # type: ignore
import unittest import unittest
from asyncio.runners import _cancel_all_tasks # type: ignore
from unittest.case import _Outcome from unittest.case import _Outcome
import lbry_comment_server.database as db
from lbry_comment_server import config import asyncio
import lbry_comment_server.database as db
import schema.db_helpers as schema import schema.db_helpers as schema
from lbry_comment_server.settings import config
class AsyncioTestCase(unittest.TestCase): class AsyncioTestCase(unittest.TestCase):