consumer.h 2.3 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_CONSUMER_H_
#define _TD_CONSUMER_H_
H
refact  
Hongze Cheng 已提交
18

L
Liu Jicong 已提交
19 20 21 22
#include "tlist.h"
#include "tarray.h"
#include "hash.h"

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

27 28 29 30 31 32 33 34 35 36 37 38
  //consumer handle
  struct tmq_consumer_t;
  typedef struct tmq_consumer_t tmq_consumer_t;

  //consumer config
  struct tmq_consumer_config_t;
  typedef struct tmq_consumer_config_t tmq_consumer_config_t;

  //response err
  struct tmq_resp_err_t;
  typedef struct tmq_resp_err_t tmq_resp_err_t;

L
Liu Jicong 已提交
39 40 41 42 43
  struct tmq_message_t;
  typedef struct tmq_message_t tmq_message_t;

  struct tmq_col_batch_t;
  typedef struct tmq_col_batch_t tmq_col_batch_t;
44 45

  //get content of message
L
Liu Jicong 已提交
46 47
  tmq_col_batch_t* tmq_get_msg_col_by_idx(tmq_message_t*, int32_t col_id);
  tmq_col_batch_t* tmq_get_msg_col_by_name(tmq_message_t*, const char*);
48 49 50 51 52 53 54 55 56

  //consumer config
  int32_t tmq_conf_set(tmq_consumer_config_t* , const char* config_key, const char* config_value, char* errstr, int32_t errstr_cap);

  //consumer initialization
  //resouces are supposed to be free by users by calling tmq_consumer_destroy
  tmq_consumer_t* tmq_consumer_new(tmq_consumer_config_t* , char* errstr, int32_t errstr_cap);

  //subscribe
L
Liu Jicong 已提交
57 58
  tmq_resp_err_t tmq_subscribe(tmq_consumer_t*, const SList*);
  tmq_resp_err_t tmq_unsubscribe(tmq_consumer_t*);
59 60 61

  //consume
  //resouces are supposed to be free by users by calling tmq_message_destroy
L
Liu Jicong 已提交
62
  tmq_message_t* tmq_consume_poll(tmq_consumer_t*, int64_t blocking_time);
63 64 65 66 67 68 69 70 71 72 73

  //destroy message and free memory
  void tmq_message_destroy(tmq_message_t*);

  //close consumer
  int32_t tmq_consumer_close(tmq_consumer_t*);

  //destroy consumer
  void tmq_consumer_destroy(tmq_message_t*);


H
refact  
Hongze Cheng 已提交
74 75 76 77
#ifdef __cplusplus
}
#endif

78
#endif /*_TD_CONSUMER_H_*/