annotate Framework/TransferToolbox.h @ 61:2bdb38da2562

contributing
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 14 Aug 2023 10:20:13 +0200
parents f4e828607f02
children 1e396fb509ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Transfers accelerator plugin for Orthanc
33
44a0430d7899 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 19
diff changeset
3 * Copyright (C) 2018-2021 Osimis S.A., Belgium
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 *
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * This program is free software: you can redistribute it and/or
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * modify it under the terms of the GNU Affero General Public License
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * as published by the Free Software Foundation, either version 3 of
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * the License, or (at your option) any later version.
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 *
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * This program is distributed in the hope that it will be useful, but
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * Affero General Public License for more details.
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 *
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * You should have received a copy of the GNU Affero General Public License
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 **/
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 #pragma once
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #include <stdint.h>
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include <string>
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
24 #include <json/value.h>
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 static const unsigned int KB = 1024;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 static const unsigned int MB = 1024 * 1024;
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 static const char* const JOB_TYPE_PULL = "PullTransfer";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 static const char* const JOB_TYPE_PUSH = "PushTransfer";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 static const char* const PLUGIN_NAME = "transfers";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 static const char* const KEY_BUCKETS = "Buckets";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 static const char* const KEY_COMPRESSION = "Compression";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 static const char* const KEY_ID = "ID";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 static const char* const KEY_INSTANCES = "Instances";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 static const char* const KEY_LEVEL = "Level";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 static const char* const KEY_OFFSET = "Offset";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 static const char* const KEY_ORIGINATOR_UUID = "Originator";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 static const char* const KEY_PATH = "Path";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 static const char* const KEY_PEER = "Peer";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 static const char* const KEY_PLUGIN_CONFIGURATION = "Transfers";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 static const char* const KEY_PRIORITY = "Priority";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 static const char* const KEY_REMOTE_JOB = "RemoteJob";
5
5e6de82bb10f use of user properties instead of BidirectionalPeers option
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4
diff changeset
46 static const char* const KEY_REMOTE_SELF = "RemoteSelf";
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 static const char* const KEY_RESOURCES = "Resources";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 static const char* const KEY_SIZE = "Size";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 static const char* const KEY_URL = "URL";
44
f4e828607f02 Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
50 static const char* const KEY_SENDER_TRANSFER_ID = "SenderTransferID";
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 static const char* const URI_CHUNKS = "/transfers/chunks";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 static const char* const URI_JOBS = "/jobs";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 static const char* const URI_LOOKUP = "/transfers/lookup";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 static const char* const URI_PEERS = "/transfers/peers";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 static const char* const URI_PLUGINS = "/plugins";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 static const char* const URI_PULL = "/transfers/pull";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 static const char* const URI_PUSH = "/transfers/push";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 static const char* const URI_SEND = "/transfers/send";
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
44
f4e828607f02 Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
61 static const char* const HEADER_KEY_SENDER_TRANSFER_ID = "sender-transfer-id";
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 namespace OrthancPlugins
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
65 class OrthancPeers;
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
66
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 enum BucketCompression
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 {
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 BucketCompression_None,
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 BucketCompression_Gzip
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 };
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 unsigned int ConvertToMegabytes(uint64_t value);
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 unsigned int ConvertToKilobytes(uint64_t value);
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 BucketCompression StringToBucketCompression(const std::string& value);
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 const char* EnumerationToString(BucketCompression compression);
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
80
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
81 bool DoPostPeer(Json::Value& answer,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
82 const OrthancPeers& peers,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
83 size_t peerIndex,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
84 const std::string& uri,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
85 const std::string& body,
44
f4e828607f02 Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
86 unsigned int maxRetries,
f4e828607f02 Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
87 const std::map<std::string, std::string>& headers);
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
88
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
89 bool DoPostPeer(Json::Value& answer,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
90 const OrthancPeers& peers,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
91 const std::string& peerName,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
92 const std::string& uri,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
93 const std::string& body,
44
f4e828607f02 Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
94 unsigned int maxRetries,
f4e828607f02 Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
95 const std::map<std::string, std::string>& headers);
10
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
96
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
97 bool DoDeletePeer(const OrthancPeers& peers,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
98 size_t peerIndex,
c9e28e31262e new option: MaxHttpRetries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 9
diff changeset
99 const std::string& uri,
44
f4e828607f02 Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
100 unsigned int maxRetries,
f4e828607f02 Added 'SenderTransferID' option that is added as an HTTP header in outgoing requests in PushMode
Alain Mazy <am@osimis.io>
parents: 33
diff changeset
101 const std::map<std::string, std::string>& headers);
0
95226b754d9e initial release
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 }