Recent Releases of panini
panini - Release v0.8.4
Panini v0.8.4 Updates:
- Added ability to exclude specific subjects via config.
- Implemented fixes to Tracing Middleware for enhanced stability.
- Python
Published by artas728 almost 2 years ago
panini - Release v0.8.2
Summary:
This release introduces a new feature to enhance fail tolerance by ignoring exceptions in the main loop. It addresses an issue where any internal exception in NATS could lead to a crash of the entire application.
Changes Made:
Added an optional flag to enable/disable ignoring exceptions in the main loop. Implemented the flag as a parameter "ignore_exceptions" in the panini.App class. By default, the flag is enabled to ensure better fail tolerance.
Contributor:
@vlad-zverev
- Python
Published by artas728 over 2 years ago
panini - Introducing Panini v0.8.1: Enhanced Tracing Middleware for Improved Debugging and Performance Analysis
We're excited to announce the release of Panini v0.8.1, which brings a powerful new feature to our Python microframework: an enhanced Tracing Middleware. With this update, developers can easily trace their NATS microservices, allowing for more effective debugging and performance analysis.
The new Tracing Middleware leverages OpenTelemetry and integrates with Jaeger and Grafana, providing a comprehensive solution for monitoring your microservices. With custom span configurations, you can gain granular insights into your service operations and quickly identify bottlenecks or potential issues.
Key features in this release:
- Middleware for tracing @app.listen and app.publish/request actions
- Customizable trace attributes with SpanConfig
- Optional tracing for specific endpoints or publish/request tasks
- Easy integration with Jaeger and Grafana for trace visualization and analysis
- To get started with the new Tracing Middleware, check out the detailed documentation and example code at https://github.com/lwinterface/panini/tree/main/examples/tracingmiddlewarecompose .
A huge thank you to Igor Hwang @i2gor87 for contributing this fantastic feature to the Panini community!
Upgrade to Panini v0.8.1 today and enjoy the benefits of tracing and performance analysis for your NATS microservices!
- Python
Published by artas728 almost 3 years ago
panini - v0.8.0
New Updates to Panini v0.8.0
Parameter data_type "json" removed
In v0.8.0, we have removed the data type "json" from the parameter list, as it was referring to a jsonble Python object which was not the most explicit data type name. This may have caused confusion among developers, so we decided to remove it.
No Need to Declare "data_type" for "publish" and "request"
Panini detects a type of your message by itself.
New Parameter for “request” method - “responsedatatype”
For example: ```python subject = "a.b.c" message = {"param1": "value1"}
response: bytes = app.request(subject=subject, message=message, responsedatatype=bytes) ```
Panini Supports Dataclass as data_type
You may use it to serialize or validate your messages. I’ve tested it mostly with Pydantic dataclasses and also with Mashumaro. Example of usage is here:
```python import asyncio from panini import app as panini_app from pydantic import BaseModel
papp = paniniapp.App( servicename="validators", host="127.0.0.1", port=4222, )
log = papp.logger
class SubTestData(BaseModel): subkey1: str subkey2: int
class TestMessage(BaseModel): key1: str key2: int key3: float key4: list key5: dict key6: SubTestData key7: int = None key8: int = None
message = { "key1": "value1", "key2": 2, "key3": 3.0, "key4": [1, 2, 3, 4], "key5": {"1": 1, "2": 2, "3": 3, "4": 4, "5": 5}, "key6": {"subkey1": "1", "subkey2": 2, "3": 3, "4": 4, "5": 5}, "key7": None, }
@papp.task() async def publishdataclass(): for _ in range(10): messagedataclass = TestMessage(**message) await papp.publish( subject="some.publish.subject", message=message_dataclass )
@papp.listen("some.publish.subject", datatype=TestMessage) async def receivedataclass(msg): log.info(f"got message {msg.data}") await asyncio.sleep(1)
if name == "main": papp.start() ```
Experimental: Custom data_type with Callable Object
Panini supports any Callable object as data_type for custom processing. An example of usage is here:
```python from panini.exceptions import MessageSchemaError from panini import app as panini_app
app = paniniapp.App( servicename="testserializercallable", host="127.0.0.1", port=4222, )
def callable_validator(message): if type(message) is not dict: raise MessageSchemaError("type(data) is not dict") if "data" not in message: raise MessageSchemaError("'data' not in message") if type(message["data"]) is not int: raise MessageSchemaError("type(message['data']) is not int") if message["data"] < 0: raise MessageSchemaError(f"Value of field 'data' is {message['data']} that negative") message["data"] += 1 return message
@app.listen("testvalidator.foo", datatype=callable_validator) async def publish(msg): return {"success": True}
@app.listen("testvalidator.foo-with-error-cb", datatype=callable_validator) async def publish(msg): return {"success": True}
@app.listen("testvalidator.check") async def check(msg): try: message = callablevalidator(**msg.data) except MessageSchemaError: return {"success": False}
return {"success": True}
if name == "main": app.start()
```
Panini Validator Removed
If you need incoming message validation, we recommend to use dataclasses. Example of usage for Pydantic: https://pydantic-docs.helpmanual.io/usage/validators/
JetStream Syntax Support
Panini now supports JetStream syntax for streams. Examples
Removed validationerrorcb
The validation_error_cb parameter has been removed from the listen decorator.
- Python
Published by artas728 about 3 years ago
panini - Release v0.7.1
- added custom logger to panini app instead of internal one
- added headers to request
- added
validation_error_cbto listen decorator, usage: ``` async def customvalidationerror_cb(msg): # custom msg handling log.error(f"something wrong")
@app.listen("some.subject", validator=SomeValidator, validationerrorcb=customvalidationerror_cb) async def foo(msg): # msg handling if everything allright log.info(f"got message {msg.data}") ``` - experimental: do not wait for the received message to be processed, immediately take the next mesage
- Python
Published by artas728 almost 4 years ago
panini - Release v0.7.0
- Support NATS 2.0🎉. Now the panini stands on shoulders of nats-py v2.0.0
- Support Python 3.10
- Introducing onstarttask Example:
```python
from panini import app as panini_app
app = paniniapp.App( servicename="jspublish", host="127.0.0.1", port=4222, enablejs=True )
log = app.logger NUM = 0
@app.onstarttask() async def onstarttask(): await app.nats.jsclient.addstream(name="sample-stream-1", subjects=["test.*.stream"])
def getmessage(): return { "id": app.nats.client.clientid, }
@app.timertask(interval=2) async def publishperiodically(): subject = "test.app2.stream" message = get_message() global NUM NUM+=1 message['counter'] = NUM await app.publish(subject=subject, message=message) log.info(f"sent {message}")
if name == "main": app.start()
```
- Introducing minimal JetStream support Since Panini switched from asyncio-nats-client to nats-py, it has become possible to support one of the most important features of NATS 2.0 - JetStream. Panini v0.7.0 does not implement an interface to JetStream at the framework level. Instead, it is suggested to use directly nats-py. Example JetStream publisher microservice:
```python
from panini import app as panini_app
app = paniniapp.App( servicename="jslistenpush", host="127.0.0.1", port=4222, enable_js=True )
log = app.logger NUM = 0
@app.task() async def subscribetojsstreampush(): async def cb(msg): log.info(f"got JS message ! {msg.subject}:{msg.data}")
await app.nats.js_client.subscribe("test.*.stream", cb=cb, durable='consumer-1', stream="sample-stream-1")
if name == "main": app.start()
```
See more details in the documentation: https://panini.technology/JetStream.html A full-fledged extension of the Panini interface for JetStream is expected in the next versions of Panini.
- Python
Published by artas728 about 4 years ago
panini - Release v0.6.2
- Fixed bug: tasks don't works with HTTP server
- Fixed package incompatibility
- Python
Published by artas728 over 4 years ago
panini - Release v0.6.0
- Global refactoring
- Added new interface for pereodic tasks: @app.task(interval=1)
- Changed
listen_subject_only_if_includeparam in App to functionapp.add_filters(include, exclude) - Added ability to use all authorization methods from nats.py
- Added ability to establish connection to multiple NATS brokers
- Added start message when starting in terminal
- Python
Published by artas728 over 4 years ago
panini - Release v0.5.2
Added ability to use any parameters for aiohttp including ssl_context(for HTTPS)
- Python
Published by artas728 over 4 years ago
panini - Release v0.5.0
- Implemented AsyncTestClient for better testing experience
- Added listensubjectonlyifexclude parameter for excluding unnecessary subjects
- Python
Published by artas728 over 4 years ago
panini - Release v0.4.0
- fixed silent error if response type is list
- fixed TestClient
- added non-blocking request support for bytes messages
- added automatically generated changelog
- added pendingbyteslimit parameter to panini App for nats_client
- added isasync parameter to subscribenewsubject for natsclient
- added data types for dynamic subscription
- added test for long requests
- removed old 'aio' interface for nats_client & managers
- removed 'app_strategy' parameter
- Python
Published by artas728 over 4 years ago
panini - Release v0.3.1
- Fixed bug with no hinting for publish & request functions
- Removed 'app_strategy' parameter
- Removed old 'aio' interface for nats_client & managers
- Added auto unsubscribe to test_client waiting for panini to start
- Change ci test flow, add test on python v3.9 -major fixes in TestClient, changes in client.wait() function
- Added non-blocking request support for bytes messages
- Python
Published by artas728 over 4 years ago
panini - Release v0.3.0
- removed sync app connection strategy
- removed redis dependency
- minor fix
- Python
Published by artas728 almost 5 years ago
panini - Release v0.2.3
- Added CI/CD checks
- Moved from json to ujson
- Fixed logging bugs
- Fixed bug with emulator for windows
- Many minor bugs
- Python
Published by artas728 almost 5 years ago
panini - Release v0.2.2
- Added Emulator middlewares: ReaderEmulatorMiddleware & WriterEmulatorMiddleware
- Fixed Test client
- Minor fix: grafana dashboard default rate size changed from 1m to 15m
- Python
Published by artas728 almost 5 years ago
panini - Release v0.2.1
- Updated PrometheusMonitoringMiddleware(ex ListenPerformancePrometheusTracerMiddleware)
- Python
Published by artas728 almost 5 years ago
panini - Release v0.2.0
- Msg object instead of arguments subject and message in listener's callbacks
- Addition datatypes supported: bytes, str
- Added publish/request from another thread
- Added http-like middlewares
- Added default middleware that calculates processing time for incoming messages and sends it to pushgateway(prometheus)
- Added default middleware that sends alert message to some topic if service for NatsTimeoutError
- Changed default console logging level: WARNING -> INFO
- Added new examples
- Python
Published by artas728 almost 5 years ago
panini - Release. v0.1.3rc
- middlewares
- msg object for listeners
- publish from another thread
- request from another thread
- Python
Published by artas728 almost 5 years ago
panini - Release v0.1.2
Initial release: - basic architecture - publish messages to subject - subscribe to subject - request-response - request-response to another topic - tasks - periodic tasks - HTTP server - examples - tests
- Python
Published by artas728 almost 5 years ago