This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tango-tfe/cache/tango_cache_client_in.h

124 lines
2.7 KiB
C
Raw Normal View History

2018-09-18 11:14:11 +08:00
#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 "tango_cache_client.h"
2018-09-21 14:50:41 +08:00
#define RESPONSE_HDR_EXPIRES 1
#define RESPONSE_HDR_LAST_MOD 2
#define RESPONSE_HDR_ALL 3
2018-09-18 11:14:11 +08:00
enum CACHE_REQUEST_METHOD
{
CACHE_REQUEST_GET=0,
CACHE_REQUEST_PUT,
};
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_hostlist[4096];
char bucketname[256];
struct event_base* evbase;
struct event timer_event;
struct cache_statistics statistic;
CURLM *multi_hd;
void *runtime_log;
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 block_len; //<2F><><EFBFBD><EFBFBD>buffercache<68>ڴ<EFBFBD><DAB4>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>ÿ<EFBFBD><C3BF>update<74><65><EFBFBD><EFBFBD>С<EFBFBD><D0A1><EFBFBD>ò<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
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;
};
2018-09-21 14:50:41 +08:00
struct multipart_etag_list
{
char *etag;
u_int32_t part_number;
TAILQ_ENTRY(multipart_etag_list) node;
};
2018-09-18 11:14:11 +08:00
struct tango_cache_ctx
{
CURL *curl;
struct curl_slist *headers;
struct future* future;
char error[CURL_ERROR_SIZE];
2018-09-23 15:35:13 +08:00
char object_key[256];
2018-09-18 11:14:11 +08:00
char hostport[24]; //<2F><>ͬctxʹ<78><CAB9><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>IP<49><50><EFBFBD><EFBFBD>֤pipeline˳<65><CBB3><EFBFBD><EFBFBD>
2018-09-21 14:50:41 +08:00
2018-09-18 11:14:11 +08:00
enum CACHE_REQUEST_METHOD method;
enum CACHE_ERR_CODE error_code;
2018-09-21 14:50:41 +08:00
struct evbuffer *evbuffer;
2018-09-18 11:14:11 +08:00
union{
enum PUT_OBJECT_STATE put_state;
enum GET_OBJECT_STATE get_state;
};
2018-09-21 14:50:41 +08:00
u_int32_t part_index;
u_int32_t need_hdrs; //<2F><>RESPONSE_HDR_
2018-09-23 15:35:13 +08:00
bool fail_state;
2018-09-18 11:14:11 +08:00
bool close_state; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ùر<C3B9>
long res_code;
2018-09-21 14:50:41 +08:00
time_t max_age;//Get
time_t min_fresh;//Get
time_t expires;
time_t last_modify;
2018-09-18 11:14:11 +08:00
2018-09-21 14:50:41 +08:00
size_t upload_length;
size_t upload_offset;
2018-09-18 11:14:11 +08:00
char *uploadID;
char *combine_xml;
struct easy_string response;
2018-09-23 15:35:13 +08:00
struct easy_string response_tag;
2018-09-21 14:50:41 +08:00
TAILQ_HEAD(__etag_list_head, multipart_etag_list) cache_head;
2018-09-18 11:14:11 +08:00
struct tango_cache_instance *instance;
};
struct curl_socket_data
{
struct event sock_event;
};
2018-09-21 14:50:41 +08:00
void easy_string_savedata(struct easy_string *estr, const char *data, size_t len);
2018-09-23 15:35:13 +08:00
void easy_string_expand(struct easy_string *estr, size_t to_size);
2018-09-21 14:50:41 +08:00
void easy_string_destroy(struct easy_string *estr);
2018-09-18 11:14:11 +08:00
void tango_cache_ctx_destroy(struct tango_cache_ctx *ctx);
2018-09-21 14:50:41 +08:00
2018-09-18 11:14:11 +08:00
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);
#endif