diff options
| author | yangwei <[email protected]> | 2024-09-05 18:58:17 +0800 |
|---|---|---|
| committer | yangwei <[email protected]> | 2024-09-05 18:58:17 +0800 |
| commit | b8b8bc1addbb66fcf2cd6d33ad5a2a1047e0a83e (patch) | |
| tree | 2b67347eb5a406a66b0b967241cff4a33bf8596d /include | |
| parent | a36865275d62bf878e9ad818d1863e4b098c435f (diff) | |
✨ feat(stellar mq): add dispatch_cb per topic
Diffstat (limited to 'include')
| -rw-r--r-- | include/stellar/stellar_mq.h | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/include/stellar/stellar_mq.h b/include/stellar/stellar_mq.h index 4780990..b2a5f44 100644 --- a/include/stellar/stellar_mq.h +++ b/include/stellar/stellar_mq.h @@ -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); |
