# Async Darsman Account SDK

## Requirements

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

## Installation

Run the following command using pip:

```bash
pip install admac
```

## Sample code

```python
import asyncio
from dmmc import User

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

async def main():
    # Get one user using its identifier
    result = await user.fetch_one_by_id(
        identifier="b2f6c8e2-7e3a-4cb3-a58e-ef4e3f893708",
        timeout="3.5",              # Optional: override default timeout
        wait_for_ready=True         # Optional: wait for channel if not ready
    )
    print(result)

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

```

## Env example

```python
### === ASYNC ACCOUNT SDK CONFIG === ###

# Server config
ASYNC_ACCOUNT_SDK_HOST=127.0.0.1
ASYNC_ACCOUNT_SDK_PORT=50051
ASYNC_ACCOUNT_SDK_API_KEY=your_api_key_here

# Graceful shutdown
ASYNC_ACCOUNT_SDK_CHANNEL_SHUTDOWN_GRACE=10

# Keepalive (for long-lived connection health checks)
ASYNC_ACCOUNT_SDK_KEEPALIVE_TIME_MS=60000
ASYNC_ACCOUNT_SDK_KEEPALIVE_TIMEOUT_MS=5000
ASYNC_ACCOUNT_SDK_KEEPALIVE_PERMIT_WITHOUT_CALLS=1
ASYNC_ACCOUNT_SDK_MAX_PINGS_WITHOUT_DATA=0

# Retry policy
ASYNC_ACCOUNT_SDK_MAX_ATTEMPTS=5  # more than 5 isn't allowed by grpc
ASYNC_ACCOUNT_SDK_INITIAL_BACKOFF=0.1s
ASYNC_ACCOUNT_SDK_MAX_BACKOFF=1.5s
ASYNC_ACCOUNT_SDK_BACKOFF_MULTIPLIER=2.0
ASYNC_ACCOUNT_SDK_RETRYABLE_STATUS_CODES=["UNAVAILABLE", "RESOURCE_EXHAUSTED", "ABORTED"]

# RPC-level configs
ASYNC_ACCOUNT_SDK_WAIT_FOR_READY=true
ASYNC_ACCOUNT_SDK_TIMEOUT=5.0
```
