ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
edge_fetch.h File Reference

CDN edge-cache tier - async origin-fetch engine (PROTOCORE_ENABLE_EDGE_CACHE). More...

#include "protocore_config.h"

Go to the source code of this file.

Classes

struct  EdgeFetchTransport
 The origin transport, bound to protocore_client on the device and a mock in host tests. More...
struct  EdgeFetch
 One in-flight origin fetch (fixed-size, zero-heap). More...
struct  EdgeFetchNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...

Typedefs

typedef struct EdgeFetchTransport EdgeFetchTransport
 The origin transport, bound to protocore_client on the device and a mock in host tests.

Functions

 EMBED_ENUM_BYTE (EdgeFetchStatus, EDGE_FETCH_STATUS_PENDING, EDGE_FETCH_STATUS_DONE, EDGE_FETCH_STATUS_OVERSIZE, EDGE_FETCH_STATUS_FAILED,)
 Fetch progress.
 PROTOCORE_NS_LAYOUT (EdgeFetchNs, begin, pump, end, edge_resp_complete)
void protocore_edge_fetcher_begin (const uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t, const char *host, uint16_t port, const void *request, size_t req_len, uint32_t now_ms)
 Open the origin connection and park request; begin the fetch. Sets .
EdgeFetchStatus protocore_edge_fetcher_pump (uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t, uint32_t now_ms)
 Drain available bytes and advance. On DONE the response is parsed .
void protocore_edge_fetcher_end (const uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t)
 Release the transport connection (idempotent).
embed_bool protocore_edge_fetcher_edge_resp_complete (const uint8_t *work, const uint8_t *buf, size_t len, embed_bool conn_closed, size_t *head_len)
 Is the accumulated response complete? (headers terminated + body .

Variables

PROTOCORE_NS EdgeFetchNs EdgeFetcher PROTOCORE_UNUSED
 Module namespace.

Detailed Description

CDN edge-cache tier - async origin-fetch engine (PROTOCORE_ENABLE_EDGE_CACHE).

A non-blocking origin fetch: open + send a request over a transport seam, accumulate the response across poll loops into a bounded buffer, detect completion (Content-Length / chunked / connection close), then parse it with the proven http_client codec. Pumped from the server poll loop so a miss or revalidation never stalls the worker. The transport seam is protocore_client on the device and a mock in host tests. Zero heap; the buffer is fixed (PROTOCORE_EDGE_FETCH_BUF).

work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.

Author
Douglas Quigg (dstroy0)
Date
2026

Definition in file edge_fetch.h.

Typedef Documentation

◆ EdgeFetchTransport

typedef struct EdgeFetchTransport EdgeFetchTransport

The origin transport, bound to protocore_client on the device and a mock in host tests.

Function Documentation

◆ EMBED_ENUM_BYTE()

EMBED_ENUM_BYTE ( EdgeFetchStatus ,
EDGE_FETCH_STATUS_PENDING ,
EDGE_FETCH_STATUS_DONE ,
EDGE_FETCH_STATUS_OVERSIZE ,
EDGE_FETCH_STATUS_FAILED  )

Fetch progress.

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( EdgeFetchNs ,
begin ,
pump ,
end ,
edge_resp_complete  )

◆ protocore_edge_fetcher_begin()

void protocore_edge_fetcher_begin ( const uint8_t * work,
EdgeFetch * f,
const EdgeFetchTransport * t,
const char * host,
uint16_t port,
const void * request,
size_t req_len,
uint32_t now_ms )

Open the origin connection and park request; begin the fetch. Sets .

Parameters
workPROTOCORE_EDGE_FETCHER_BORROW bytes the caller took. Not held past the call.
fF
tT
hostHost
portPort
requestRequest
req_lenReq len
now_msNow ms

◆ protocore_edge_fetcher_pump()

EdgeFetchStatus protocore_edge_fetcher_pump ( uint8_t * work,
EdgeFetch * f,
const EdgeFetchTransport * t,
uint32_t now_ms )

Drain available bytes and advance. On DONE the response is parsed .

Parameters
workPROTOCORE_EDGE_FETCHER_BORROW bytes the caller took. Not held past the call.
fF
tT
now_msNow ms
Returns
The EdgeFetchStatus.

◆ protocore_edge_fetcher_end()

void protocore_edge_fetcher_end ( const uint8_t * work,
EdgeFetch * f,
const EdgeFetchTransport * t )

Release the transport connection (idempotent).

Parameters
workPROTOCORE_EDGE_FETCHER_BORROW bytes the caller took. Not held past the call.
fF
tT

◆ protocore_edge_fetcher_edge_resp_complete()

embed_bool protocore_edge_fetcher_edge_resp_complete ( const uint8_t * work,
const uint8_t * buf,
size_t len,
embed_bool conn_closed,
size_t * head_len )

Is the accumulated response complete? (headers terminated + body .

Parameters
workPROTOCORE_EDGE_FETCHER_BORROW bytes the caller took. Not held past the call.
bufBuf
lenLen
conn_closedConn closed
head_lenHead len
Returns
EMBED_TRUE on success.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS EdgeFetchNs EdgeFetcher PROTOCORE_UNUSED
Initial value:
.edge_resp_complete =
void protocore_edge_fetcher_begin(const uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t, const char *host, uint16_t port, const void *request, size_t req_len, uint32_t now_ms)
Open the origin connection and park request; begin the fetch. Sets .
EdgeFetchStatus protocore_edge_fetcher_pump(uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t, uint32_t now_ms)
Drain available bytes and advance. On DONE the response is parsed .
embed_bool protocore_edge_fetcher_edge_resp_complete(const uint8_t *work, const uint8_t *buf, size_t len, embed_bool conn_closed, size_t *head_len)
Is the accumulated response complete? (headers terminated + body .
void protocore_edge_fetcher_end(const uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t)
Release the transport connection (idempotent).

Module namespace.

Definition at line 123 of file edge_fetch.h.