kopia lustrzana https://github.com/bugout-dev/moonstream
Correct auth for local redis
rodzic
5eca0fb57f
commit
016d9129ae
|
@ -1,17 +1,19 @@
|
|||
import os
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from redis import ConnectionPool, Redis
|
||||
from redis import asyncio as aioredis
|
||||
|
||||
from .settings import ENGINE_REDIS_URI
|
||||
from .settings import ENGINE_REDIS_PASSWORD, ENGINE_REDIS_URL
|
||||
|
||||
REDIS_CONFIG_CORS_KEY = "configs:cors:engineapi"
|
||||
|
||||
|
||||
def create_redis_client() -> Redis:
|
||||
rc_pool = ConnectionPool.from_url(
|
||||
url=ENGINE_REDIS_URI, max_connections=10, decode_responses=True
|
||||
url=f"redis://:{ENGINE_REDIS_PASSWORD}@{ENGINE_REDIS_URL}",
|
||||
max_connections=10,
|
||||
decode_responses=True,
|
||||
socket_timeout=0.5,
|
||||
)
|
||||
return Redis(connection_pool=rc_pool)
|
||||
|
||||
|
@ -21,7 +23,10 @@ rc_client = create_redis_client()
|
|||
|
||||
def create_async_redis_client() -> Redis:
|
||||
rc_pool_async: ConnectionPool = aioredis.ConnectionPool.from_url(
|
||||
url=ENGINE_REDIS_URI, max_connections=10, decode_responses=True
|
||||
url=f"redis://:{ENGINE_REDIS_PASSWORD}@{ENGINE_REDIS_URL}",
|
||||
max_connections=10,
|
||||
decode_responses=True,
|
||||
socket_timeout=0.5,
|
||||
)
|
||||
|
||||
return aioredis.Redis(connection_pool=rc_pool_async)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import logging
|
||||
import os
|
||||
import warnings
|
||||
from typing import Set
|
||||
from typing import Optional, Set
|
||||
|
||||
from bugout.app import Bugout
|
||||
from bugout.data import BugoutUser
|
||||
|
@ -35,7 +35,8 @@ for o_raw in RAW_ORIGINS_LST:
|
|||
BUGOUT_RESOURCE_TYPE_APPLICATION_CONFIG = "application-config"
|
||||
BUGOUT_REQUEST_TIMEOUT_SECONDS = 5
|
||||
|
||||
ENGINE_REDIS_URI = os.environ.get("ENGINE_REDIS_URI")
|
||||
ENGINE_REDIS_URL = os.environ.get("ENGINE_REDIS_URL")
|
||||
ENGINE_REDIS_PASSWORD = os.environ.get("ENGINE_REDIS_PASSWORD")
|
||||
|
||||
# Open API documentation path
|
||||
DOCS_TARGET_PATH = os.environ.get("DOCS_TARGET_PATH", "docs")
|
||||
|
@ -193,8 +194,9 @@ MOONSTREAM_ADMIN_ACCESS_TOKEN = os.environ.get("MOONSTREAM_ADMIN_ACCESS_TOKEN",
|
|||
if MOONSTREAM_ADMIN_ACCESS_TOKEN == "":
|
||||
raise ValueError("MOONSTREAM_ADMIN_ACCESS_TOKEN environment variable must be set")
|
||||
|
||||
MOONSTREAM_ADMIN_USER: Optional[BugoutUser] = None
|
||||
try:
|
||||
MOONSTREAM_ADMIN_USER: BugoutUser = bugout_client.get_user(
|
||||
MOONSTREAM_ADMIN_USER = bugout_client.get_user(
|
||||
token=MOONSTREAM_ADMIN_ACCESS_TOKEN,
|
||||
)
|
||||
except Exception as err:
|
||||
|
|
|
@ -9,7 +9,8 @@ export ENGINE_DB_URI="postgresql://<username>:<password>@<db_host>:<db_port>/<db
|
|||
export ENGINE_DB_URI_READ_ONLY="postgresql://<username>:<password>@<db_host>:<db_port>/<db_name>"
|
||||
export MOONSTREAM_ADMIN_ACCESS_TOKEN="<admin access token>"
|
||||
export MOONSTREAM_APPLICATION_ID="<moonstream application id>"
|
||||
export ENGINE_REDIS_URI="redis://localhost:6380"
|
||||
export ENGINE_REDIS_PASSWORD="<redis_requirepass_password>"
|
||||
export ENGINE_REDIS_URL="localhost:6380"
|
||||
|
||||
# Web3 Provider URIs
|
||||
export MOONSTREAM_ETHEREUM_WEB3_PROVIDER_URI="<JSON_RPC_API_URL>"
|
||||
|
|
Ładowanie…
Reference in New Issue