be/src/load/routine_load/kinesis_conf.h
Line | Count | Source |
1 | | // Licensed to the Apache Software Foundation (ASF) under one |
2 | | // or more contributor license agreements. See the NOTICE file |
3 | | // distributed with this work for additional information |
4 | | // regarding copyright ownership. The ASF licenses this file |
5 | | // to you under the Apache License, Version 2.0 (the |
6 | | // "License"); you may not use this file except in compliance |
7 | | // with the License. You may obtain a copy of the License at |
8 | | // |
9 | | // http://www.apache.org/licenses/LICENSE-2.0 |
10 | | // |
11 | | // Unless required by applicable law or agreed to in writing, |
12 | | // software distributed under the License is distributed on an |
13 | | // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
14 | | // KIND, either express or implied. See the License for the |
15 | | // specific language governing permissions and limitations |
16 | | // under the License. |
17 | | |
18 | | #pragma once |
19 | | |
20 | | #include <aws/core/client/ClientConfiguration.h> |
21 | | #include <aws/kinesis/model/GetRecordsRequest.h> |
22 | | #include <aws/kinesis/model/GetShardIteratorRequest.h> |
23 | | #include <aws/kinesis/model/ListShardsRequest.h> |
24 | | |
25 | | #include <map> |
26 | | #include <string> |
27 | | |
28 | | #include "common/status.h" |
29 | | |
30 | | namespace doris { |
31 | | |
32 | | /** |
33 | | * KinesisConf - Configuration management for AWS Kinesis API parameters |
34 | | * |
35 | | * Manages less-frequently-used Kinesis API parameters, organized by API type. |
36 | | * Parameters are categorized into three maps based on which API they apply to: |
37 | | * - GetRecords API parameters (max_records, stream_arn) |
38 | | * - GetShardIterator API parameters (stream_arn, timestamp) |
39 | | * - ListShards API parameters (stream_arn, max_results) |
40 | | * |
41 | | * Note: Frequently-used parameters (stream, shards, positions) are stored |
42 | | * as explicit members in KinesisDataConsumer for better performance. |
43 | | */ |
44 | | class KinesisConf { |
45 | | public: |
46 | | enum ConfResult { CONF_OK = 0, CONF_INVALID = 1, CONF_UNKNOWN = 2 }; |
47 | | |
48 | 0 | KinesisConf() = default; |
49 | 0 | ~KinesisConf() = default; |
50 | | |
51 | | /** |
52 | | * Set a configuration property for Kinesis APIs |
53 | | * Automatically categorizes parameters by API type: |
54 | | * |
55 | | * GetRecords API: |
56 | | * - get_records.max_records: Max records per call (1-10000) |
57 | | * - get_records.stream_arn: StreamARN for enhanced fan-out |
58 | | * |
59 | | * GetShardIterator API: |
60 | | * - get_shard_iterator.stream_arn: StreamARN for enhanced fan-out |
61 | | * - get_shard_iterator.timestamp: Timestamp for AT_TIMESTAMP iterator type |
62 | | * |
63 | | * ListShards API: |
64 | | * - list_shards.stream_arn: StreamARN for enhanced fan-out |
65 | | * - list_shards.max_results: Max shards per call (1-10000) |
66 | | */ |
67 | | ConfResult set(const std::string& name, const std::string& value, std::string& errstr); |
68 | | |
69 | | Status apply_to_get_records_request(Aws::Kinesis::Model::GetRecordsRequest& request, |
70 | | const std::string& shard_iterator) const; |
71 | | |
72 | | Status apply_to_get_shard_iterator_request( |
73 | | Aws::Kinesis::Model::GetShardIteratorRequest& request, const std::string& stream_name, |
74 | | const std::string& shard_id, const std::string& sequence_number) const; |
75 | | |
76 | | Status apply_to_list_shards_request(Aws::Kinesis::Model::ListShardsRequest& request, |
77 | | const std::string& stream_name) const; |
78 | | |
79 | | private: |
80 | | // Separate parameter maps for each API |
81 | | std::map<std::string, std::string> _get_records_params; |
82 | | std::map<std::string, std::string> _get_shard_iterator_params; |
83 | | std::map<std::string, std::string> _list_shards_params; |
84 | | |
85 | | bool parse_int(const std::string& value, int& result, std::string& errstr) const; |
86 | | bool parse_long(const std::string& value, long& result, std::string& errstr) const; |
87 | | }; |
88 | | |
89 | | } // namespace doris |