-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Pull Request resolved: #280 Making the GCS Client a singleton Differential Revision: D37853909 fbshipit-source-id: 89f7f603f51801f9c9980e94e33960efd6a403e4
- Loading branch information
1 parent
74e793e
commit b20b0f0
Showing
3 changed files
with
63 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#include <google/cloud/storage/client.h> | ||
|
||
#include "fbpcf/io/cloud_util/GCSClient.h" | ||
|
||
namespace fbpcf::cloudio { | ||
GCSClient& GCSClient::getInstance(const fbpcf::gcp::GCSClientOption& option) { | ||
static GCSClient GCSClient(option); | ||
return GCSClient; | ||
} | ||
} // namespace fbpcf::cloudio |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
|
||
#include <google/cloud/storage/client.h> | ||
#include "fbpcf/gcp/GCSUtil.h" | ||
|
||
namespace fbpcf::cloudio { | ||
|
||
class GCSClient { | ||
private: | ||
explicit GCSClient(const fbpcf::gcp::GCSClientOption& option) { | ||
GCSClient_ = fbpcf::gcp::createGCSClient(); | ||
} | ||
|
||
public: | ||
static GCSClient& getInstance(const fbpcf::gcp::GCSClientOption& option); | ||
|
||
std::shared_ptr<google::cloud::storage::Client> getGCSClient() { | ||
return GCSClient_; | ||
} | ||
|
||
private: | ||
std::shared_ptr<google::cloud::storage::Client> GCSClient_; | ||
}; | ||
|
||
} // namespace fbpcf::cloudio |