Skip to content
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

Release: v0.17.0 #328

Merged
merged 3 commits into from
Jul 1, 2024
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
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ AWS_SUBNET_ID_3=subnet3
API_PORT=3001
LAMBDA_INVOKE_URL=http://explorer-service:3002/
DATA_AGGREGATOR_LAMBDA_NAME=hathor-explorer-service-dev-node_data_aggregator_handler
HATHOR_CORE_DOMAIN=node.explorer.testnet.hathor.network
HATHOR_NODES=node.explorer.testnet.hathor.network
HATHOR_CORE_URL=https://node.explorer.testnet.hathor.network
HATHOR_NODES=https://node.explorer.testnet.hathor.network
REDIS_KEY_PREFIX=hathor-explorer-service-dev
REDIS_HOST=redis
REDIS_PORT=6379
Expand All @@ -24,6 +24,7 @@ ELASTIC_USER=elastic
ELASTIC_PASSWORD=elastic_password
ELASTIC_INDEX=elastic_index
ELASTIC_TX_INDEX=elastic_tx_index
ELASTIC_TOKEN_BALANCES_INDEX=elastic_token_balances_index
ELASTIC_RESULTS_PER_PAGE=10
ELASTIC_SEARCH_TIMEOUT=25
WALLET_SERVICE_DB_USERNAME=wallet_service_user
Expand All @@ -34,4 +35,4 @@ WALLET_SERVICE_DB_NAME=wallet_service_ci
HEALTHCHECK_HATHOR_CORE_ENABLED=True
HEALTHCHECK_WALLET_SERVICE_DB_ENABLED=False
HEALTHCHECK_ELASTICSEARCH_ENABLED=False
HEALTHCHECK_REDIS_ENABLED=False
HEALTHCHECK_REDIS_ENABLED=False
12 changes: 6 additions & 6 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ jobs:
make deploy-lambdas-ci stage=dev
env:
API_PORT: 3001
HATHOR_CORE_DOMAIN: node.explorer.testnet.hathor.network
HATHOR_NODES: node1.testnet.hathor.network,node.explorer.testnet.hathor.network
HATHOR_CORE_URL: https://node.explorer.testnet.hathor.network
HATHOR_NODES: https://node1.testnet.hathor.network,https://node.explorer.testnet.hathor.network
REDIS_KEY_PREFIX: hathor-explorer-service-dev
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: 6379
Expand All @@ -112,8 +112,8 @@ jobs:
make deploy-lambdas-ci stage=testnet
env:
API_PORT: 3001
HATHOR_CORE_DOMAIN: node.explorer.testnet.hathor.network
HATHOR_NODES: node1.testnet.hathor.network,node.explorer.testnet.hathor.network
HATHOR_CORE_URL: https://node.explorer.testnet.hathor.network
HATHOR_NODES: https://node1.testnet.hathor.network,https://node.explorer.testnet.hathor.network
REDIS_KEY_PREFIX: hathor-explorer-service-testnet
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: 6379
Expand All @@ -134,8 +134,8 @@ jobs:
make deploy-lambdas-ci stage=mainnet
env:
API_PORT: 3001
HATHOR_CORE_DOMAIN: node.explorer.hathor.network
HATHOR_NODES: node.explorer.hathor.network,node1.mainnet.hathor.network,node2.mainnet.hathor.network
HATHOR_CORE_URL: https://node.explorer.hathor.network
HATHOR_NODES: https://node.explorer.hathor.network,https://node1.mainnet.hathor.network,https://node2.mainnet.hathor.network
REDIS_KEY_PREFIX: hathor-explorer-service-mainnet
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: 6379
Expand Down
2 changes: 1 addition & 1 deletion common/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def default(cls) -> "LogRenderer":

DATA_AGGREGATOR_LAMBDA_NAME = config("DATA_AGGREGATOR_LAMBDA_NAME", default=None)

HATHOR_CORE_DOMAIN = config("HATHOR_CORE_DOMAIN", default=None)
HATHOR_CORE_URL = config("HATHOR_CORE_URL", default=None)

HATHOR_NODES = config("HATHOR_NODES", default="", cast=Csv())
NODE_CACHE_TTL = config("NODE_CACHE_TTL", default=30)
Expand Down
26 changes: 13 additions & 13 deletions gateways/clients/hathor_core_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import aiohttp
import requests

from common.configuration import HATHOR_CORE_DOMAIN
from common.configuration import HATHOR_CORE_URL
from common.errors import HathorCoreTimeout
from common.logging import get_logger

Expand Down Expand Up @@ -33,13 +33,13 @@
class HathorCoreAsyncClient:
DEFAULT_TIMEOUT = 60 # seconds

def __init__(self, domain: Optional[str] = None) -> None:
def __init__(self, url: Optional[str] = None) -> None:
"""Client to make async requests

:param domain: domain where the requests will be made, defaults to config `hathor_core_domain`
:type domain: str, optional
:param url: url where the requests will be made, defaults to config `hathor_core_url`
:type url: str, optional
"""
self.domain = domain or HATHOR_CORE_DOMAIN
self.url = url or HATHOR_CORE_URL
self.log = logger.new(client="async")

async def get(
Expand All @@ -54,7 +54,7 @@ async def get(
:param timeout: timeout in seconds
:type timeout: Optional[float]
"""
url = parse.urljoin(f"https://{self.domain}", path)
url = parse.urljoin(self.url, path)

if not timeout:
timeout = self.DEFAULT_TIMEOUT
Expand Down Expand Up @@ -88,7 +88,7 @@ async def post(
:param timeout: timeout in seconds
:type timeout: Optional[float]
"""
url = parse.urljoin(f"https://{self.domain}", path)
url = parse.urljoin(self.url, path)

if not timeout:
timeout = self.DEFAULT_TIMEOUT
Expand All @@ -114,12 +114,12 @@ async def post(
class HathorCoreClient:
"""Client to make requests

:param domain: domain where the requests will be made, defaults to config `hathor_core_domain`
:type domain: str, optional
:param url: url where the requests will be made, defaults to config `hathor_core_url`
:type url: str, optional
"""

def __init__(self, domain: Optional[str] = None) -> None:
self.domain = domain or HATHOR_CORE_DOMAIN
def __init__(self, url: Optional[str] = None) -> None:
self.url = url or HATHOR_CORE_URL
self.log = logger.new(client="sync")

def get_text(
Expand All @@ -136,7 +136,7 @@ def get_text(
:return: request response
:rtype: Optional[str]
"""
url = parse.urljoin(f"https://{self.domain}", path)
url = parse.urljoin(self.url, path)

try:
response = requests.get(url, params=params, **kwargs)
Expand Down Expand Up @@ -172,7 +172,7 @@ def post_text(
:return: request response
:rtype: Optional[str]
"""
url = parse.urljoin(f"https://{self.domain}", path)
url = parse.urljoin(self.url, path)

try:
response = requests.post(url, json=body, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hathor-explorer-service",
"version": "0.16.1",
"version": "0.17.0",
"description": "Hathor Explorer Service Serverless deps",
"dependencies": {
"@apidevtools/swagger-cli": "^4.0.4",
Expand All @@ -16,7 +16,7 @@
"serverless-s3-local": "^0.8.1"
},
"scripts": {
"start": "serverless offline --printOutput"
"start": "serverless offline"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hathor-explorer-service"
version = "0.16.1"
version = "0.17.0"
description = ""
authors = ["Hathor Labs <[email protected]>"]
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ provider:
- ${env:AWS_SUBNET_ID_2}
- ${env:AWS_SUBNET_ID_3}
environment:
HATHOR_CORE_DOMAIN: ${env:HATHOR_CORE_DOMAIN}
HATHOR_CORE_URL: ${env:HATHOR_CORE_URL}
HATHOR_NODES: ${env:HATHOR_NODES}
REDIS_KEY_PREFIX: ${env:REDIS_KEY_PREFIX}
REDIS_HOST: ${env:REDIS_HOST}
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/gateways/clients/test_hathor_core_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_get_text(self, mocked_get):
expected = json.dumps({"success": True})
mocked_get.return_value.text = expected

client = HathorCoreClient("mydomain.com")
client = HathorCoreClient("https://mydomain.com")

result = client.get_text("/some/path", {"page": 2})

Expand All @@ -29,12 +29,12 @@ def test_get(self, mocked_get):
mocked_get.return_value.status_code = 200
mocked_get.return_value.text = json.dumps({"success": True})

client = HathorCoreClient("mydomain.com")
client = HathorCoreClient("http://mydomain.com")

result = client.get("/some/path", {"page": 2})

mocked_get.assert_called_once_with(
"https://mydomain.com/some/path", params={"page": 2}
"http://mydomain.com/some/path", params={"page": 2}
)
assert result
assert result["success"] is True
Expand All @@ -43,7 +43,7 @@ def test_get(self, mocked_get):
def test_get_no_200(self, mocked_get):
mocked_get.return_value.status_code = 404

client = HathorCoreClient("mydomain.com")
client = HathorCoreClient("https://mydomain.com")

result = client.get("/some/path", {"id": 42})

Expand All @@ -56,7 +56,7 @@ def test_get_no_200(self, mocked_get):
def test_get_raises(self, mocked_get):
mocked_get.side_effect = Exception("Boom!")

client = HathorCoreClient("mydomain.com")
client = HathorCoreClient("https://mydomain.com")

with raises(Exception, match=r"Boom!"):
result = client.get("/some/path", {"page": -12})
Expand All @@ -72,7 +72,7 @@ def test_get_raises(self, mocked_get):
def test_get_timeout(self, mocked_get):
mocked_get.side_effect = requests.ReadTimeout("reason")

client = HathorCoreClient("mydomain.com")
client = HathorCoreClient("https://mydomain.com")

with raises(Exception, match=r"timeout"):
client.get("/some/path", {"page": 69})
Expand Down
Loading