This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
stellar-stellar/infra/mq/mq_interna.h
2024-09-10 14:44:38 +08:00

74 lines
1.3 KiB
C

#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
#include "stellar/mq.h"
#include "uthash/utarray.h"
struct mq_schema
{
UT_array *topic_array;
int stellar_mq_topic_num;
int mq_topic_subscriber_num;
};
enum stellar_mq_priority
{
STELLAR_MQ_PRIORITY_LOW = 0,
STELLAR_MQ_PRIORITY_MEDIUM,
STELLAR_MQ_PRIORITY_HIGH,
STELLAR_MQ_PRIORITY_MAX
};
struct stellar_message
{
struct mq_runtime *rt;
struct
{
int topic_id;
enum stellar_mq_priority priority;
} header;
void *body;
struct stellar_message *next, *prev;
} __attribute__((aligned(sizeof(void *))));
typedef struct stellar_mq_subscriber
{
int topic_subscriber_idx;
int plugin_idx;
on_msg_cb_func *plugin_msg_cb;
void *plugin_msg_cb_arg;
struct stellar_mq_subscriber *next, *prev;
}stellar_mq_subscriber __attribute__((aligned(sizeof(void*))));
struct stellar_mq_topic_schema
{
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 stellar_mq_subscriber *subscribers;
}__attribute__((aligned(sizeof(void*))));
struct mq_runtime
{
struct mq_schema *schema;
struct stellar_message *priority_mq[STELLAR_MQ_PRIORITY_MAX];// message list
struct stellar_message *dealth_letter_queue;// dlq list
};
#ifdef __cplusplus
}
#endif