feat(stellar mq): add dispatch_cb per topic

This commit is contained in:
yangwei
2024-09-05 18:58:17 +08:00
parent a36865275d
commit b8b8bc1add
4 changed files with 119 additions and 125 deletions

View File

@@ -16,10 +16,13 @@ inline static void stellar_msg_free_default(void *msg, void *msg_free_arg __unus
if(msg)FREE(msg);
}
typedef void on_msg_cb_func(int topic_id, const void *msg, void *plugin_env);
typedef void on_msg_dispatch_cb_func(int topic_id, const void *msg, on_msg_cb_func* on_msg_cb, void *sub_plugin_env);
//return topic_id
int stellar_mq_create_topic(struct stellar *st, const char *topic_name, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
int stellar_mq_create_topic(struct stellar *st, const char *topic_name, on_msg_dispatch_cb_func *on_dispatch_cb, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
int stellar_mq_get_topic_id(struct stellar *st, const char *topic_name);
int stellar_mq_update_topic(struct stellar *st, int topic_id, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
int stellar_mq_update_topic(struct stellar *st, int topic_id, on_msg_dispatch_cb_func *on_dispatch_cb, stellar_msg_free_cb_func *msg_free_cb, void *msg_free_arg);
int stellar_mq_destroy_topic(struct stellar *st, int topic_id);
@@ -31,9 +34,9 @@ enum stellar_mq_priority
STELLAR_MQ_PRIORITY_MAX,
};
typedef void on_msg_cb_func(int topic_id, const void *msg, void *plugin_env);
//return 0 if success, otherwise return -1.
int stellar_mq_subscribe(struct stellar *st, int topic_id, on_msg_cb_func *plugin_on_msg_cb, int plugin_id);
int stellar_mq_subscribe(struct stellar *st, int topic_id, on_msg_cb_func *on_msg_cb, int plugin_id);
int stellar_mq_publish_message(struct stellar *st, int topic_id, void *msg);
int stellar_mq_publish_message_with_priority(struct stellar *st, int topic_id, void *msg, enum stellar_mq_priority priority);