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

Replace config/params dict with connection string syntax for all WebSocket backends #102

Closed
wants to merge 11 commits into from
Closed
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
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

Mangum is an adapter for using [ASGI](https://asgi.readthedocs.io/en/latest/) applications with AWS Lambda & API Gateway. It is intended to provide an easy-to-use, configurable wrapper for any ASGI application deployed in an AWS Lambda function to handle API Gateway requests and responses.

***Documentation***: https://erm.github.io/mangum/introduction/

## Features

- API Gateway support for [HTTP](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api.html), [REST](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-rest-api.html), and [WebSocket](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api.html) APIs.
Expand Down Expand Up @@ -37,11 +39,13 @@ pip install mangum
You can install the required dependencies for the WebSocket backends with one the following:

```shell
pip install mangum[aws]
pip install mangum[postgresql]
pip install mangum[redis]
pip install mangum[aws]==0.9.0b1
pip install mangum[postgresql]==0.9.0b1
pip install mangum[redis]==0.9.0b1
```

**Note**: WebSocket support is currently available only in the pre-release version `0.9.0b1`.

## Usage

The `Mangum` adapter class is designed to wrap any ASGI application, accepting various configuration options, returning a callable. It can wrap an application and be assigned to the handler:
Expand Down
2 changes: 1 addition & 1 deletion docs/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ The adapter class accepts the following optional arguments:

Specify whether or not to enable lifespan support. The adapter will automatically determine if lifespan is supported by the framework unless explicitly disabled.

- `log_level` : **str** (default="info")
- `log_level` : **str** (default=`"info"`)

Level parameter for the logger.

Expand Down
14 changes: 9 additions & 5 deletions docs/introduction.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
# Mangum

<a href="https://pypi.org/project/mangum/">
<img src="https://badge.fury.io/py/mangum.svg" alt="Package version">
<img src="https://badge.fury.io/py/mangum.svg" alt="Package version">
</a>
<a href="https://travis-ci.org/erm/mangum">
<img src="https://travis-ci.org/erm/mangum.svg?branch=master" alt="Build Status">
</a>
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/mangum.svg?style=flat-square">
<a href="https://pypi.org/project/mangum/">
<img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/mangum.svg?style=flat-square">
</a>

Mangum is an adapter for using [ASGI](https://asgi.readthedocs.io/en/latest/) applications with AWS Lambda & API Gateway. It is intended to provide an easy-to-use, configurable wrapper for any ASGI application deployed in an AWS Lambda function to handle API Gateway requests and responses.

Expand Down Expand Up @@ -37,11 +39,13 @@ pip install mangum
You can install the required dependencies for the WebSocket backends with one the following:

```shell
pip install mangum[aws]
pip install mangum[postgresql]
pip install mangum[redis]
pip install mangum[aws]==0.9.0b1
pip install mangum[postgresql]==0.9.0b1
pip install mangum[redis]==0.9.0b1
```

**Note**: WebSocket support is currently available only in the pre-release version `0.9.0b1`.

## Usage

The `Mangum` adapter class is designed to wrap any ASGI application, accepting various configuration options, returning a callable. It can wrap an application and be assigned to the handler:
Expand Down
33 changes: 17 additions & 16 deletions docs/websockets.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ handler = Mangum(

##### Required

- `ws_config` : ***dict*** (default=None)
- `ws_config` : **dict** *(required)*

Configuration mapping for a supported WebSocket backend.

Expand All @@ -48,6 +48,11 @@ The following required values need to be defined inside the `ws_config`:

Name of data source backend to use.


- `params` : **dict** *(required)*

Parameter mapping of required and optional arguments for the specified backend.

The following backends are currently supported:

- `dynamodb`
Expand All @@ -56,25 +61,21 @@ The following backends are currently supported:
- `redis`
- `sqlite3` (for local debugging)

- `params` : **str** *(required)*

The required and optional arguments provided to a specific backend.

##### Optional

The following optional values may be defined inside the `ws_config`:

- `api_gateway_endpoint_url` : **str**

The endpoint url to use in API Gateway Management API calls.. This is useful if you are debugging locally with a package such as [serverless-dynamodb-local](https://github.com/99xt/serverless-dynamodb-local).
The endpoint url to use in API Gateway Management API calls. This is useful if you are debugging locally with a package such as [serverless-offline](https://github.com/dherault/serverless-offline).

- `api_gateway_region_name` : **str**

The region name of the API Gateway that is managing the API connections.

### DynamoDB

The `DynamoDBStorageBackend` uses a [DynamoDB](https://aws.amazon.com/dynamodb/) table to store the connection details.
The `DynamoDBackend` uses a [DynamoDB](https://aws.amazon.com/dynamodb/) table to store the connection details.

#### Configuration

Expand Down Expand Up @@ -108,7 +109,7 @@ handler = Mangum(

### S3

The `S3Backend` uses an (S3)[https://aws.amazon.com/s3/](https://aws.amazon.com/s3/)] bucket as a key-value store to store the connection details.
The `S3Backend` uses an [Amazon S3](https://aws.amazon.com/s3/](https://aws.amazon.com/s3/) bucket as a key-value store to store the connection details.

#### Configuration

Expand Down Expand Up @@ -138,7 +139,7 @@ handler = Mangum(

### PostgreSQL

The `PostgreSQLBackend` requires (psycopg2)[https://github.com/psycopg/psycopg2] and access to a remote PostgreSQL database.
The `PostgreSQLBackend` requires [psycopg2](https://github.com/psycopg/psycopg2) and access to a remote PostgreSQL database.

#### Configuration

Expand All @@ -159,7 +160,7 @@ handler = Mangum(

##### Required

- `uri`: ***str*** *(required)*
- `uri`: **str** *(required)*
The connection string for the remote database.

If a `uri` is not supplied, then the following parameters are required:
Expand All @@ -182,21 +183,21 @@ If a `uri` is not supplied, then the following parameters are required:

##### Optional

- `port` : **str** (default="5432")
- `port` : **str** (default=`5432`)

Port number for Postgres database connection.

- `connect_timeout` **int** (default=5)
- `connect_timeout` **int** (default=`5`)

Timeout for database connection.

- `table_name` **str (default="connection")
- `table_name` **str (default=`"connection"`)

Table name to use to store WebSocket connections.

### Redis

The `RedisBackend` requires (redis-py)[https://github.com/andymccurdy/redis-py] and access to a Redis server.
The `RedisBackend` requires [redis-py](https://github.com/andymccurdy/redis-py) and access to a Redis server.

#### Configuration

Expand All @@ -222,15 +223,15 @@ handler = Mangum(

##### Optional

- `port` : **str** (default="6379")
- `port` : **str** (default=`6379`)

Port number for Redis server.

- `password` : **str**

Password for Redis server.

### SQlite3
### SQLite

The `sqlite3` backend uses a local [sqlite3](https://docs.python.org/3/library/sqlite3.html) database to store connection. It is intended for ***local*** debugging (with a package such as [Serverless Offline](https://github.com/dherault/serverless-offline)) and will ***not*** work in an AWS Lambda deployment.

Expand Down
9 changes: 4 additions & 5 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
site_name: Mangum
site_description: Serverless ASGI
site_description: AWS Lambda & API Gateway support for ASGI

theme:
name: 'material'
palette:
primary: 'brown'
accent: 'orange'
logo:
icon: 'cloud'


repo_name: erm/mangum
repo_url: https://github.com/erm/mangum
edit_uri: ""

nav:
- Introduction: 'index.md'
- Introduction: 'introduction.md'
- HTTP: 'http.md'
- WebSockets: 'websockets.md'

markdown_extensions:
- markdown.extensions.codehilite:
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ psycopg2
redis
testing.postgresql
testing.redis
sqlalchemy

# Docs
mkdocs
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def get_long_description():

setup(
name="mangum",
version="0.8.0",
version="0.9.0b1",
packages=find_packages(),
license="MIT",
url="https://github.com/erm/mangum",
Expand Down