Skip to content

Commit

Permalink
support dora idle tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
bachue committed Aug 19, 2024
1 parent 65f7cb8 commit f73e8c0
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## CHANGE LOG

## v7.8.0 (2024-08-20)

- 支持闲时任务

## v7.7.0 (2023-12-25)

- 支持归档直读存储类型
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CMAKE_POLICY(SET CMP0074 NEW)
SET(PROJECT_NAME qiniu)

# 建立项目
PROJECT(${PROJECT_NAME} VERSION 7.7.0 LANGUAGES C)
PROJECT(${PROJECT_NAME} VERSION 7.8.0 LANGUAGES C)

set(CMAKE_C_STANDARD 99)

Expand Down
13 changes: 11 additions & 2 deletions examples/fop_video_avthumb.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ int main(int argc, char **argv) {

char *fops[] = {avthumbMp4Fop, vframeJpgFop};

Qiniu_Error error = Qiniu_FOP_Pfop(&client, &pfopRet, bucket, key, fops, 2, pipeline, notifyURL, force);
Qiniu_FOP_PfopParams params = {
.bucket = bucket,
.key = key,
.pipeline = pipeline,
.notifyURL = notifyURL,
.fops = fops,
.fopCount = 2,
.force = force,
};
Qiniu_Error error = Qiniu_FOP_Pfop_v2(&client, &pfopRet, &params);
if (error.code != 200) {
printf("video file pfop %s:%s error.\n", bucket, key);
debug_log(&client, error);
Expand All @@ -55,4 +64,4 @@ int main(int argc, char **argv) {
Qiniu_Free(avthumbMp4Fop);
Qiniu_Free(vframeJpgFop);
Qiniu_Client_Cleanup(&client);
}
}
52 changes: 38 additions & 14 deletions qiniu/fop.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
#include "private/region.h"
#include "../cJSON/cJSON.h"

Qiniu_Error Qiniu_FOP_Pfop(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, const char *bucket, const char *key,
char *fops[], int fopCount, const char *pipeline, const char *notifyURL, int force)
Qiniu_Error Qiniu_FOP_Pfop_v2(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, Qiniu_FOP_PfopParams *params)
{
Qiniu_Error err;
cJSON *root;
Expand All @@ -25,6 +24,7 @@ Qiniu_Error Qiniu_FOP_Pfop(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, const cha
char *encodedNotifyURL = NULL;
char *encodedPipeline = NULL;
char *forceStr = NULL;
char *typeStr = NULL;
char *url = NULL;
char *body = NULL;
Qiniu_Bool escapeBucketOk;
Expand All @@ -34,39 +34,48 @@ Qiniu_Error Qiniu_FOP_Pfop(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, const cha
Qiniu_Bool escapeNotifyURLOk;

// Add encoded bucket
encodedBucket = Qiniu_QueryEscape(bucket, &escapeBucketOk);
encodedKey = Qiniu_QueryEscape(key, &escapeKeyOk);
fopsStr = Qiniu_String_Join(";", fops, fopCount);
encodedBucket = Qiniu_QueryEscape(params->bucket, &escapeBucketOk);
encodedKey = Qiniu_QueryEscape(params->key, &escapeKeyOk);
fopsStr = Qiniu_String_Join(";", params->fops, params->fopCount);
encodedFops = Qiniu_QueryEscape(fopsStr, &escapeFopsOk);
Qiniu_Free(fopsStr);

if (pipeline)
if (params->pipeline)
{
encodedPipeline = Qiniu_QueryEscape(pipeline, &escapePipelineOk);
encodedPipeline = Qiniu_QueryEscape(params->pipeline, &escapePipelineOk);
}
else
{
encodedPipeline = "";
}
if (notifyURL)
if (params->notifyURL)
{
encodedNotifyURL = Qiniu_QueryEscape(notifyURL, &escapeNotifyURLOk);
encodedNotifyURL = Qiniu_QueryEscape(params->notifyURL, &escapeNotifyURLOk);
}
else
{
encodedNotifyURL = "";
}
if (force == 1)
if (params->force == 1)
{
forceStr = "1";
}
else
{
forceStr = "0";
}
if (params->type == 1)
{
typeStr = "1";
}
else
{
typeStr = "0";
}

body = Qiniu_String_Concat("bucket=", encodedBucket, "&key=", encodedKey, "&fops=", encodedFops,
"&pipeline=", encodedPipeline, "&notifyURL=", encodedNotifyURL, "&force=", forceStr, NULL);
"&pipeline=", encodedPipeline, "&notifyURL=", encodedNotifyURL, "&force=", forceStr,
"&type=", typeStr, NULL);
if (escapeBucketOk)
{
Qiniu_Free(encodedBucket);
Expand All @@ -82,18 +91,18 @@ Qiniu_Error Qiniu_FOP_Pfop(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, const cha
Qiniu_Free(encodedFops);
}

if (pipeline && escapePipelineOk)
if (params->pipeline && escapePipelineOk)
{
Qiniu_Free(encodedPipeline);
}

if (notifyURL && escapeNotifyURLOk)
if (params->notifyURL && escapeNotifyURLOk)
{
Qiniu_Free(encodedNotifyURL);
}

const char *apiHost;
err = _Qiniu_Region_Get_Api_Host(self, NULL, bucket, &apiHost);
err = _Qiniu_Region_Get_Api_Host(self, NULL, params->bucket, &apiHost);
if (err.code != 200)
{
goto error;
Expand All @@ -116,4 +125,19 @@ Qiniu_Error Qiniu_FOP_Pfop(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, const cha
Qiniu_Free(body);
Qiniu_Free(url);
return err;
}

Qiniu_Error Qiniu_FOP_Pfop(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, const char *bucket, const char *key,
char *fops[], int fopCount, const char *pipeline, const char *notifyURL, int force)
{
Qiniu_FOP_PfopParams params;
Qiniu_Zero(params);
params.bucket = bucket;
params.key = key;
params.fops = (char **)fops;
params.fopCount = fopCount;
params.pipeline = pipeline;
params.notifyURL = notifyURL;
params.force = force;
return Qiniu_FOP_Pfop_v2(self, ret, &params);
} // Qiniu_FOP_Pfop
15 changes: 14 additions & 1 deletion qiniu/fop.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Name : fop.h
Author : Qiniu.com
Copyright : 2012(c) Shanghai Qiniu Information Technologies Co., Ltd.
Description :
Description :
============================================================================
*/

Expand All @@ -22,6 +22,18 @@ extern "C"
/*============================================================================*/
/* func Qiniu_FOP_Pfop */

typedef struct _Qiniu_FOP_PfopParams
{
const char *bucket;
const char *key;
const char *pipeline;
const char *notifyURL;
char **fops;
int fopCount;
int force;
int type;
} Qiniu_FOP_PfopParams;

/* @gist pfopret */

typedef struct _Qiniu_FOP_PfopRet {
Expand All @@ -33,6 +45,7 @@ typedef struct _Qiniu_FOP_PfopRet {
QINIU_DLLAPI extern Qiniu_Error Qiniu_FOP_Pfop(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, const char *bucket,
const char *key, char *fops[], int fopCount, const char *pipeline,
const char *notifyURL, int force);
QINIU_DLLAPI extern Qiniu_Error Qiniu_FOP_Pfop_v2(Qiniu_Client *self, Qiniu_FOP_PfopRet *ret, Qiniu_FOP_PfopParams *params);

/*============================================================================*/

Expand Down
5 changes: 2 additions & 3 deletions qiniu/http.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ extern "C"
typedef struct _Qiniu_Region Qiniu_Region;
QINIU_DLLAPI extern void Qiniu_Region_Free(Qiniu_Region *region);

struct _Qiniu_Client
typedef struct _Qiniu_Client
{
void *curl;
Qiniu_Auth auth;
Expand Down Expand Up @@ -138,8 +138,7 @@ extern "C"

// Millisecond timeout for the connection phase.
long connectTimeoutMs;
};
typedef struct _Qiniu_Client Qiniu_Client;
} Qiniu_Client;

QINIU_DLLAPI extern void Qiniu_Client_InitEx(Qiniu_Client *self, Qiniu_Auth auth, size_t bufSize);
QINIU_DLLAPI extern void Qiniu_Client_Cleanup(Qiniu_Client *self);
Expand Down
5 changes: 1 addition & 4 deletions qiniu/private/region.h
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
#ifndef QINIU_PRIVATE_REGION_H
#define QINIU_PRIVATE_REGION_H
#include <stddef.h>
#include "../base.h"
#include "../http.h"

#ifdef __cplusplus
extern "C"
{
#endif

struct _Qiniu_Client;
typedef struct _Qiniu_Client Qiniu_Client;

struct _Qiniu_Region_Hosts
{
const char *const *hosts;
Expand Down
6 changes: 0 additions & 6 deletions qiniu/region.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ extern "C"
{
#endif

struct _Qiniu_Client;
typedef struct _Qiniu_Client Qiniu_Client;

struct _Qiniu_Region;
typedef struct _Qiniu_Region Qiniu_Region;

QINIU_DLLAPI extern const char *const *Qiniu_Region_Get_Up_Preferred_Hosts(Qiniu_Region *region, size_t *count);
QINIU_DLLAPI extern const char *const *Qiniu_Region_Get_Up_Alternative_Hosts(Qiniu_Region *region, size_t *count);
QINIU_DLLAPI extern const char *const *Qiniu_Region_Get_Io_Preferred_Hosts(Qiniu_Region *region, size_t *count);
Expand Down
4 changes: 4 additions & 0 deletions qiniu/rs.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ char *Qiniu_RS_PutPolicy_Token(Qiniu_RS_PutPolicy *auth, Qiniu_Mac *mac)
{
cJSON_AddNumberToObject(root, "fileType", auth->fileType);
}
if (auth->persistentType)
{
cJSON_AddNumberToObject(root, "persistentType", auth->persistentType);
}

if (auth->expires)
{
Expand Down
1 change: 1 addition & 0 deletions qiniu/rs.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ typedef struct _Qiniu_RS_PutPolicy {
Qiniu_Uint32 expires;
Qiniu_Uint32 deleteAfterDays;
Qiniu_Uint32 fileType;
Qiniu_Uint32 persistentType;
} Qiniu_RS_PutPolicy;

/* @endgist */
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qiniu-c-sdk",
"version-string": "7.7.0",
"version-string": "7.8.0",
"dependencies": [
"curl",
"openssl"
Expand Down

0 comments on commit f73e8c0

Please sign in to comment.