tq.h 2.0 KB
Newer Older
H
refact  
Hongze Cheng 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
/*
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
 *
 * This program is free software: you can use, redistribute, and/or modify
 * it under the terms of the GNU Affero General Public License, version 3
 * or later ("AGPL"), as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

H
refact  
Hongze Cheng 已提交
16 17
#ifndef _TD_TQ_H_
#define _TD_TQ_H_
H
refact  
Hongze Cheng 已提交
18

L
Liu Jicong 已提交
19 20
#include "os.h"

H
refact  
Hongze Cheng 已提交
21 22 23 24
#ifdef __cplusplus
extern "C" {
#endif

L
Liu Jicong 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
typedef struct tmqMsgHead {
  int32_t headLen;
  int32_t msgVer;
  int64_t cgId;
  int32_t topicLen;
  char topic[];
} tmqMsgHead;

//TODO: put msgs into common
typedef struct tmqConnectReq {
  tmqMsgHead head;

} tmqConnectReq;

typedef struct tmqConnectResp {

} tmqConnectResp;

typedef struct tmqDisconnectReq {

} tmqDisconnectReq;

typedef struct tmqDisconnectResp {

} tmqDiconnectResp;

typedef struct tmqConsumeReq {

} tmqConsumeReq;

typedef struct tmqConsumeResp {

} tmqConsumeResp;

typedef struct tmqSubscribeReq {

} tmqSubscribeReq;

typedef struct tmqSubscribeResp {

} tmqSubscribeResp;

typedef struct tmqHeartbeatReq {

} tmqHeartbeatReq;

typedef struct tmqHeartbeatResp {

} tmqHeartbeatResp;

L
Liu Jicong 已提交
75 76 77 78 79 80 81
typedef struct tqTopicVhandle {
  //name
  //
  //executor for filter
  //
  //callback for mnode
  //
L
Liu Jicong 已提交
82
} tqTopicVhandle;
L
Liu Jicong 已提交
83 84 85 86 87 88 89 90 91 92 93 94

typedef struct STQ {
  //the set for topics
  //key=topicName: str
  //value=tqTopicVhandle

  //a map
  //key=<topic: str, cgId: int64_t>
  //value=consumeOffset: int64_t
} STQ;

//init in each vnode
L
Liu Jicong 已提交
95
STQ* tqInit(void* ref_func(void*), void* unref_func(void*));
L
Liu Jicong 已提交
96 97 98 99
void tqCleanUp(STQ*);

//void* will be replace by a msg type
int tqPushMsg(STQ*, void* msg, int64_t version);
L
Liu Jicong 已提交
100 101
int tqCommit(STQ*);

L
Liu Jicong 已提交
102
//void* will be replace by a msg type
L
Liu Jicong 已提交
103
int tqHandleConsumeMsg(STQ*, tmqConsumeReq* msg);
H
refact  
Hongze Cheng 已提交
104

H
refact  
Hongze Cheng 已提交
105 106 107 108
#ifdef __cplusplus
}
#endif

L
Liu Jicong 已提交
109
#endif /*_TD_TQ_H_*/