Add loop to map messages to workers

This commit is contained in:
2024-03-02 22:20:06 -05:00
parent bccd86ef38
commit 0134deeb56

View File

@@ -4,6 +4,8 @@
#include <zactor.h>
#include <guestfs.h>
#define STREQ(a, b) (strcmp((a), (b)) == 0)
void *worker_task;
char *endpoint(void);
@@ -25,14 +27,29 @@ int main(int argc, char **argv) {
for (int i = 0; i < worker_count; i++) {
char *path = strtok(argv[i+1], ":");
worker_map[i].name = strtok(NULL, ":");
zactor_new(worker_map[i].worker, (void *) &((struct { char* path; char *name; }) {.path = path, .name = name}));
zactor_new(worker_map[i].worker, path);
}
char *ep = endpoint();
zsock_t *frontend = zsock_new_router(ep);
free(ep);
while (true) {
zmsg_t *msg = zmsg_recv(frontend);
if (!msg) break;
// Find the worker with the given name.
zactor_t *worker = NULL;
for (int i = 0; i < worker_count; i++) {
}
if (worker) {
zmsg_send(&msg, zactor_sock(worker));
} else {
// The name specified does not exist.
}
}
return EXIT_SUCCESS;
}