feat(mq): mq_runtime_clean in mq.h

This commit is contained in:
yangwei
2024-09-19 15:58:39 +08:00
parent ba13baaf34
commit 87944eb115
4 changed files with 289 additions and 157 deletions

View File

@@ -9,10 +9,6 @@ struct mq_schema;
struct mq_schema *mq_schema_new();
void mq_schema_free(struct mq_schema *s);
struct mq_runtime;
struct mq_runtime *mq_runtime_new(struct mq_schema *s);
void mq_runtime_free(struct mq_runtime *s);
typedef void mq_msg_free_cb_func(void *msg, void *msg_free_arg);
typedef void on_msg_cb_func(int topic_id, void *msg, void *on_msg_arg);
typedef void on_msg_dispatch_cb_func(int topic_id,
@@ -44,8 +40,14 @@ int mq_schema_destroy_topic(struct mq_schema *s, int topic_id);
int mq_schema_subscribe(struct mq_schema *s, int topic_id, on_msg_cb_func *on_msg_cb, void * on_msg_cb_arg);
int mq_runtime_publish_message(struct mq_runtime *rt, int topic_id, void *msg);
void mq_runtime_dispatch(struct mq_runtime *rt);
struct mq_runtime;
struct mq_runtime *mq_runtime_new(struct mq_schema *s);
void mq_runtime_free(struct mq_runtime *s);
// return 0 if success, otherwise return -1
int mq_runtime_publish_message(struct mq_runtime *rt, int topic_id, void *msg);// append message to pending queue
void mq_runtime_dispatch(struct mq_runtime *rt);// dispatch all message in pending queue, dispatched message will be append to dlq
void mq_runtime_clean(struct mq_runtime *rt); // free all message in dlq and pending queue, during this period, publish will be disabled
#ifdef __cplusplus
}