-
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: Making the GCS Client a singleton Differential Revision: D37853909 fbshipit-source-id: 37d1cc0da1d24ab467e5f9f99ebfab3105a2caad
- Loading branch information
1 parent
14b0e6b
commit 5098e6c
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 |