4#ifndef PROTOCORE_EDGE_FETCH_H
5#define PROTOCORE_EDGE_FETCH_H
36 int (*
open)(
void *
ctx,
const char *host, uint16_t port, uint32_t timeout_ms);
39 size_t (*
read)(
void *
ctx,
int cid, uint8_t *buf,
size_t cap);
93 uint16_t port,
const void *request,
size_t req_len, uint32_t now_ms);
126 .edge_resp_complete =
PROTO_ENUM_PACKED
Application protocol spoken on a listener port or connection slot.
#define PROTOCORE_EDGE_FETCH_BUF
PROTOCORE_NS EdgeFetchNs EdgeFetcher PROTOCORE_UNUSED
Module namespace.
void protocore_edge_fetcher_end(uint8_t *work, EdgeFetch *f, const EdgeFetchTransport *t)
Release the transport connection (idempotent).
proto_bool protocore_edge_fetcher_edge_resp_complete(uint8_t *work, const uint8_t *buf, size_t len, proto_bool conn_closed, size_t *head_len)
Is the accumulated response complete? (headers terminated + body .
void protocore_edge_fetcher_begin(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 .
enum PROTO_ENUM_PACKED EdgeFetchStatus
Fetch progress.
@ EDGE_FETCH_STATUS_DONE
a complete response is parsed (status / body_off / body_len valid)
@ EDGE_FETCH_STATUS_PENDING
still receiving
@ EDGE_FETCH_STATUS_FAILED
connect / send / timeout / closed-before-complete
@ EDGE_FETCH_STATUS_OVERSIZE
response exceeded the buffer - not cacheable (caller passes through / fails open)
#define PROTOCORE_NS_LAYOUT(T,...)
Pin every dispatch slot of a table that is nothing but function pointers.
#define PROTOCORE_NS
Storage for a dispatch table. The const is load bearing.
Dispatch table. Addressed by offset, so the layout is asserted below.
void(* begin)(uint8_t *, EdgeFetch *, const EdgeFetchTransport *, const char *, uint16_t, const void *, size_t, uint32_t)
The origin transport, bound to protocore_client on the device and a mock in host tests.
proto_bool(* connected)(void *ctx, int cid)
step the open along; true once it is up
proto_bool(* send)(void *ctx, int cid, const void *data, size_t len)
proto_bool(* closed)(void *ctx, int cid)
true once the origin closed its side
size_t(* read)(void *ctx, int cid, uint8_t *buf, size_t cap)
0 = nothing available right now
int(* open)(void *ctx, const char *host, uint16_t port, uint32_t timeout_ms)
cid >= 0, or < 0 on failure
void(* close)(void *ctx, int cid)
One in-flight origin fetch (fixed-size, zero-heap).
proto_bool sent
the request reached the transport, so buf now takes the response
uint32_t got
bytes accumulated
uint32_t req_len
request bytes parked at the head of buf until the connection is up
int status
HTTP status (valid when DONE)
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS