1/* @ajax/mesh-infer-svc: where each member's inference services listen
2 * (infer.rs Svc): its peer host and port (the base: a worker listens on
3 * base + its manifest's `param`) and the address members outside its subnet
4 * use (`k.lan` in the cluster config). */
5#ifndef MESH_INFER_SVC_H
6#define MESH_INFER_SVC_H
78#include <stdint.h>
910#define MESH_INFER_SVC_MAX 8
1112typedef struct {
13 uint32_t me, n;
14 char hosts[MESH_INFER_SVC_MAX][256];
15 char lans[MESH_INFER_SVC_MAX][256]; /* "" when the member has no k.lan */
16 uint16_t bases[MESH_INFER_SVC_MAX];
17} mesh_infer_svc;
1819/* A single meshd: its services on loopback, based at the control port (host:port). */
20int mesh_infer_svc_single(mesh_infer_svc *s, const char *control, char **err);
21/* A cluster member: `get(ctx, "k.peer")` per member, optional `k.lan` (NULL when absent). */
22int mesh_infer_svc_cluster(mesh_infer_svc *s, const char *(*get)(void *ctx, const char *key), void *ctx, uint32_t me,
23 uint32_t n, char **err);
24/* The address member `from` dials for member `to`'s service at `param`:
25 * loopback for itself; `to`'s peer host when the two peer hosts share a /24;
26 * else `to`'s lan host if it has one. Written to out (host:port). */
27void mesh_infer_svc_addr(const mesh_infer_svc *s, uint32_t from, uint32_t to, uint32_t param, char out[300]);
2829#endif