O’REILLY Learning「Microservice APIs」6〜7

https://learning.oreilly.com/library/view/microservice-apis/9781617298417/

6 Building REST APIs with Python

This chapter covers
・Adding URL query parameters to an endpoint using FastAPI
・Disallowing the presence of unknown properties in a payload using pydantic and marshmallow
・Implementing a REST API using flask-smorest
・Defining validation schemas and URL query parameters using marshmallow

FastAPI
https://fastapi.tiangolo.com/ja/
Pythonの標準である型ヒントに基づいてPython 3.6 以降でAPI を構築するための、モダンで、高速(高パフォーマンス)な、Web フレームワークです。
・高速
・高速なコーディング
・少ないバグ
・直感的
・簡単
・短い
・堅牢性
・Standards-based:OpenAPIとの互換性

7 Service implementation patterns for microservices

This chapter covers
・How hexagonal architecture helps us design loosely coupled services
・Implementing the business layer for a microservice and implementing database models using SQLAlchemy
・Using the repository pattern to decouple the data layer from the business layer
・Using the unit of work pattern to ensure the atomicity of all transactions and using the dependency inversion principle to build software that is resilient to changes
・Using the inversion of control principle and the dependency injection pattern to decouple components that are dependent on each other

SQLAlchemy
https://www.sqlalchemy.org
Python SQL ツールキットと Object Relational Mapper で、アプリケーション開発者に SQL のフルパワーと柔軟性を提供。

依存関係逆転の原則 は、インターフェースを前提にソフトウェアを設計し、コンポーネントの低レベルの詳細の間に依存関係を作らないようにすることを勧めています。
依存関係逆転の原則とは、いったい何を逆転させるのでしょうか?
この原則は、ソフトウェアについての考え方を逆転させるものです。
インターフェイスを最初に考え、それに対して低レベルの詳細を構築することを推奨しています。

データアクセスのためのリポジトリパターン
ビジネスレイヤーをデータレイヤーから切り離すために、リポジトリパターンを使用する。
データストアにインメモリリストインタフェースを提供するソフトウェア開発パターン。

ユニットオブワークパターン
ビジネス・トランザクションのアトミック性を保証するデザイン・パターンであり、すべてのトランザクションが一度にコミットされ、どれかに障害が発生した場合はロールバックされることを保証している。

memoO'REILLY Learning

Posted by shi-n