# orca.ui.pools

> A module of morca's API.

Ops' Pools (`/ops/pools`): a row per machine of every pool runs are placed on (`orca.views.pools`), filtered by pool and kind with plain links, refreshed every 10 s from `/ops/pools/live`; a machine's own page (`/ops/pools/<kind>/<id>`); and `/api/pools`. With EC2 in view the page keeps Fleet's summary cards and charts (`orca.fleet`).

Pools replaced Fleet and Workers: `/ops/fleet` and `/ops/workers` redirect
here (`?kind=ec2`, `?kind=self-hosted`), and answer their old JSON to a
script that asks for JSON, as `/api/fleet` and `/api/workers` still do.

## Structs

### `PoolsAsk`

```mojo
struct PoolsAsk
```

What the page was asked for: `?pool=`, `?kind=`, `?range=`.

Implements: `Copyable`, `Movable`

Fields:

- `pool: String`
- `kind: String`
- `range: String`

#### `query`

```mojo
def query(self, with_range: Bool = True) -> String
```

The query that asks for it again (`?` included; empty for none).

#### `ec2`

```mojo
def ec2(self) -> Bool
```

Whether EC2 instances are in view: Fleet's cards and charts.

## Functions

### `pools_ask`

```mojo
def pools_ask(pool: String, kind: String, range: String) -> PoolsAsk
```

### `machine_href`

```mojo
def machine_href(m: Machine) -> String
```

### `machines_html`

```mojo
def machines_html(mut h: Html, ms: List[Machine])
```

The table of machines, a row each.

### `pools_json`

```mojo
def pools_json(ask: PoolsAsk, all: List[Machine]) -> String
```

### `pools_page`

```mojo
def pools_page(mut db: State, ask: PoolsAsk) -> Page
```

`/ops/pools` (and `/api/pools`): every machine of every pool.

### `pools_live`

```mojo
def pools_live(mut db: State, ask: PoolsAsk) -> Page
```

`/ops/pools/live`: the page's live part, as the fragment it refreshes from; it never ends.

### `pools_api`

```mojo
def pools_api(mut db: State, ask: PoolsAsk) -> Page
```

`/api/pools`: the page's machines as JSON, filtered as asked.

### `machine_page`

```mojo
def machine_page(mut db: State, kind: String, id: String) -> Page
```

`/ops/pools/<kind>/<id>`: a machine's facts, and its charts: an EC2 instance's samples (as its run's Machines card draws them), a worker's runs.

## Aliases

### `POOLS_EVERY`

```mojo
comptime POOLS_EVERY = 10
```

Seconds between refreshes of the machines, as Fleet's hosts and the Workers table were.
