添加cache客户端的代码示意。

This commit is contained in:
zhengchao
2018-08-17 19:29:43 +08:00
parent 4d845a2b00
commit 093afcce8d
2 changed files with 35 additions and 1 deletions

30
src/tango_cache_client.h Normal file
View File

@@ -0,0 +1,30 @@
#include "future.h"
struct tango_cache_instance{};
struct tango_cache_update_ctx{};
#define CACHE_FRAG_BEGIN 0x01
#define CACHE_FRAG_DATA 0x02
#define CACHE_FRAG_END 0x04
#define CACHE_FRAG_FULL (CACHE_FRAG_BEGIN|CACHE_FRAG_DATA|CACHE_FRAG_END)
struct tango_cache_result
{
char frag_type;
unsigned char* data_frag;
size_t size;
};
struct tango_cache_meta
{
const char* url;
const char* content_type;
};
struct tango_cache_instance* tango_cache_init(event_base* evbase,const char* profile_path, const char* section);
int tango_cache_fetch(struct tango_cache_instance* instance,struct future* future, const char* http_hdr, const char* url);
//following tfe_stream_write_xx functions are NOT thread safe, MUST be called in the stream process thread.
struct tango_cache_update_ctx* tango_cache_update_start(struct tango_cache_instance* instance,struct future* future, const char* http_hdr, const char* url);
/*
@return 0 if successful, or -1 if an error occurred
*/
int tango_cache_update_frag(struct tango_cache_update_ctx* ctx,const unsigned char *data, size_t size);
void tango_cache_update_end(struct tango_cache_update_ctx*ctx);

View File

@@ -420,7 +420,11 @@ void ssl_conn_origin_on_succ(void * result, void * user)
session_cache_set(_stream->thrmgr_ref->dsess_cache, struct sockaddr * addr, addrlen,_stream->ssl_downstream->sni, SSL_get0_session(_stream->ssl_upstream->ssl));
_stream->ssl_downstream->future_get_cert=future_create(ssl_get_cert_on_succ, ssl_get_cert_on_fail, _stream);
_stream->ssl_downstream->future_get_cert=future_create(ssl_get_cert_on_succ, ssl_get_cert_on_fail, _stream);
cert_mgr_async_get( _stream->ssl_downstream->future_get_cert,
_stream->thrmgr_ref->cert_mgr,
_stream->ssl_downstream->sni,
_stream->ssl_downstream->keyring_id,
_stream->ssl_upstream->orig_cert);
future_destroy(_stream->ssl_upstream->conn_ssl_srv);