summaryrefslogtreecommitdiff
path: root/src/inc/tango_cache_client.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/inc/tango_cache_client.h')
-rw-r--r--src/inc/tango_cache_client.h74
1 files changed, 48 insertions, 26 deletions
diff --git a/src/inc/tango_cache_client.h b/src/inc/tango_cache_client.h
index bcd2f63..c551e8f 100644
--- a/src/inc/tango_cache_client.h
+++ b/src/inc/tango_cache_client.h
@@ -4,8 +4,8 @@
#include <event2/event.h>
#include <event.h>
-#include "tfe_future.h"
-#include "proxy_cache.h"
+#include <tfe_future.h>
+#include "tango_cache_pending.h"
#define USER_TAG_MAX_LEN 1518
@@ -16,7 +16,13 @@ enum CACHE_ERR_CODE
CACHE_TIMEOUT, //���泬ʱ
CACHE_OUTOF_MEMORY,//��ǰ�ڴ�ռ�ó������ƣ��鿴MAX_USED_MEMORY_SIZE_MB�Ƿ��С���ߵ�ǰ�ϴ����ʸ����ϵ����ߵ�����
CACHE_ERR_CURL,
- CACHE_ERR_UNKNOWN
+ CACHE_ERR_WIREDLB,
+ CACHE_ERR_SOCKPAIR,
+ CACHE_ERR_INTERNAL,
+ CACHE_ERR_REDIS_JSON,
+ CACHE_ERR_REDIS_CONNECT,
+ CACHE_OUTOF_SESSION,
+ CACHE_UPDATE_CANCELED,
};
enum PUT_MEMORY_COPY_WAY
@@ -41,23 +47,27 @@ struct cache_statistics
long long put_error_num;//UPLOADʧ�ܵĴ���
long long del_recv_num; //����DELETE�Ĵ���
long long del_succ_num; //DELETE�ɹ��Ĵ���
- long long del_error_num;//DELETE�ɹ��Ĵ���
+ long long del_error_num;//DELETEʧ�ܵĴ���
+ long long totaldrop_num;//�ڴ����Լ�WiredLB����ʱDROP�Ĵ���
long long memory_used; //��ǰUPLOAD BODY��ռ�ڴ��С
long long session_num; //��ǰ���ڽ���GET/PUT��HTTP�Ự��
};
enum CACHE_RESULT_TYPE
{
- RESULT_TYPE_HEADER=0, //ֻ����һ��
- RESULT_TYPE_USERTAG, //ֻ����һ��
+ RESULT_TYPE_HEADER=0, //���ֻ����һ��
+ RESULT_TYPE_USERTAG, //���ֻ����һ��
RESULT_TYPE_BODY, //���ܵ��ö��
+ RESULT_TYPE_END, //ȫ��������ֻ����һ�Σ�����������
+ RESULT_TYPE_MISS, //����δ���У����������ͻ��⣬ֻ����һ��(��END֮��)������������
};
//promise_success�Ľ��result
struct tango_cache_result
{
- const void *data_frag; //���typeΪRESULT_TYPE_HEADER��ÿ��ͷ��������һ������(HTTP1.1��ʽ)
+ const char *data_frag; //���typeΪRESULT_TYPE_HEADER��ÿ��ͷ��������һ������(HTTP1.1��ʽ)
size_t size;
+ size_t tlength; //������ܳ��ȣ��ص�ʱ����Ч
enum CACHE_RESULT_TYPE type;
};
@@ -71,18 +81,22 @@ enum CACHE_HTTP_HDR_TYPE
HDR_CONTENT_NUM,
};
-struct tango_cache_meta
+struct tango_cache_meta_get
{
- const char* url; //����:URL���ǽṹ����־:�ļ�������󳤶�256�ֽ�
+ const char* url; //����:URL���ǽṹ����־:�ļ�·������CACHE_OBJECT_KEY_HASH_SWITCH=0ʱ��󳤶�256�ֽڣ�=1ʱ������
+ struct request_freshness get;
+};
+
+struct tango_cache_meta_put
+{
+ const char* url;
const char* std_hdr[HDR_CONTENT_NUM]; //����ͷ������"Content-Type: text/html"����Ҫ�������У�NULL��ʾû�и�ͷ����
const char* usertag; //�������������ݣ�GETʱ��ԭ������
size_t usertag_len; //��󳤶�USER_TAG_MAX_LEN��0��ʾû�и�ͷ��
- union{
- struct response_freshness put;
- struct request_freshness get;
- };
+ struct response_freshness put;
};
+struct tango_cache_parameter;
struct tango_cache_instance;
struct tango_cache_ctx;
@@ -90,22 +104,28 @@ enum CACHE_ERR_CODE tango_cache_get_last_error(const struct tango_cache_ctx *ctx
enum CACHE_ERR_CODE tango_cache_ctx_error(const struct tango_cache_instance *instance);
void tango_cache_get_statistics(const struct tango_cache_instance *instance, struct cache_statistics *out);
+/*ÿ������ִ��һ�γ�ʼ��*/
+void tango_cache_global_init(void);
+
+//ÿ��minio��Ⱥ��bucket����һ��parameter�����instance�ɹ���һ��parameter
+struct tango_cache_parameter *tango_cache_parameter_new(const char* profile_path, const char* section, void *runtimelog);
/*��������API�̲߳���ȫ*/
//ÿ�������̴߳���һ��instance
-struct tango_cache_instance *tango_cache_instance_new(struct event_base* evbase,const char* profile_path, const char* section, void *runtimelog);
+struct tango_cache_instance *tango_cache_instance_new(struct tango_cache_parameter *param, struct event_base* evbase, void *runtimelog);
/* GET�ӿڵ�API*/
-//�ɹ�ʱ�ص�promise_success, resultΪNULLʱ��ʾ������
+//�ɹ�ʱ�ص�promise_success
//ʧ��ʱ�ص�promise_failed(��һ��)��ʹ��get_last_error��ȡ�����룻
//future������ΪNULL
-int tango_cache_fetch_object(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta);
+int tango_cache_fetch_object(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_get *meta);
+int tango_cache_head_object(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_get *meta);
//��promise_success��result������ȡ���
-struct tango_cache_result *tango_cache_read_result(void *promise_result);
+struct tango_cache_result *tango_cache_read_result(future_result_t *promise_result);
/* DELETE�ӿڵ�API*/
-int tango_cache_delete_object(struct tango_cache_instance *instance, struct future* future, const char *objkey);
+int tango_cache_delete_object(struct tango_cache_instance *instance, struct future* f, const char *objkey);
/* UPLOAD�ӿڵ�API
@@ -115,24 +135,26 @@ int tango_cache_delete_object(struct tango_cache_instance *instance, struct futu
/*����һ���ϴ�API*/
//��path��Ϊ�գ����������Ĵ洢·��
//����ֵ: 0-�ɹ���<0ʧ�ܣ���ͬ
-int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct future* future,
+int tango_cache_upload_once_data(struct tango_cache_instance *instance, struct future* f,
enum PUT_MEMORY_COPY_WAY way, const char *data, size_t size,
- struct tango_cache_meta *meta,
- char *path, size_t pathsize);
-int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct future* future,
+ struct tango_cache_meta_put *meta,
+ char *path/*OUT*/, size_t pathsize);
+int tango_cache_upload_once_evbuf(struct tango_cache_instance *instance, struct future* f,
enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf,
- struct tango_cache_meta *meta,
- char *path, size_t pathsize);
+ struct tango_cache_meta_put *meta,
+ char *path/*OUT*/, size_t pathsize);
/*��ʽ�ϴ�API*/
//����ֵ: ��ΪNULL���ʾ����ʧ�ܣ�����tango_cache_ctx_error�鿴�������Ƿ���CACHE_OUTOF_MEMORY(�����������)��
-struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* future, struct tango_cache_meta *meta);
+struct tango_cache_ctx *tango_cache_update_start(struct tango_cache_instance *instance, struct future* f, struct tango_cache_meta_put *meta);
//����ֵ: 0-�ɹ���<0ʧ�ܣ�����tango_cache_get_last_error�鿴�����룻
int tango_cache_update_frag_data(struct tango_cache_ctx *ctx, const char *data, size_t size);
int tango_cache_update_frag_evbuf(struct tango_cache_ctx *ctx, enum EVBUFFER_COPY_WAY way, struct evbuffer *evbuf);
void tango_cache_update_end(struct tango_cache_ctx *ctx);
+//����cancel�󲻻��������ص�����������ʧ��
+void tango_cache_update_cancel(struct tango_cache_ctx *ctx);
//��ȡ����keyֵ����CACHE_OBJECT_KEY_HASH_SWITCH=1������URL/�ļ�����ϣʱ����
-void tango_cache_get_object_path(const struct tango_cache_ctx *ctx, char *path, size_t pathsize);
+void tango_cache_get_object_path(const struct tango_cache_ctx *ctx, char *path/*OUT*/, size_t pathsize);
#endif