重构cache目录,将libxml2、libcurl放到vendor目录。
This commit is contained in:
151
cache/src/tango_cache_client_in.h
vendored
Normal file
151
cache/src/tango_cache_client_in.h
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
#ifndef __TANGO_CACHE_CLIENT_IN_H__
|
||||
#define __TANGO_CACHE_CLIENT_IN_H__
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include <sys/queue.h>
|
||||
|
||||
#include <event2/event.h>
|
||||
#include <event.h>
|
||||
|
||||
#include <MESA/wiredLB.h>
|
||||
#include "tango_cache_client.h"
|
||||
|
||||
#define RESPONSE_HDR_EXPIRES 1
|
||||
#define RESPONSE_HDR_LAST_MOD 2
|
||||
#define RESPONSE_HDR_ALL 3
|
||||
|
||||
enum CACHE_REQUEST_METHOD
|
||||
{
|
||||
CACHE_REQUEST_GET=0,
|
||||
CACHE_REQUEST_PUT,
|
||||
CACHE_REQUEST_DELETE,
|
||||
CACHE_REQUEST_DELETE_MUL,
|
||||
};
|
||||
|
||||
enum GET_OBJECT_STATE
|
||||
{
|
||||
GET_STATE_START=0,
|
||||
GET_STATE_DELETE,
|
||||
GET_STATE_END,
|
||||
};
|
||||
|
||||
enum PUT_OBJECT_STATE
|
||||
{
|
||||
PUT_STATE_START=0,
|
||||
PUT_STATE_WAIT_START,
|
||||
PUT_STATE_PART,
|
||||
PUT_STATE_END,
|
||||
PUT_STATE_CANCEL,
|
||||
};
|
||||
|
||||
struct easy_string
|
||||
{
|
||||
char* buff;
|
||||
size_t len;
|
||||
size_t size;
|
||||
};
|
||||
|
||||
struct tango_cache_instance
|
||||
{
|
||||
char minio_iplist[4096];
|
||||
char bucketname[256];
|
||||
char wiredlb_topic[64];
|
||||
char wiredlb_group[64];
|
||||
char wiredlb_datacenter[64];
|
||||
u_int32_t minio_port;
|
||||
u_int32_t wiredlb_override;
|
||||
struct event_base* evbase;
|
||||
struct event timer_event;
|
||||
struct cache_statistics statistic;
|
||||
CURLM *multi_hd;
|
||||
void *runtime_log;
|
||||
WLB_handle_t wiredlb;
|
||||
time_t relative_ttl; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7>
|
||||
u_int64_t cache_limit_size;
|
||||
long max_cnn_host;
|
||||
u_int32_t upload_block_size; //minio<69>ֶ<EFBFBD><D6B6>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
||||
enum CACHE_ERR_CODE error_code;
|
||||
u_int32_t hash_object_key;
|
||||
};
|
||||
|
||||
struct multipart_etag_list
|
||||
{
|
||||
char *etag;
|
||||
u_int32_t part_number;
|
||||
TAILQ_ENTRY(multipart_etag_list) node;
|
||||
};
|
||||
|
||||
struct cache_ctx_data_get
|
||||
{
|
||||
time_t max_age;//Get
|
||||
time_t min_fresh;//Get
|
||||
time_t expires;
|
||||
time_t last_modify;
|
||||
u_int32_t need_hdrs;
|
||||
enum GET_OBJECT_STATE state;
|
||||
struct easy_string response_tag;
|
||||
};
|
||||
|
||||
struct cache_ctx_data_put
|
||||
{
|
||||
struct evbuffer *evbuf;
|
||||
size_t upload_length;
|
||||
size_t upload_offset;
|
||||
char *uploadID;
|
||||
char *combine_xml;
|
||||
TAILQ_HEAD(__etag_list_head, multipart_etag_list) etag_head;
|
||||
enum PUT_OBJECT_STATE state;
|
||||
u_int32_t part_index; //<2F><>RESPONSE_HDR_
|
||||
bool close_state; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ùر<C3B9>
|
||||
};
|
||||
|
||||
struct cache_ctx_multi_delete
|
||||
{
|
||||
u_int32_t succ_num;
|
||||
u_int32_t fail_num;
|
||||
};
|
||||
|
||||
struct tango_cache_ctx
|
||||
{
|
||||
CURL *curl;
|
||||
struct curl_slist *headers;
|
||||
struct future* future;
|
||||
char error[CURL_ERROR_SIZE];
|
||||
char object_key[256];
|
||||
char hostaddr[48];
|
||||
|
||||
enum CACHE_REQUEST_METHOD method;
|
||||
enum CACHE_ERR_CODE error_code;
|
||||
struct easy_string response;
|
||||
|
||||
bool fail_state;
|
||||
long res_code;
|
||||
|
||||
union{
|
||||
struct cache_ctx_data_put put;
|
||||
struct cache_ctx_data_get get;
|
||||
struct cache_ctx_multi_delete del;
|
||||
};
|
||||
struct tango_cache_instance *instance;
|
||||
};
|
||||
|
||||
struct curl_socket_data
|
||||
{
|
||||
struct event sock_event;
|
||||
};
|
||||
|
||||
void caculate_sha256(const char *data, unsigned long len, char *result, u_int32_t size);
|
||||
|
||||
void easy_string_savedata(struct easy_string *estr, const char *data, size_t len);
|
||||
void easy_string_destroy(struct easy_string *estr);
|
||||
|
||||
void tango_cache_ctx_destroy(struct tango_cache_ctx *ctx);
|
||||
void tango_cache_set_fail_state(struct tango_cache_ctx *ctx, enum CACHE_ERR_CODE error_code);
|
||||
const char *tango_cache_get_errstring(const struct tango_cache_ctx *ctx);
|
||||
|
||||
struct tango_cache_ctx *tango_cache_update_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta);
|
||||
struct tango_cache_ctx *tango_cache_fetch_prepare(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta);
|
||||
struct tango_cache_ctx *tango_cache_delete_prepare(struct tango_cache_instance *instance, struct future* future, const char *objkey);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user