Metadata-Version: 2.1
Name: dmnc
Version: 2.0.0
Summary: Notification center for Darsman Academy
Author: Ellnamin
Author-email: ellnamin.business@gmail.com

# Darsman Notification Center

Darsman Notification Center simply is a toolkit for sending messages using gRPC.

## Requirements

- Python (== 3.10)
- grpcio-tools (>= 1.62.1)
- pydantic (>= 2.7.0)


## Installation

Run the following command using pip:
```bash
pip install dmnc
```

## Sample code

```python
import asyncio
from dmnc import Notify

# see `Env example` for confgs, you may want to only fill host and port
notify = Notify()

async def main():
    # send discount for user
    await notify().send_discount(
        recipient="user@example.com",        # either email or phone number
        # recipient="09123456789",
        user_name="سامان",
        course="پایتون",
        support_phone_number="09123456789",
        discount_code="MX3EH98",
        discount_percentage=25,
        timeout="3.5",              # Optional: override default timeout
        wait_for_ready=True         # Optional: wait for channel if not ready
    )

if __name__ == "__main__":
    loop = asyncio.get_event_loop()
    loop.run_until_complete(main())

```

## Env example

```python
### === NOTIFICATION SDK CONFIG === ###

# Server config
NOTIFICATION_SDK_HOST=127.0.0.1
NOTIFICATION_SDK_PORT=50051

# Graceful shutdown
NOTIFICATION_SDK_CHANNEL_SHUTDOWN_GRACE=10

# Keepalive (for long-lived connection health checks)
NOTIFICATION_SDK_KEEPALIVE_TIME_MS=60000
NOTIFICATION_SDK_KEEPALIVE_TIMEOUT_MS=5000
NOTIFICATION_SDK_KEEPALIVE_PERMIT_WITHOUT_CALLS=1
NOTIFICATION_SDK_MAX_PINGS_WITHOUT_DATA=0

# Retry policy
NOTIFICATION_SDK_MAX_ATTEMPTS=5  # more than 5 isn't allowed by grpc
NOTIFICATION_SDK_INITIAL_BACKOFF=0.1s
NOTIFICATION_SDK_MAX_BACKOFF=1.5s
NOTIFICATION_SDK_BACKOFF_MULTIPLIER=2.0
NOTIFICATION_SDK_RETRYABLE_STATUS_CODES=["UNAVAILABLE", "RESOURCE_EXHAUSTED", "ABORTED"]

# RPC-level configs
NOTIFICATION_SDK_WAIT_FOR_READY=true
NOTIFICATION_SDK_TIMEOUT=5.0
```
