> ## Documentation Index
> Fetch the complete documentation index at: https://alibi.itsdote.tech/llms.txt
> Use this file to discover all available pages before exploring further.

# alibi_sdk.offline_queue

> Offline queue — generated from python/alibi_sdk source.

Offline control-plane queue — buffer uploads when CP is unreachable.

*Source:* [`python/alibi_sdk/alibi_sdk/offline_queue.py`](https://github.com/valid22/alibi-ai/blob/main/python/alibi_sdk/alibi_sdk/offline_queue.py)

## `QueuedRequest`

**Attributes**

| Name | Type |
| - | - |
| `id` | `str` |
| `method` | `str` |
| `path` | `str` |
| `json_body` | `Any` |
| `enqueued_at` | `float` |
| `attempts` | `int` |
| `last_error` | `Optional[str]` |

#### `to_dict`

```python theme={null}
def to_dict() -> dict[str, Any]
```

**Returns**

`dict[str, Any]`

#### `from_dict`

```python theme={null}
def from_dict(cls, data: dict[str, Any]) -> 'QueuedRequest'
```

**Parameters**

| Name | Type |
| - | - |
| `cls` | `—` |
| `data` | `dict[str, Any]` |

**Returns**

`'QueuedRequest'`

## `FlushResult`

**Attributes**

| Name | Type |
| - | - |
| `flushed` | `int` |
| `remaining` | `int` |
| `errors` | `list[str]` |

## `OfflineQueue`

FIFO queue of CP write operations.

Optional disk persistence via `path` / ALIBI\_OFFLINE\_QUEUE\_PATH so
buffered steps survive process restart.

#### `__init__`

```python theme={null}
def __init__(path: Optional[str] = None, max_size: Optional[int] = None) -> None
```

**Parameters**

| Name | Type |
| - | - |
| `path` | `Optional[str]` |
| `max_size` | `Optional[int]` |

**Returns**

`None`

#### `snapshot`

```python theme={null}
def snapshot() -> list[QueuedRequest]
```

**Returns**

`list[QueuedRequest]`

#### `clear`

```python theme={null}
def clear() -> None
```

**Returns**

`None`

#### `enqueue`

```python theme={null}
def enqueue(method: str, path: str, json_body: Any = None) -> QueuedRequest
```

**Parameters**

| Name | Type |
| - | - |
| `method` | `str` |
| `path` | `str` |
| `json_body` | `Any` |

**Returns**

`QueuedRequest`

#### `flush`

```python theme={null}
async def flush(send: Callable[[str, str, Any], Awaitable[Any]], max_items: Optional[int] = None) -> FlushResult
```

Drain the queue FIFO via `send(method, path, json_body)`.

Stops on first failure so ordering of step uploads is preserved.

**Parameters**

| Name | Type |
| - | - |
| `send` | `Callable[[str, str, Any], Awaitable[Any]]` |
| `max_items` | `Optional[int]` |

**Returns**

`FlushResult`

### `get_offline_queue`

```python theme={null}
def get_offline_queue() -> OfflineQueue
```

**Returns**

`OfflineQueue`

### `reset_offline_queue_for_tests`

```python theme={null}
def reset_offline_queue_for_tests() -> None
```

**Returns**

`None`

### `offline_queue_enabled`

```python theme={null}
def offline_queue_enabled() -> bool
```

**Returns**

`bool`


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.