mirror of
https://github.com/kurbezz/discord-bot.git
synced 2025-12-08 09:30:44 +01:00
Read Temporal URL from config
Add TEMPOLAR_URL default ("temporal:7233") to Config and use
config.TEMPOLAR_URL when connecting the Temporal client. Also import
config in temporal module and remove a duplicate httpx import.
This commit is contained in:
@@ -1,8 +1,7 @@
|
|||||||
|
from httpx import Client
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from pydantic_settings import BaseSettings
|
from pydantic_settings import BaseSettings
|
||||||
|
|
||||||
from httpx import Client
|
|
||||||
|
|
||||||
|
|
||||||
class Settings(BaseSettings):
|
class Settings(BaseSettings):
|
||||||
VAULT_HOST: str
|
VAULT_HOST: str
|
||||||
@@ -35,6 +34,8 @@ class Config(BaseModel):
|
|||||||
|
|
||||||
OPENAI_API_KEY: str
|
OPENAI_API_KEY: str
|
||||||
|
|
||||||
|
TEMPOLAR_URL: str = "temporal:7233"
|
||||||
|
|
||||||
|
|
||||||
def get_config() -> Config:
|
def get_config() -> Config:
|
||||||
settings = Settings() # type: ignore
|
settings = Settings() # type: ignore
|
||||||
@@ -45,7 +46,7 @@ def get_config() -> Config:
|
|||||||
headers={
|
headers={
|
||||||
"X-Vault-Token": settings.VAULT_TOKEN,
|
"X-Vault-Token": settings.VAULT_TOKEN,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
from temporalio.client import Client
|
from temporalio.client import Client
|
||||||
from temporalio.contrib.pydantic import pydantic_data_converter
|
from temporalio.contrib.pydantic import pydantic_data_converter
|
||||||
|
|
||||||
|
from core.config import config
|
||||||
|
|
||||||
|
|
||||||
async def get_client() -> Client:
|
async def get_client() -> Client:
|
||||||
return await Client.connect(
|
return await Client.connect(
|
||||||
"temporal:7233",
|
config.TEMPOLAR_URL, namespace="default", data_converter=pydantic_data_converter
|
||||||
namespace="default",
|
|
||||||
data_converter=pydantic_data_converter
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user