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
pxz-hos-client-cpp-module/src/hos_client.h

179 lines
9.3 KiB
C
Raw Normal View History

2020-09-11 16:13:02 +08:00
/*************************************************************************
> File Name: hos_client_api.h
> Author: pxz
> Created Time: Thu 10 Sep 2020 03:13:59 PM CST
************************************************************************/
#ifndef __HOS_CLIENT_INIT__
#define __HOS_CLIENT_INIT__
/*hos client 句柄*/
2020-09-21 19:19:18 +08:00
typedef struct hos_client_handle_s* hos_client_handle;
2020-09-11 16:13:02 +08:00
2020-09-21 19:19:18 +08:00
#define HOS_CLIENT_OK 0
/* fd mode */
#define FILE_MODE 0x00
#define BUFF_MODE 0x01
#define APPEND_MODE 0x02 /* 默认不追加 */
/* hos 错误码 */
enum hoserrors
{
HOS_PARAMETER_ERROR = -1,
HOS_FILE_NOT_EXITS = -2,
HOS_HASH_NOT_FIND = -3,
HOS_FD_NOT_ENOUGH = -4,
2020-10-20 17:20:27 +08:00
HOS_SEND_FAILED = -5,
2020-09-21 19:19:18 +08:00
};
/* s3 的错误码 */
enum s3errors
{
2020-09-21 19:19:18 +08:00
//From Core Aws::S3::S3Error + 1//
//////////////////////////////////////////////////////////////////////////////////////////
2020-09-21 19:19:18 +08:00
INCOMPLETE_SIGNATURE = 1,
INTERNAL_FAILURE = 2,
INVALID_ACTION = 3,
INVALID_CLIENT_TOKEN_ID = 4,
INVALID_PARAMETER_COMBINATION = 5,
INVALID_QUERY_PARAMETER = 6,
INVALID_PARAMETER_VALUE = 7,
MISSING_ACTION = 8, // SDK should never allow
MISSING_AUTHENTICATION_TOKEN = 9, // SDK should never allow
MISSING_PARAMETER = 10, // SDK should never allow
OPT_IN_REQUIRED = 11,
REQUEST_EXPIRED = 12,
SERVICE_UNAVAILABLE = 13,
THROTTLING = 14,
VALIDATION = 15,
ACCESS_DENIED = 16,
RESOURCE_NOT_FOUND = 17, // Shared with multiple services
UNRECOGNIZED_CLIENT = 18, // Most likely caused by an invalid access key or secret key
MALFORMED_QUERY_STRING = 19,
SLOW_DOWN = 20,
REQUEST_TIME_TOO_SKEWED = 21,
INVALID_SIGNATURE = 22,
SIGNATURE_DOES_NOT_MATCH = 23,
INVALID_ACCESS_KEY_ID = 24,
REQUEST_TIMEOUT = 25,
NETWORK_CONNECTION = 100, // General failure to send message to service
// These are needed for logical reasons
2020-09-21 19:19:18 +08:00
UNKNOWN = 101,
CLIENT_SIGNING_FAILURE = 102, // Client failed to sign the request
USER_CANCELLED = 103, // User cancelled the request
SERVICE_EXTENSION_START_RANGE = 129,
BUCKET_ALREADY_EXISTS= SERVICE_EXTENSION_START_RANGE + 1,
BUCKET_ALREADY_OWNED_BY_YOU,
NO_SUCH_BUCKET,
NO_SUCH_KEY,
NO_SUCH_UPLOAD,
OBJECT_ALREADY_IN_ACTIVE_TIER,
OBJECT_NOT_IN_ACTIVE_TIER
};
2020-09-21 19:19:18 +08:00
typedef void (*put_finished_callback)(bool, const char *, void *);
/*************************************************************************************
* hos_client_init
* const char *endpoint http://192.168.44.12:9098/hos“
* const char *accesskeyid AWS access key IDdefault
2020-09-21 19:19:18 +08:00
* const char *secretkey AWS secret keydefault
2020-10-09 14:20:39 +08:00
* size_t thread_sum 线
2020-10-14 15:23:01 +08:00
* NULL
*************************************************************************************/
hos_client_handle hos_client_create(const char *endpoint, const char *accesskeyid, const char *secretkey, size_t pool_size);
2020-09-21 19:19:18 +08:00
/*************************************************************************************
* hos_create_bucket
* hos_client_handle handle
* const char * bucket
* int 0S3错误返回s3errors错误码hos client错误返回hoserrors错误码
*************************************************************************************/
bool hos_verify_bucket(hos_client_handle handle, const char *bucket);
/*************************************************************************************
* hos_create_bucket
* hos_client_handle handle
* const char * bucket
2020-09-21 19:19:18 +08:00
* int 0S3错误返回s3errors错误码hos client错误返回hoserrors错误码
*************************************************************************************/
2020-09-21 19:19:18 +08:00
int hos_create_bucket(hos_client_handle handle, const char *bucket);
/*************************************************************************************
* set_cache_size
* hos_client_handle handle
* size_t cache_size append buffer大小
*************************************************************************************/
void set_cache_size(hos_client_handle handle, size_t cache_size);
/*************************************************************************************
* set_cache_times
* hos_client_handle handle
* size_t cache_times append
*************************************************************************************/
void set_cache_times(hos_client_handle handle, size_t cache_times);
/*************************************************************************************
* set_thread_sum
* hos_client_handle handle
* size_t thread_sum append
*************************************************************************************/
void set_cache_times(hos_client_handle handle, size_t thread_sum);
/*************************************************************************************
* hos_upload_async
* hos_client_handle handle
* const char * bucket
2020-10-09 14:20:39 +08:00
* const char * file_path
2020-09-21 19:19:18 +08:00
* put_finished_callback callback upload操作结束时调用的回调函数
2020-10-09 14:20:39 +08:00
* void *userdata
* size_t thread_id 线id
2020-09-21 19:19:18 +08:00
* int 0hoserros错误码
*************************************************************************************/
int hos_upload_file(hos_client_handle handle, const char *bucket, const char *file_path, put_finished_callback callback, void* userdata, size_t thread_id);
/*************************************************************************************
* hos_upload_async
* hos_client_handle handle
* const char * bucket
* const char * object
2020-10-09 14:20:39 +08:00
* const char *buf buf
* size_t buf_len buf的长度
2020-09-21 19:19:18 +08:00
* put_finished_callback callback upload操作结束时调用的回调函数
2020-10-09 14:20:39 +08:00
* void *userdata
* size_t thread_id 线id
2020-09-21 19:19:18 +08:00
* int 0hoserros错误码
*************************************************************************************/
int hos_upload_buf(hos_client_handle handle, const char *bucket, const char *object, const char *buf, size_t buf_len, put_finished_callback callback, void *userdata, size_t thread_id);
/*************************************************************************************
* hos_open_fd
* hos_client_handle handle
* const char * bucket
* const char * object
* put_finished_callback callback upload操作结束时调用的回调函数
* void *data
* size_t thread_id 线ID
* int mode (FILE OR BUFFER, APPEND OR NOT)
* int 0hoserros错误码
*************************************************************************************/
int hos_open_fd(hos_client_handle handle, const char *bucket, const char *object, put_finished_callback callback, void *userdata, size_t thread_id, int mode);
/*************************************************************************************
* hos_upload_stream_async
* hos_client_handle handle
* const char * stream
* size_t stream
* size_t thread_id 线ID
2020-10-09 14:20:39 +08:00
* size_t position append模式下的每段内容编号
2020-09-21 19:19:18 +08:00
* int 0hoserros错误码
*************************************************************************************/
int hos_write(size_t fd, const char *stream, size_t stream_len, size_t thread_id);
2020-09-21 19:19:18 +08:00
/*************************************************************************************
* hos_close_fd
* size_t fd fd
* size_t thread_id 线ID
* int 0hoserros错误码
*************************************************************************************/
2020-09-21 19:19:18 +08:00
int hos_close_fd(size_t fd, size_t thread_id);
/*************************************************************************************
2020-09-21 19:19:18 +08:00
* hos_client_destory
* hos_client_handle handle
2020-09-21 19:19:18 +08:00
* int 0hoserros错误码
*************************************************************************************/
2020-09-21 19:19:18 +08:00
int hos_client_destory(hos_client_handle handle);
2020-09-11 16:13:02 +08:00
#endif