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

0.3.5 update #1048

Merged
merged 8 commits into from
Dec 13, 2023
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
8 changes: 7 additions & 1 deletion .github/workflows/update_release_notes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ jobs:
TAG_NAME: ${{ github.ref_name }}
BRANCH_NAME: update-release-notes-${{ github.ref_name }}
steps:
- name: Configure Git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"

- name: Checkout repository
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -53,8 +58,9 @@ jobs:
with:
token: ${{ steps.generate-token.outputs.token }}
branch: ${{ env.BRANCH_NAME }}
base: "main" # The branch you want to merge into
title: "Update Release Notes for ${{ env.TAG_NAME }}"
commit-message: "Update Release Notes for ${{ env.TAG_NAME }}"
body: "This is an automated pull request to update the release notes for ${{ env.TAG_NAME }}"
base: "main" # The branch you want to merge into
labels: documentation
reviewers: davorrunje, Lancetnik, kumaranvpl, sternakt
2 changes: 1 addition & 1 deletion docs/create_api_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from types import FunctionType, ModuleType
from typing import Any, List, Optional, Tuple, Type, Union


API_META = (
"# 0.5 - API\n"
"# 2 - Release\n"
Expand Down Expand Up @@ -294,6 +293,7 @@ def create_api_docs(

(docs_dir / "SUMMARY.md").write_text(summary)


if __name__ == "__main__":
root = Path(__file__).resolve().parent
create_api_docs(root, "faststream")
6 changes: 6 additions & 0 deletions docs/docs/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
search:
exclude: true
---
- [Features](faststream.md)
- Tutorial
- [Getting Started](getting-started/index.md)
Expand Down Expand Up @@ -62,6 +66,7 @@
- [Acknowledgement](rabbit/ack.md)
- [Declare Queue/Exchange](rabbit/declare.md)
- [Message Information](rabbit/message.md)
- [Security Configuration](rabbit/security.md)
- [NATS](nats/index.md)
- Subscription
- [Direct](nats/examples/direct.md)
Expand Down Expand Up @@ -228,6 +233,7 @@
- handler
- [AsyncHandler](api/faststream/broker/handler/AsyncHandler.md)
- [BaseHandler](api/faststream/broker/handler/BaseHandler.md)
- [MultiLock](api/faststream/broker/handler/MultiLock.md)
- message
- [ABCStreamMessage](api/faststream/broker/message/ABCStreamMessage.md)
- [StreamMessage](api/faststream/broker/message/StreamMessage.md)
Expand Down
11 changes: 11 additions & 0 deletions docs/docs/en/api/faststream/broker/handler/MultiLock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# 0.5 - API
# 2 - Release
# 3 - Contributing
# 5 - Template Page
# 10 - Default
search:
boost: 0.5
---

::: faststream.broker.handler.MultiLock
8 changes: 4 additions & 4 deletions docs/docs/en/getting-started/serialization/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,19 @@ Next, let's define the schema for our message. You can either define it in the P
Or you can load the schema from an avsc file as:

``` python
{!> docs_src/getting_started/serialization/avro.py [ln:20] !}
{!> docs_src/getting_started/serialization/avro.py [ln:21] !}
```

The contents of the `person.avsc` file are:

```avro
``` avro
{!> docs_src/getting_started/serialization/person.avsc !}
```

Finally, let's use Avro's `schemaless_reader` and `schemaless_writer` to decode and encode messages in the `FastStream` app.

``` python linenums="1" hl_lines="1 3 25-28 31 40-42"
{!> docs_src/getting_started/serialization/avro.py !}
``` python linenums="1" hl_lines="1 3 15-18 21 30-32"
{!> docs_src/getting_started/serialization/avro.py [ln:1-9,23-45] !}
```

## Tips
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/en/kafka/Publisher/batch_publisher.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ Or you can decorate your processing function and return a batch of messages, as

The application in the example imelements both of these ways, so feel free to use whichever option fits your needs better.

!!! note
Also, you can publishes messages in batches right from a `broker` object: just call
`#!python broker.publish_batch("msg2", "msg2", topic="output_data")`

## Why Publish in Batches?

In the above example, we've explored how to leverage the `#!python @broker.publisher(...)` decorator to efficiently publish messages in batches using **FastStream** and **Kafka**. By following the two key steps outlined in the previous sections, you can significantly enhance the performance and reliability of your **Kafka**-based applications.
Expand Down
8 changes: 3 additions & 5 deletions docs/docs/en/kafka/security.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
# Kafka Security Configuration

# FastStream Kafka Security

This chapter discusses the security options available in FastStream and how to use them.
This chapter discusses the security options available in **FastStream** and how to use them.

## Security Objects

FastStream allows you to enhance the security of applications by using security objects when creating brokers. These security objects encapsulate security-related configurations and mechanisms. Security objects supported in FastStream are (More are planned in the future such as SASL OAuth):
**FastStream** allows you to enhance the security of applications by using security objects when creating brokers. These security objects encapsulate security-related configurations and mechanisms. Security objects supported in **FastStream** are (More are planned in the future such as SASL OAuth):

### 1. BaseSecurity Object

**Purpose:** The `BaseSecurity` object wraps `ssl.SSLContext` object and is used to enable SSL/TLS encryption for secure communication between FastStream services and external components such as message brokers.
**Purpose:** The `BaseSecurity` object wraps `ssl.SSLContext` object and is used to enable SSL/TLS encryption for secure communication between **FastStream** services and external components such as message brokers.

**Usage:**

Expand Down
27 changes: 27 additions & 0 deletions docs/docs/en/rabbit/security.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# FastStream RabbitMQ Security

This chapter discusses the security options available in **FastStream** and how to use them.

## Security Objects

**FastStream** allows you to enhance the security of **applications** by using security objects when creating brokers. These security objects encapsulate security-related configurations and mechanisms. Security objects supported in **FastStream** for **RabbitMQ** are:

### 1. BaseSecurity Object

**Purpose:** The `BaseSecurity` object wraps `ssl.SSLContext` object and is used to enable SSL/TLS encryption for secure communication between FastStream services and external components such as message brokers.

**Usage:**

```python linenums="1" hl_lines="6-7 9"
{!> docs_src/rabbit/security/basic.py !}
```

### 2. SASLPlaintext Object with SSL/TLS

**Purpose:** The `SASLPlaintext` object is used for authentication in SASL (Simple Authentication and Security Layer) plaintext mode. It allows you to provide a username and password for authentication.

**Usage:**

```python linenums="1" hl_lines="6-11 13"
{!> docs_src/rabbit/security/plaintext.py !}
```
14 changes: 6 additions & 8 deletions docs/docs/en/redis/security.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
# Kafka Security Configuration

# FastStream Redis Security

This chapter discusses the security options available in FastStream and how to use them.
This chapter discusses the security options available in **FastStream** and how to use them.

## Security Objects

FastStream allows you to enhance the security of applications by using security objects when creating brokers. These security objects encapsulate security-related configurations and mechanisms. Security objects supported in FastStream for Redis are:
**FastStream** allows you to enhance the security of **applications** by using security objects when creating brokers. These security objects encapsulate security-related configurations and mechanisms. Security objects supported in **FastStream** for **Redis** are:

### 1. BaseSecurity Object

**Purpose:** The `BaseSecurity` object wraps `ssl.SSLContext` object and is used to enable SSL/TLS encryption for secure communication between FastStream services and external components such as message brokers.

**Usage:**

```python linenums="1"
{!> docs_src/redis/basic_security/app.py [ln:1-11] !}
```python linenums="1" hl_lines="6-7 9"
{!> docs_src/redis/security/basic.py !}
```

### 2. SASLPlaintext Object with SSL/TLS
Expand All @@ -24,6 +22,6 @@ FastStream allows you to enhance the security of applications by using security

**Usage:**

```python linenums="1"
{!> docs_src/redis/plaintext_security/app.py [ln:1-11] !}
```python linenums="1" hl_lines="6-11 13"
{!> docs_src/redis/security/plaintext.py !}
```
5 changes: 5 additions & 0 deletions docs/docs/navigation_template.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
---
search:
exclude: true
---
- [Features](faststream.md)
- Tutorial
- [Getting Started](getting-started/index.md)
Expand Down Expand Up @@ -62,6 +66,7 @@
- [Acknowledgement](rabbit/ack.md)
- [Declare Queue/Exchange](rabbit/declare.md)
- [Message Information](rabbit/message.md)
- [Security Configuration](rabbit/security.md)
- [NATS](nats/index.md)
- Subscription
- [Direct](nats/examples/direct.md)
Expand Down
1 change: 1 addition & 0 deletions docs/docs_src/getting_started/serialization/avro.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

person_schema = fastavro.schema.load_schema("person.avsc")

# person_schema = ...
schema = fastavro.schema.parse_schema(person_schema)

async def decode_message(msg: KafkaMessage):
Expand Down
9 changes: 9 additions & 0 deletions docs/docs_src/rabbit/security/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import ssl

from faststream.rabbit import RabbitBroker
from faststream.security import BaseSecurity

ssl_context = ssl.create_default_context()
security = BaseSecurity(ssl_context=ssl_context)

broker = RabbitBroker(security=security)
13 changes: 13 additions & 0 deletions docs/docs_src/rabbit/security/plaintext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import ssl

from faststream.rabbit import RabbitBroker
from faststream.security import SASLPlaintext

ssl_context = ssl.create_default_context()
security = SASLPlaintext(
ssl_context=ssl_context,
username="admin",
password="password",
)

broker = RabbitBroker(security=security)
17 changes: 0 additions & 17 deletions docs/docs_src/redis/plaintext_security/app.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import ssl

from faststream import FastStream
from faststream.redis import RedisBroker
from faststream.security import BaseSecurity

ssl_context = ssl.create_default_context()
security = BaseSecurity(ssl_context=ssl_context)

broker = RedisBroker(security=security)
app = FastStream(broker)


@broker.publisher("test_2")
@broker.subscriber("test_1")
async def test_topic(msg: str) -> str:
pass
13 changes: 13 additions & 0 deletions docs/docs_src/redis/security/plaintext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import ssl

from faststream.redis import RedisBroker
from faststream.security import SASLPlaintext

ssl_context = ssl.create_default_context()
security = SASLPlaintext(
ssl_context=ssl_context,
username="admin",
password="password",
)

broker = RedisBroker(security=security)
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

=== "NATS"

```python linenums="1" hl_lines="5-6 16 18-19"
```python linenums="1" hl_lines="4-5 15 17-18"
{!> docs_src/integrations/fastapi/nats/multiple.py !}
```

=== "Redis"

```python linenums="1" hl_lines="5-6 16 18-19"
```python linenums="1" hl_lines="4-5 15 17-18"
{!> docs_src/integrations/fastapi/redis/multiple.py !}
```
2 changes: 1 addition & 1 deletion faststream/__about__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Simple and fast framework to create message brokers based microservices"""
__version__ = "0.3.4"
__version__ = "0.3.5"


INSTALL_YAML = """
Expand Down
5 changes: 5 additions & 0 deletions faststream/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
ANYIO_VERSION = parse(get_version("anyio"))
ANYIO_V3 = ANYIO_VERSION.major == 3


def is_test_env() -> bool:
return bool(os.getenv("PYTEST_CURRENT_TEST"))


try:
from fastapi import __version__ as FASTAPI_VERSION

Expand Down
Loading