==> src/fleetd_int.h <==1/* mesh-fleetd's state, shared by the host callbacks (host.c), the reconciler's ops (recon.c), the
2 * bridges (fleetd.c) and the F_PERF hook (perf.c). */
3#ifndef MESH_FLEETD_INT_H
4#define MESH_FLEETD_INT_H
5
6#include "mesh/fleetd.h"
7#include "mesh/reconcile.h"
8#include "mesh/sched_report.h"
9
10#include <pthread.h>
11#include <stdatomic.h>
12#include <stdbool.h>
13#include <stdint.h>
14
15/* reconcile.rs's timeouts: a driver action, the retry, an image or view from a member, a placement. */
16#define FD_APPLY_MS 60000
17#define FD_FETCH_MS 35000
18#define FD_PLACE_MS 20000
19
20struct mesh_fleetd {
21 mesh_shared *sh;
22 mcc_topology topo;
23 char *state_path;
24 mpk_caps caps;
25 mpr_host host;
26 _Atomic(mpr_relay *) relay;
27 _Atomic bool starting; /* the fleet thread has not finished mpr_start yet */
28 _Atomic bool stop;
29 mrc_thread *rec;
30 pthread_t fleet_t, bridge_t, fwd_t[MESH_MAX_SYSTEMS];
31 bool fleet_on, bridge_on, fwd_on[MESH_MAX_SYSTEMS];
32 pthread_mutex_t mu;
33 /* The reconciler's status as the beats carry it (shared.rs ReconStatus), and its failures
34 * (recon_fail: the F_PERF's). */
35 uint64_t applied;
36 uint32_t status;
37 char *reason;
38 mst_outcome *moves;
39 size_t nmoves;
40 msr_fail *fails;
41 size_t nfails;
42 /* The lockstep group as the reconciler wants it (shared.rs GroupLocal's want, mirror, member). */
43 bool want_set, mirror, member;
44};
45
46/* The relay, waiting while the fleet thread is still starting it (NULL: it is not running). */
47mpr_relay *fd_relay(mesh_fleetd *f);
48
49mpr_host fd_host(mesh_fleetd *f);
50mrc_ops fd_recon_ops(mesh_fleetd *f);
51void fd_perf_set(mesh_fleetd *f);
52
53/* The answer to a bridged change: ctx is the waiter's mesh_reply (taken). */
54void fd_reply_fn(void *ctx, bool ok, const char *text);
55
56/* driver commands */
57bool fd_ask(mesh_shared *sh, mesh_cmd c, int64_t within_ms, mesh_result *out, char **err);
58mfl_actual *fd_inventory(mesh_shared *sh, int64_t within_ms, size_t *n);
59
60#endif