Skip to content

Commit 64f3fa7

Browse files
ivanmurashkofacebook-github-bot
authored andcommitted
glass_swift_remote_client introduced
Summary: There is a remote Swift Glass Client that uses ServiceRouter and can be built and run on DevServer/OnDemand Reviewed By: dmpolukhin Differential Revision: D78965427 fbshipit-source-id: 0ea3ce81db4ab78b4492ccdab16c4bf40bc0e367
1 parent fb48f78 commit 64f3fa7

5 files changed

Lines changed: 45 additions & 15 deletions

File tree

glean/client/swift/GlassAccess.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,13 @@
1111
#include <folly/String.h>
1212
#include <folly/coro/BlockingWait.h>
1313
#include <glog/logging.h>
14-
#include "servicerouter/client/cpp2/ServiceRouter.h"
1514

1615
using namespace facebook;
1716
using apache::thrift::RpcOptions;
1817

1918
const auto GlassTimeoutMs = 900;
2019

21-
GlassAccess::GlassAccess() {
22-
auto params = facebook::servicerouter::ClientParams().setProcessingTimeoutMs(
23-
std::chrono::milliseconds(10000));
24-
25-
std::string connectionTier = "glean.glass";
26-
client =
27-
servicerouter::cpp2::getClientFactory()
28-
.getSRClientUnique<apache::thrift::Client<::glean::GlassService>>(
29-
connectionTier, params);
30-
}
20+
GlassAccess::GlassAccess() : client(nullptr) {}
3121

3222
std::optional<protocol::LocationList> GlassAccess::usrToDefinition(
3323
const std::string& usr) {

glean/client/swift/GlassAccess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class GlassAccess : public IGlassAccess {
2222
std::optional<protocol::LocationList> usrToDefinition(
2323
const std::string& usr) override;
2424

25-
private:
25+
protected:
2626
template <typename T>
2727
std::optional<T> runGlassMethod(
2828
const std::string& method,
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
#include "glean/client/swift/GlassAccessRemote.h"
10+
#include "servicerouter/client/cpp2/ServiceRouter.h"
11+
12+
using namespace facebook;
13+
14+
GlassAccessRemote::GlassAccessRemote() {
15+
auto params = facebook::servicerouter::ClientParams().setProcessingTimeoutMs(
16+
std::chrono::milliseconds(10000));
17+
18+
std::string connectionTier = "glean.glass";
19+
client =
20+
servicerouter::cpp2::getClientFactory()
21+
.getSRClientUnique<apache::thrift::Client<::glean::GlassService>>(
22+
connectionTier, params);
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
#pragma once
10+
11+
#include "glean/client/swift/GlassAccess.h"
12+
13+
class GlassAccessRemote : public GlassAccess {
14+
public:
15+
GlassAccessRemote();
16+
~GlassAccessRemote() override = default;
17+
};

glean/client/swift/GlassSwiftClient.cpp renamed to glean/client/swift/GlassSwiftRemoteClient.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <memory>
1111
#include "folly/Singleton.h"
1212
#include "folly/init/Init.h"
13-
#include "glean/client/swift/GlassAccess.h"
13+
#include "glean/client/swift/GlassAccessRemote.h"
1414
#include "glean/client/swift/JsonServer.h"
1515

1616
// Folly singleton for JsonServer
@@ -29,8 +29,8 @@ int main(int argc, char** argv) {
2929

3030
std::signal(SIGINT, signalHandler);
3131

32-
// Create GlassAccess and set it in JsonServer
33-
auto glassAccess = std::make_unique<GlassAccess>();
32+
// Create GlassAccessRemote and set it in JsonServer
33+
auto glassAccess = std::make_unique<GlassAccessRemote>();
3434
jsonServerSingleton.try_get()->setGlassAccess(std::move(glassAccess));
3535

3636
// Start the server

0 commit comments

Comments
 (0)