view seobeo/README.md @ 250:745fd127b2a1

[seobeo] Add bounded worker interface Co-authored-by: Copilot <[email protected]>
author MrJuneJune <me@mrjunejune.com>
date Tue, 04 Aug 2026 06:23:37 -0700
parents b818a4561a3c
children 609d3c6aff4e
line wrap: on
line source

# seobeo

HTTP client and networking library for C.

## Features

- HTTP/HTTPS client
- SSL/TLS support
- Async networking with libuv
- Joinable/detached tasks and bounded worker pools
- Snapshot testing utilities

## Files

| File | Description |
|------|-------------|
| `seobeo.h` | Public API header |
| `seobeo_internal.h` | Internal declarations |
| `s_http_client.c` | HTTP client implementation |
| `s_network.c` | Network utilities |
| `s_ssl.c` | SSL/TLS handling |
| `s_logging.c` | Logging utilities |
| `s_worker.c` | Thread and worker-pool implementation |
| `seobeo_worker.h` | Public worker API |
| `snapshot_creator.c/h` | Snapshot testing |
| `docs/` | Documentation |
| `examples/` | Usage examples |
| `tests/` | Unit tests |
| `os/` | OS-specific code |

## Usage

```c
#include "seobeo/seobeo.h"

// Make HTTP request
HttpResponse* resp = http_get("https://example.com");
// handle response...
http_response_free(resp);
```

## Building

```bash
bazel build //seobeo:seobeo
bazel test //seobeo:seobeo_test
```

## Background workers

Use a detached task for simple fire-and-forget work:

```c
void Convert_Image(void *p_context)
{
  Conversion *p_conversion = p_context;
  Run_FFmpeg(p_conversion);
}

Seobeo_Worker_Result result =
    Seobeo_Thread_Start_Detached(
        Convert_Image,
        p_conversion,
        free);
if (result != SEOBEO_WORKER_OK)
  free(p_conversion);
```

Use a bounded pool when requests can enqueue expensive work:

```c
Seobeo_Worker_Pool *p_pool =
    Seobeo_Worker_Pool_Create(2, 16);

Seobeo_Worker_Result result =
    Seobeo_Worker_Pool_Submit(
        p_pool,
        Convert_Image,
        p_conversion,
        free);

Seobeo_Worker_Pool_Shutdown(p_pool, TRUE);
Seobeo_Worker_Pool_Destroy(p_pool);
```

Submitting transfers context ownership only when it returns
`SEOBEO_WORKER_OK`. Cleanup runs after successful work and for queued tasks
discarded by a non-draining shutdown. User callbacks never run while the pool
mutex is held.

## Dependencies

- libuv (via //third_party/libuv)
- OpenSSL