madkote / Fastapi Plugins
Licence: mit
FastAPI framework plugins
Stars: ✭ 104
Programming Languages
Projects that are alternatives of or similar to Fastapi Plugins
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+37965.38%)
Mutual labels: openapi, openapi3, async, asyncio, json
Uvicorn Gunicorn Fastapi Docker
Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python 3.6 and above with performance auto-tuning. Optionally with Alpine Linux.
Stars: ✭ 1,014 (+875%)
Mutual labels: openapi, openapi3, async, json
Safrs
SqlAlchemy Flask-Restful Swagger Json:API OpenAPI
Stars: ✭ 255 (+145.19%)
Mutual labels: openapi, openapi3, json
Aiocache
Asyncio cache manager for redis, memcached and memory
Stars: ✭ 496 (+376.92%)
Mutual labels: asyncio, redis, memcached
Fennel
A task queue library for Python and Redis
Stars: ✭ 24 (-76.92%)
Mutual labels: async, asyncio, redis
Fastapi Gino Arq Uvicorn
High-performance Async REST API, in Python. FastAPI + GINO + Arq + Uvicorn (w/ Redis and PostgreSQL).
Stars: ✭ 204 (+96.15%)
Mutual labels: openapi3, async, asyncio
Full Stack Fastapi Couchbase
Full stack, modern web application generator. Using FastAPI, Couchbase as database, Docker, automatic HTTPS and more.
Stars: ✭ 243 (+133.65%)
Mutual labels: openapi, openapi3, json
Arq
Fast job queuing and RPC in python with asyncio and redis.
Stars: ✭ 695 (+568.27%)
Mutual labels: async, asyncio, redis
Aioredis Py
asyncio (PEP 3156) Redis support
Stars: ✭ 2,003 (+1825.96%)
Mutual labels: asyncio, redis, redis-sentinel
Fastonosql
FastoNoSQL is a crossplatform Redis, Memcached, SSDB, LevelDB, RocksDB, UnQLite, LMDB, ForestDB, Pika, Dynomite, KeyDB GUI management tool.
Stars: ✭ 1,001 (+862.5%)
Mutual labels: redis, memcached, redis-sentinel
Bricks
A standard library for microservices.
Stars: ✭ 142 (+36.54%)
Mutual labels: openapi3, json, redis
Rororo
Implement aiohttp.web OpenAPI 3 server applications with schema first approach.
Stars: ✭ 95 (-8.65%)
Mutual labels: openapi, openapi3, asyncio
Zapi
基于swoole的异步轻量级api框架,内部封装全套mysql、redis、mongo、memcached异步客户端,可以轻松start、reload、stop,加入数据库的查询模块,框架已经封装好近乎同步写法,底层异步调用。现已支持异步mysql、异步redis、异步http请求.
Stars: ✭ 245 (+135.58%)
Mutual labels: async, redis, memcached
HibiAPI
一个实现了多种常用站点的易用化API的程序 / A program that implements easy-to-use APIs for a variety of commonly used sites.
Stars: ✭ 427 (+310.58%)
Mutual labels: openapi, asyncio, openapi3
Zhttp
基于swoole的异步轻量级web框架,内部封装协程异步非阻塞全套mysql、redis、mongo、memcached连接池,可以轻松start、reload、stop,加入数据库的查询模块,框架已经封装好近乎同步写法,底层异步调用
Stars: ✭ 131 (+25.96%)
Mutual labels: async, redis, memcached
Full Stack Fastapi Postgresql
Full stack, modern web application generator. Using FastAPI, PostgreSQL as database, Docker, automatic HTTPS and more.
Stars: ✭ 7,635 (+7241.35%)
Mutual labels: openapi, openapi3, json
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+58.65%)
Mutual labels: json, redis, memcached
Spectral
A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI v2 & v3.
Stars: ✭ 876 (+742.31%)
Mutual labels: openapi, openapi3, json
Swurg
Parse OpenAPI documents into Burp Suite for automating OpenAPI-based APIs security assessments (approved by PortSwigger for inclusion in their official BApp Store).
Stars: ✭ 94 (-9.62%)
Mutual labels: openapi, openapi3, json
Kaizen Openapi Editor
Eclipse Editor for the Swagger-OpenAPI Description Language
Stars: ✭ 97 (-6.73%)
Mutual labels: openapi, openapi3, json
Plugins for FastAPI framework, high performance, easy to learn, fast to code, ready for production
fastapi-plugins
FastAPI framework plugins
Changes
See release notes
Installation
pip install fastapi-plugins
pip install fastapi-plugins[memcached]
pip install fastapi-plugins[all]
Plugins
Cache
Memcached
Valid variable are
-
MEMCACHED_HOST
- Memcached server host. -
MEMCACHED_PORT
- Memcached server port. Default is11211
. -
MEMCACHED_POOL_MINSIZE
- Minimum number of free connection to create in pool. Default is1
. -
MEMCACHED_POOL_SIZE
- Maximum number of connection to keep in pool. Default is10
. Must be greater than0
.None
is disallowed. -
MEMCACHED_PRESTART_TRIES
- The number tries to connect to the a Memcached instance. -
MEMCACHED_PRESTART_WAIT
- The interval in seconds to wait between connection failures on application start.
Example
# run with `uvicorn demo_app:app`
import typing
import fastapi
import pydantic
from fastapi_plugins.memcached import MemcachedSettings
from fastapi_plugins.memcached import MemcachedClient
from fastapi_plugins.memcached import memcached_plugin
from fastapi_plugins.memcached import depends_memcached
class AppSettings(OtherSettings, MemcachedSettings):
api_name: str = str(__name__)
app = fastapi.FastAPI()
config = AppSettings()
@app.get("/")
async def root_get(
cache: MemcachedClient=fastapi.Depends(depends_memcached),
) -> typing.Dict:
await cache.set(b'Hello', b'World')
await cache.get(b'Hello')
return dict(ping=await cache.ping())
@app.on_event('startup')
async def on_startup() -> None:
await memcached_plugin.init_app(app, config=config)
await memcached_plugin.init()
@app.on_event('shutdown')
async def on_shutdown() -> None:
await memcached_plugin.terminate()
Redis
Supports
- single instance
- sentinel
Valid variable are
-
REDIS_TYPE
-
redis
- single Redis instance -
sentinel
- Redis cluster
-
-
REDIS_URL
- URL to connect to Redis server. Exampleredis://user:[email protected]:6379/2
. Supports protocolsredis://
,rediss://
(redis over TLS) andunix://
. -
REDIS_HOST
- Redis server host. -
REDIS_PORT
- Redis server port. Default is6379
. -
REDIS_PASSWORD
- Redis password for server. -
REDIS_DB
- Redis db (zero-based number index). Default is0
. -
REDIS_CONNECTION_TIMEOUT
- Redis connection timeout. Default is2
. -
REDIS_POOL_MINSIZE
- Minimum number of free connection to create in pool. Default is1
. -
REDIS_POOL_MAXSIZE
- Maximum number of connection to keep in pool. Default is10
. Must be greater than0
.None
is disallowed. -
REDIS_SENTINELS
- List or a tuple of Redis sentinel addresses. -
REDIS_SENTINEL_MASTER
- The name of the master server in a sentinel configuration. Default ismymaster
. -
REDIS_PRESTART_TRIES
- The number tries to connect to the a Redis instance. -
REDIS_PRESTART_WAIT
- The interval in seconds to wait between connection failures on application start.
Example
# run with `uvicorn demo_app:app`
import typing
import aioredis
import fastapi
import pydantic
import fastapi_plugins
class AppSettings(OtherSettings, fastapi_plugins.RedisSettings):
api_name: str = str(__name__)
app = fastapi.FastAPI()
config = AppSettings()
@app.get("/")
async def root_get(
cache: aioredis.Redis=fastapi.Depends(fastapi_plugins.depends_redis),
) -> typing.Dict:
return dict(ping=await cache.ping())
@app.on_event('startup')
async def on_startup() -> None:
await fastapi_plugins.redis_plugin.init_app(app, config=config)
await fastapi_plugins.redis_plugin.init()
@app.on_event('shutdown')
async def on_shutdown() -> None:
await fastapi_plugins.redis_plugin.terminate()
Example with Docker Compose - Redis
version: '3.7'
services:
redis:
image: redis
ports:
- "6379:6379"
demo_fastapi_plugin:
image: demo_fastapi_plugin
environment:
- REDIS_TYPE=redis
- REDIS_HOST=redis
- REDIS_PORT=6379
ports:
- "8000:8000"
Example with Docker Compose - Redis Sentinel
version: '3.7'
services:
...
redis-sentinel:
ports:
- "26379:26379"
environment:
- ...
links:
- redis-master
- redis-slave
demo_fastapi_plugin:
image: demo_fastapi_plugin
environment:
- REDIS_TYPE=sentinel
- REDIS_SENTINELS=redis-sentinel:26379
ports:
- "8000:8000"
Scheduler
Simple schedule an awaitable job as a task.
-
long running
async
functions (e.g. monitor a file a system or events) - gracefully cancel spawned tasks
Valid variable are:
-
AIOJOBS_CLOSE_TIMEOUT
- The timeout in seconds before canceling a task. -
AIOJOBS_LIMIT
- The number of concurrent tasks to be executed. -
AIOJOBS_PENDING_LIMIT
- The number of pending jobs (waiting fr execution).
# run with `uvicorn demo_app:app`
import ...
import fastapi_plugins
class AppSettings(OtherSettings, fastapi_plugins.RedisSettings, fastapi_plugins.SchedulerSettings):
api_name: str = str(__name__)
app = fastapi.FastAPI()
config = AppSettings()
@app.post("/jobs/schedule/<timeout>")
async def job_post(
timeout: int=fastapi.Query(..., title='the job sleep time'),
cache: aioredis.Redis=fastapi.Depends(fastapi_plugins.depends_redis),
scheduler: aiojobs.Scheduler=fastapi.Depends(fastapi_plugins.depends_scheduler), # @IgnorePep8
) -> str:
async def coro(job_id, timeout, cache):
await cache.set(job_id, 'processing')
try:
await asyncio.sleep(timeout)
if timeout == 8:
raise Exception('ugly error')
except asyncio.CancelledError:
await cache.set(job_id, 'canceled')
except Exception:
await cache.set(job_id, 'erred')
else:
await cache.set(job_id, 'success')
job_id = str(uuid.uuid4()).replace('-', '')
await cache.set(job_id, 'pending')
await scheduler.spawn(coro(job_id, timeout, cache))
return job_id
@app.get("/jobs/status/<job_id>")
async def job_get(
job_id: str=fastapi.Query(..., title='the job id'),
cache: aioredis.Redis=fastapi.Depends(fastapi_plugins.depends_redis),
) -> typing.Dict:
status = await cache.get(job_id)
if status is None:
raise fastapi.HTTPException(
status_code=starlette.status.HTTP_404_NOT_FOUND,
detail='Job %s not found' % job_id
)
return dict(job_id=job_id, status=status)
@app.on_event('startup')
async def on_startup() -> None:
await fastapi_plugins.redis_plugin.init_app(app, config=config)
await fastapi_plugins.redis_plugin.init()
await fastapi_plugins.scheduler_plugin.init_app(app=app, config=config)
await fastapi_plugins.scheduler_plugin.init()
@app.on_event('shutdown')
async def on_shutdown() -> None:
await fastapi_plugins.scheduler_plugin.terminate()
await fastapi_plugins.redis_plugin.terminate()
... more already in progress ...
Development
Issues and suggestions are welcome through issues
License
This project is licensed under the terms of the MIT license.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].