72 lines
1.2 KiB
C
72 lines
1.2 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
{
|
|
#endif
|
|
|
|
#include "stellar/mq.h"
|
|
#include "uthash/utarray.h"
|
|
|
|
enum mq_priority
|
|
{
|
|
STELLAR_MQ_PRIORITY_LOW = 0,
|
|
STELLAR_MQ_PRIORITY_MEDIUM,
|
|
STELLAR_MQ_PRIORITY_HIGH,
|
|
STELLAR_MQ_PRIORITY_MAX
|
|
};
|
|
|
|
struct mq_message
|
|
{
|
|
struct mq_runtime *rt;
|
|
struct
|
|
{
|
|
int topic_id;
|
|
enum mq_priority priority;
|
|
} header;
|
|
void *body;
|
|
struct mq_message *next, *prev;
|
|
} __attribute__((aligned(sizeof(void *))));
|
|
|
|
typedef struct mq_subscriber
|
|
{
|
|
int topic_subscriber_idx;
|
|
int plugin_idx;
|
|
on_msg_cb_func *msg_cb;
|
|
void *msg_cb_arg;
|
|
struct mq_subscriber *next, *prev;
|
|
}stellar_mq_subscriber __attribute__((aligned(sizeof(void*))));
|
|
|
|
|
|
struct mq_topic
|
|
{
|
|
char *topic_name;
|
|
int topic_id;
|
|
int subscriber_cnt;
|
|
int is_destroyed;
|
|
on_msg_dispatch_cb_func *dispatch_cb;
|
|
void *dispatch_cb_arg;
|
|
mq_msg_free_cb_func *free_cb;
|
|
void *free_cb_arg;
|
|
struct mq_subscriber *subscribers;
|
|
}__attribute__((aligned(sizeof(void*))));
|
|
|
|
struct mq_schema
|
|
{
|
|
UT_array *topic_array;
|
|
int mq_topic_num;
|
|
int mq_topic_subscriber_num;
|
|
};
|
|
|
|
|
|
struct mq_runtime
|
|
{
|
|
struct mq_schema *schema;
|
|
struct mq_message *priority_mq[STELLAR_MQ_PRIORITY_MAX];// message list
|
|
struct mq_message *dealth_letter_queue;// dlq list
|
|
};
|
|
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |