54 lines
1.8 KiB
C
54 lines
1.8 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
struct mq_schema;
|
|
struct mq_schema *mq_schema_new();
|
|
void mq_schema_free(struct mq_schema *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,
|
|
void *msg,
|
|
on_msg_cb_func* on_msg_cb,
|
|
void *on_msg_cb_arg,
|
|
void *dispatch_arg);
|
|
|
|
//return topic_id
|
|
int mq_schema_create_topic(struct mq_schema *s,
|
|
const char *topic_name,
|
|
on_msg_dispatch_cb_func *on_dispatch_cb,
|
|
void *on_dispatch_arg,
|
|
mq_msg_free_cb_func *msg_free_cb,
|
|
void *msg_free_arg);
|
|
|
|
int mq_schema_get_topic_id(struct mq_schema *s, const char *topic_name);
|
|
|
|
int mq_schema_update_topic(struct mq_schema *s,
|
|
int topic_id,
|
|
on_msg_dispatch_cb_func *on_dispatch_cb,
|
|
void *on_dispatch_arg,
|
|
mq_msg_free_cb_func *msg_free_cb,
|
|
void *msg_free_arg);
|
|
|
|
int mq_schema_destroy_topic(struct mq_schema *s, int topic_id);
|
|
|
|
//return 0 if success, otherwise return -1.
|
|
int mq_schema_subscribe(struct mq_schema *s, int topic_id, on_msg_cb_func *on_msg_cb, void * on_msg_cb_arg);
|
|
|
|
|
|
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
|
|
}
|
|
#endif |