Debian Codegraph @

crt/aws-c-s3/include/aws/s3/private/s3_auto_ranged_put.h

raw symbols SCIP
1 #ifndef AWS_S3_AUTO_RANGED_PUT_H
2 #define AWS_S3_AUTO_RANGED_PUT_H
3
4 /**
5 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
6 * SPDX-License-Identifier: Apache-2.0.
7 */
8
9 #include "aws/s3/private/s3_meta_request_impl.h"
10 #include "s3_paginator.h"
11
12 enum aws_s3_auto_ranged_put_request_tag {
13 AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_LIST_PARTS,
14 AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_CREATE_MULTIPART_UPLOAD,
15 AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_PART,
16 AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_ABORT_MULTIPART_UPLOAD,
17 AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_COMPLETE_MULTIPART_UPLOAD,
18
19 AWS_S3_AUTO_RANGED_PUT_REQUEST_TAG_MAX,
20 };
21
22 struct aws_s3_auto_ranged_put {
23 struct aws_s3_meta_request base;
24
25 /* Initialized either during creation in resume flow or as result of create multipart upload during normal flow. */
26 struct aws_string *upload_id;
27
28 /* Resume token used to resume the operation */
29 struct aws_s3_meta_request_resume_token *resume_token;
30
31 uint64_t content_length;
32 bool has_content_length;
33
34 /*
35 * total_num_parts_from_content_length is calculated by content_length / part_size.
36 * It will be 0 if there is no content_length.
37 */
38 uint32_t total_num_parts_from_content_length;
39
40 /* Only meant for use in the update function, which is never called concurrently. */
41 struct {
42 /*
43 * Next part number to send.
44 * Note: this follows s3 part number convention and counting starts with 1.
45 * Throughout codebase 0 based part numbers are usually referred to as part index.
46 */
47 uint32_t next_part_number;
48 } threaded_update_data;
49
50 /* Members to only be used when the mutex in the base type is locked. */
51 struct {
52 /* Array list of `struct aws_s3_mpu_part_info *`
53 * Info about each part, that we need to remember for CompleteMultipartUpload.
54 * This is updated as we upload each part.
55 * If resuming an upload, we first call ListParts and store the details
56 * of previously uploaded parts here. In this case, the array may start with gaps
57 * (e.g. if parts 1 and 3 were previously uploaded, but not part 2). */
58 struct aws_array_list part_list;
59
60 struct aws_s3_paginated_operation *list_parts_operation;
61 struct aws_string *list_parts_continuation_token;
62
63 /* Number of parts we've started work on */
64 uint32_t num_parts_started;
65 /* Number of parts we've started, and we have no more work to do */
66 uint32_t num_parts_completed;
67 uint32_t num_parts_successful;
68 uint32_t num_parts_failed;
69 /* When content length is not known, requests are optimistically
70 * scheduled, below represents how many requests were scheduled and had no
71 * work to do*/
72 uint32_t num_parts_noop;
73
74 /* Number of parts we've started, but they're not done reading from stream yet.
75 * Though reads are serial (only 1 part can be reading from stream at a time)
76 * we may queue up more to minimize delays between each read. */
77 uint32_t num_parts_pending_read;
78
79 struct aws_http_headers *needed_response_headers;
80
81 /* Whether body stream is exhausted. */
82 bool is_body_stream_at_end;
83
84 int list_parts_error_code;
85 int create_multipart_upload_error_code;
86 int complete_multipart_upload_error_code;
87 int abort_multipart_upload_error_code;
88
89 struct {
90 /* Mark a single ListParts request has started or not */
91 uint32_t started : 1;
92 /* Mark ListParts need to continue or not */
93 uint32_t continues : 1;
94 /* Mark ListParts has completed all the pages or not */
95 uint32_t completed : 1;
96 } list_parts_state;
97 uint32_t create_multipart_upload_sent : 1;
98 uint32_t create_multipart_upload_completed : 1;
99 uint32_t complete_multipart_upload_sent : 1;
100 uint32_t complete_multipart_upload_completed : 1;
101 uint32_t abort_multipart_upload_sent : 1;
102 uint32_t abort_multipart_upload_completed : 1;
103
104 } synced_data;
105 };
106
107 AWS_EXTERN_C_BEGIN
108
109 /* Creates a new auto-ranged put meta request.
110 * This will do a multipart upload in parallel when appropriate.
111 * Note: if has_content_length is false, content_length and num_parts are ignored.
112 */
113
114 AWS_S3_API struct aws_s3_meta_request *aws_s3_meta_request_auto_ranged_put_new(
115 struct aws_allocator *allocator,
116 struct aws_s3_client *client,
117 size_t part_size,
118 bool has_content_length,
119 uint64_t content_length,
120 uint32_t num_parts,
121 const struct aws_s3_meta_request_options *options);
122
123 AWS_EXTERN_C_END
124
125 #endif /* AWS_S3_AUTO_RANGED_PUT_H */