tq.h 2.1 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
typedef struct tmqMsgHead {
  int32_t headLen;
  int32_t msgVer;
  int64_t cgId;
L
Liu Jicong 已提交
29 30 31
  int64_t topicId;
  int32_t checksum;
  int32_t msgType;
L
Liu Jicong 已提交
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 75
} 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 已提交
76 77 78 79 80 81 82
typedef struct tqTopicVhandle {
  //name
  //
  //executor for filter
  //
  //callback for mnode
  //
L
Liu Jicong 已提交
83
} tqTopicVhandle;
L
Liu Jicong 已提交
84 85 86 87 88 89 90 91 92 93 94 95

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 已提交
96
STQ* tqInit(void* ref_func(void*), void* unref_func(void*));
L
Liu Jicong 已提交
97 98 99 100
void tqCleanUp(STQ*);

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

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

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

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