From 414f0f1efe752f8d6383f89aacc537c21bbab412 Mon Sep 17 00:00:00 2001 From: YuQing <384681@qq.com> Date: Tue, 29 Jun 2021 22:42:02 +0800 Subject: [PATCH] add types: SFListLimitInfo and SFProtoLimitInfo --- src/sf_proto.h | 23 +++++++++++++++++++++-- src/sf_types.h | 5 +++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/sf_proto.h b/src/sf_proto.h index 2a379d0..134610e 100644 --- a/src/sf_proto.h +++ b/src/sf_proto.h @@ -127,6 +127,11 @@ typedef struct sf_common_proto_header { char padding[3]; } SFCommonProtoHeader; +typedef struct sf_proto_limit_info { + char offset[4]; + char count[4]; +} SFProtoLimitInfo; + typedef struct sf_proto_get_group_servers_req { char group_id[4]; char padding[4]; @@ -476,8 +481,8 @@ int sf_send_and_recv_vary_response(ConnectionInfo *conn, const int network_timeout, const unsigned char expect_cmd, SFProtoRecvBuffer *buffer, const int min_body_len); -static inline void sf_proto_extract_header(SFCommonProtoHeader *header_proto, - SFHeaderInfo *header_info) +static inline void sf_proto_extract_header(const SFCommonProtoHeader + *header_proto, SFHeaderInfo *header_info) { header_info->cmd = header_proto->cmd; header_info->body_len = buff2int(header_proto->body_len); @@ -488,6 +493,20 @@ static inline void sf_proto_extract_header(SFCommonProtoHeader *header_proto, } } +static inline void sf_proto_pack_limit(const SFListLimitInfo + *limit_info, SFProtoLimitInfo *limit_proto) +{ + int2buff(limit_info->offset, limit_proto->offset); + int2buff(limit_info->count, limit_proto->count); +} + +static inline void sf_proto_extract_limit(const SFProtoLimitInfo + *limit_proto, SFListLimitInfo *limit_info) +{ + limit_info->offset = buff2int(limit_proto->offset); + limit_info->count = buff2int(limit_proto->count); +} + static inline int sf_active_test(ConnectionInfo *conn, SFResponseInfo *response, const int network_timeout) { diff --git a/src/sf_types.h b/src/sf_types.h index 7b16c1e..4a2bb5f 100644 --- a/src/sf_types.h +++ b/src/sf_types.h @@ -216,6 +216,11 @@ typedef struct sf_memory_watermark { int64_t high; } SFMemoryWatermark; +typedef struct sf_list_limit_info { + int offset; + int count; +} SFListLimitInfo; + typedef enum sf_server_group_index_type { sf_server_group_index_type_cluster = 1, sf_server_group_index_type_service