feat: add messagequeue api

This commit is contained in:
2024-09-11 07:22:55 +02:00
parent 99174939f5
commit aae388897e
11 changed files with 183 additions and 5 deletions

27
include/api.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef SCI_API_H
#define SCI_API_H
// Start the api. This will also trigger an "sci started" event.
// Note that this is a blocking call.
void* api_start(void*);
// Fork the process and have the child run the api.
void api_start_p();
// Destroy all listeners and release the message queue.
void api_destroy();
// Post a newline-separated string with pipeline_id entries
// of the currently running pipelines on the message queue.
void api_list_running_pipelines();
// Trigger a pipeline started event.
void api_pipeline_started(const char* pipeline_id, const char* name);
// Trigger a pipeline ended event.
void api_pipeline_ended(const char* pipeline_id, const char* name, int exit_code);
// Trigger an api started event.
void api_started();
#endif // !SCI_API_H

View File

@ -36,12 +36,13 @@ typedef struct {
char* command;
} pipeline_event;
// create a new pipeline_conf struct instance based on a configuration line.
// create a new `pipeline_conf` struct instance based on a configuration line.
optional_pipeline_conf pipeline_create(const char* config_line);
void pipeline_event_destroy(pipeline_event* ev);
void pipeline_destroy(pipeline_conf* conf);
void pipeline_register(pthread_t thread);
void pipeline_loop();
void pipeline_cancel();
int pipeline_count();
#endif

View File

@ -42,6 +42,8 @@ void per_line(const char* file, line_handler handler);
char* join(const char* a, const char* b);
char* join3(const char* a, const char* b, const char* c);
char* join4(const char* a, const char* b, const char* c, const char* d);
char* join5(const char* a, const char* b, const char* c, const char* d, const char* e);
char* join6(const char* a, const char* b, const char* c, const char* d, const char* e, const char* f);
const char* skip_arg(const char* cp);
char* skip_spaces(const char* str);