Common utilities for EriPotter microservices
Project description
EriPotter Common
EriPotter 마이크로서비스를 위한 공통 유틸리티 패키지입니다.
기능
- 환경변수 기반 설정 관리
- 비동기 데이터베이스 연결 및 세션 관리
- FastAPI 확장 기능 (CORS, 헬스 체크 등)
- 보안 유틸리티 (비밀번호 해시화)
- 구조화된 로깅
설치
pip install eripotter-common
마이그레이션 가이드
기존 common/ 폴더에서 PyPI 패키지로 마이그레이션하는 방법:
- 기존
common/폴더 제거
rm -rf common/ # Linux/Mac
rd /s /q common # Windows
- PyPI 패키지 설치
pip install eripotter-common
- import 문 수정
# 이전
from common.config import settings
from common.db import get_db_engine
from common.security import hash_password
# 이후
from app import settings, db, hash_password
# 데이터베이스 사용
engine = await db.initialize()
async with db.session() as session:
# 데이터베이스 작업
pass
사용 예시
FastAPI 애플리케이션 생성
from app import create_app, settings, setup_logging, get_session, db, Base
# 로깅 설정
setup_logging()
# FastAPI 앱 생성
app = create_app(
title="My Service",
description="My Microservice"
)
# 모델 정의
class User(Base):
__tablename__ = "users"
# ... 모델 정의
# 라우터
@app.get("/users")
async def get_users(session = Depends(get_session)):
users = await session.query(User).all()
return users
환경변수 설정 (.env)
# 필수 설정
DATABASE_URL=postgresql+asyncpg://user:pass@localhost/db
SERVICE_NAME=my-service
# 선택적 설정
SQL_ECHO=true
LOG_LEVEL=INFO
JSON_LOGS=true
PORT=8000
개발 환경 설정
- 저장소 클론
git clone https://github.com/eripotter/eripotter-common.git
cd eripotter-common
- 가상환경 생성 및 활성화
python -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
- 개발 의존성 설치
pip install -e ".[test]"
- 테스트 실행
pytest
라이선스
MIT License - 자세한 내용은 LICENSE 파일을 참조하세요.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eripotter_common-0.1.0.tar.gz.
File metadata
- Download URL: eripotter_common-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
599eb65e362b25c18353aa7f26976f0daea8d1efee12c1f713e37779f25077f3
|
|
| MD5 |
59751e8163bf0e0bb3a4bc9758942d68
|
|
| BLAKE2b-256 |
1f276e43f92d875ae6337afc1c79ca3b0d0ad0367ea65cac824dd6f82688b928
|
Provenance
The following attestation bundles were made for eripotter_common-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on yeseung-2/eripotter-common
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eripotter_common-0.1.0.tar.gz -
Subject digest:
599eb65e362b25c18353aa7f26976f0daea8d1efee12c1f713e37779f25077f3 - Sigstore transparency entry: 433656937
- Sigstore integration time:
-
Permalink:
yeseung-2/eripotter-common@ca5a35cfcdc16505835f1df27d38cb923312adff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yeseung-2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@ca5a35cfcdc16505835f1df27d38cb923312adff -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file eripotter_common-0.1.0-py3-none-any.whl.
File metadata
- Download URL: eripotter_common-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc18a62fde485e1d836ea8ac480eb72b0cdced76a3c553a8d9ffcbd98e8b427d
|
|
| MD5 |
c7b95f3a403dd38c18c2d9cbf2fcbce3
|
|
| BLAKE2b-256 |
02c8043190210d7791e2b0e87b97725d9c32f384952ede5e46d9d1f1aed4e4df
|
Provenance
The following attestation bundles were made for eripotter_common-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on yeseung-2/eripotter-common
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eripotter_common-0.1.0-py3-none-any.whl -
Subject digest:
cc18a62fde485e1d836ea8ac480eb72b0cdced76a3c553a8d9ffcbd98e8b427d - Sigstore transparency entry: 433656959
- Sigstore integration time:
-
Permalink:
yeseung-2/eripotter-common@ca5a35cfcdc16505835f1df27d38cb923312adff -
Branch / Tag:
refs/heads/main - Owner: https://github.com/yeseung-2
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@ca5a35cfcdc16505835f1df27d38cb923312adff -
Trigger Event:
workflow_dispatch
-
Statement type: