secgateway/Platform/common/redismq/redis_publisher.h

33 lines
702 B
C

#ifndef REDIS_PUBLISHER_H
#define REDIS_PUBLISHER_H
#include <stdlib.h>
#include <string.h>
#include <hiredis/async.h>
#include <hiredis/adapters/libevent.h>
#include <unistd.h>
#include <pthread.h>
#include <semaphore.h>
#include <stdbool.h>
extern struct RedisPublisher gRedisPublisher;
struct RedisPublisher
{
/*libevent事件对象*/
struct event_base *eventBase;
/*事件线程ID*/
pthread_t eventThread;
/* 事件线程的信号量*/
sem_t eventSem;
/* hiredis异步对象*/
redisAsyncContext *redisContext;
};
bool redisPubInit();
void redisPubUninit();
bool redisPubConnect();
void redisPubDisconnect();
bool redisPublish(char *channel_name,char *message);
#endif