Skip to content

Commit 1868d08

Browse files
ivanmurashkofacebook-github-bot
authored andcommitted
glass_swift_local_client introduced
Summary: There is a local Swift Glass Client that uses [X2P](https://www.internalfb.com/wiki/X2PROD/) and can be built and run on local Darwing laptops Reviewed By: Wilfred Differential Revision: D78969332 fbshipit-source-id: a943956265ba842c3f68348633fe9f633a85b132
1 parent 64f3fa7 commit 1868d08

3 files changed

Lines changed: 77 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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/GlassAccessLocal.h"
10+
#include "c2p/secure_thrift/cpp/client/SecureThrift.h"
11+
12+
using namespace facebook;
13+
14+
GlassAccessLocal::GlassAccessLocal() {
15+
std::string connectionTier = "glean.glass";
16+
client = facebook::corp2prod::client::getClientFactory()
17+
.getClientUnique<apache::thrift::Client<::glean::GlassService>>(
18+
connectionTier);
19+
}
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 GlassAccessLocal : public GlassAccess {
14+
public:
15+
GlassAccessLocal();
16+
~GlassAccessLocal() override = default;
17+
};
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 <csignal>
10+
#include <memory>
11+
#include <utility>
12+
#include "folly/Singleton.h"
13+
#include "folly/init/Init.h"
14+
#include "glean/client/swift/GlassAccessLocal.h"
15+
#include "glean/client/swift/JsonServer.h"
16+
17+
// Folly singleton for JsonServer
18+
folly::Singleton<JsonServer> jsonServerSingleton([]() {
19+
return new JsonServer();
20+
});
21+
22+
void signalHandler(int signal) {
23+
if (signal == SIGINT) {
24+
jsonServerSingleton.try_get()->stop();
25+
}
26+
}
27+
28+
int main(int argc, char** argv) {
29+
folly::Init init(&argc, &argv);
30+
31+
std::signal(SIGINT, signalHandler);
32+
33+
// Create GlassAccessLocal and set it in JsonServer
34+
auto glassAccess = std::make_unique<GlassAccessLocal>();
35+
jsonServerSingleton.try_get()->setGlassAccess(std::move(glassAccess));
36+
37+
// Start the server
38+
jsonServerSingleton.try_get()->start();
39+
40+
return 0;
41+
}

0 commit comments

Comments
 (0)