mirror of
https://github.com/apple/foundationdb.git
synced 2025-05-22 23:19:02 +08:00
clang-format S3BlobStore* files
This commit is contained in:
parent
4666f59c4c
commit
ac274cf479
fdbclient
@ -247,11 +247,10 @@ Reference<S3BlobStoreEndpoint> S3BlobStoreEndpoint::fromString(std::string const
|
|||||||
StringRef c(cred.get());
|
StringRef c(cred.get());
|
||||||
StringRef key = c.eat(":");
|
StringRef key = c.eat(":");
|
||||||
StringRef secret = c.eat();
|
StringRef secret = c.eat();
|
||||||
creds = S3BlobStoreEndpoint::Credentials{key.toString(), secret.toString()};
|
creds = S3BlobStoreEndpoint::Credentials{ key.toString(), secret.toString() };
|
||||||
}
|
}
|
||||||
|
|
||||||
return makeReference<S3BlobStoreEndpoint>(
|
return makeReference<S3BlobStoreEndpoint>(host.toString(), service.toString(), creds, knobs, extraHeaders);
|
||||||
host.toString(), service.toString(), creds, knobs, extraHeaders);
|
|
||||||
|
|
||||||
} catch (std::string& err) {
|
} catch (std::string& err) {
|
||||||
if (error != nullptr)
|
if (error != nullptr)
|
||||||
@ -277,7 +276,7 @@ std::string S3BlobStoreEndpoint::getResourceURL(std::string resource, std::strin
|
|||||||
if (credentials.present()) {
|
if (credentials.present()) {
|
||||||
credsString = credentials.get().key;
|
credsString = credentials.get().key;
|
||||||
if (!lookupSecret) {
|
if (!lookupSecret) {
|
||||||
credsString +=":" + credentials.get().secret;
|
credsString += ":" + credentials.get().secret;
|
||||||
}
|
}
|
||||||
credsString += "@";
|
credsString += "@";
|
||||||
}
|
}
|
||||||
@ -527,7 +526,7 @@ ACTOR Future<Void> updateSecret_impl(Reference<S3BlobStoreEndpoint> b) {
|
|||||||
std::string secret;
|
std::string secret;
|
||||||
// Once we find a matching account, use it.
|
// Once we find a matching account, use it.
|
||||||
if (account.tryGet("secret", secret)) {
|
if (account.tryGet("secret", secret)) {
|
||||||
b->credentials = S3BlobStoreEndpoint::Credentials{accessKey, secret};
|
b->credentials = S3BlobStoreEndpoint::Credentials{ accessKey, secret };
|
||||||
return Void();
|
return Void();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1060,7 +1059,7 @@ Future<std::vector<std::string>> S3BlobStoreEndpoint::listBuckets() {
|
|||||||
return listBuckets_impl(Reference<S3BlobStoreEndpoint>::addRef(this));
|
return listBuckets_impl(Reference<S3BlobStoreEndpoint>::addRef(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string S3BlobStoreEndpoint::hmac_sha1(Credentials const &creds, std::string const& msg) {
|
std::string S3BlobStoreEndpoint::hmac_sha1(Credentials const& creds, std::string const& msg) {
|
||||||
std::string key = creds.secret;
|
std::string key = creds.secret;
|
||||||
|
|
||||||
// Hash key to shorten it if it is longer than SHA1 block size
|
// Hash key to shorten it if it is longer than SHA1 block size
|
||||||
|
@ -95,20 +95,22 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
S3BlobStoreEndpoint(std::string const &host, std::string service, Optional<Credentials> const& creds, BlobKnobs const &knobs = BlobKnobs(), HTTP::Headers extraHeaders = HTTP::Headers())
|
S3BlobStoreEndpoint(std::string const& host,
|
||||||
: host(host), service(service), credentials(creds), lookupSecret(creds.present() && creds.get().secret.empty()), knobs(knobs), extraHeaders(extraHeaders),
|
std::string service,
|
||||||
requestRate(new SpeedLimit(knobs.requests_per_second, 1)),
|
Optional<Credentials> const& creds,
|
||||||
requestRateList(new SpeedLimit(knobs.list_requests_per_second, 1)),
|
BlobKnobs const& knobs = BlobKnobs(),
|
||||||
requestRateWrite(new SpeedLimit(knobs.write_requests_per_second, 1)),
|
HTTP::Headers extraHeaders = HTTP::Headers())
|
||||||
requestRateRead(new SpeedLimit(knobs.read_requests_per_second, 1)),
|
: host(host), service(service), credentials(creds), lookupSecret(creds.present() && creds.get().secret.empty()),
|
||||||
requestRateDelete(new SpeedLimit(knobs.delete_requests_per_second, 1)),
|
knobs(knobs), extraHeaders(extraHeaders), requestRate(new SpeedLimit(knobs.requests_per_second, 1)),
|
||||||
sendRate(new SpeedLimit(knobs.max_send_bytes_per_second, 1)),
|
requestRateList(new SpeedLimit(knobs.list_requests_per_second, 1)),
|
||||||
recvRate(new SpeedLimit(knobs.max_recv_bytes_per_second, 1)),
|
requestRateWrite(new SpeedLimit(knobs.write_requests_per_second, 1)),
|
||||||
concurrentRequests(knobs.concurrent_requests),
|
requestRateRead(new SpeedLimit(knobs.read_requests_per_second, 1)),
|
||||||
concurrentUploads(knobs.concurrent_uploads),
|
requestRateDelete(new SpeedLimit(knobs.delete_requests_per_second, 1)),
|
||||||
concurrentLists(knobs.concurrent_lists) {
|
sendRate(new SpeedLimit(knobs.max_send_bytes_per_second, 1)),
|
||||||
|
recvRate(new SpeedLimit(knobs.max_recv_bytes_per_second, 1)), concurrentRequests(knobs.concurrent_requests),
|
||||||
|
concurrentUploads(knobs.concurrent_uploads), concurrentLists(knobs.concurrent_lists) {
|
||||||
|
|
||||||
if(host.empty())
|
if (host.empty())
|
||||||
throw connection_string_invalid();
|
throw connection_string_invalid();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,7 +166,7 @@ public:
|
|||||||
Future<Void> updateSecret();
|
Future<Void> updateSecret();
|
||||||
|
|
||||||
// Calculates the authentication string from the secret key
|
// Calculates the authentication string from the secret key
|
||||||
static std::string hmac_sha1(Credentials const &creds, std::string const &msg);
|
static std::string hmac_sha1(Credentials const& creds, std::string const& msg);
|
||||||
|
|
||||||
// Sets headers needed for Authorization (including Date which will be overwritten if present)
|
// Sets headers needed for Authorization (including Date which will be overwritten if present)
|
||||||
void setAuthHeaders(std::string const& verb, std::string const& resource, HTTP::Headers& headers);
|
void setAuthHeaders(std::string const& verb, std::string const& resource, HTTP::Headers& headers);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user