Skip to content

Commit 2578334

Browse files
alitoukainsrc-copybara[bot]
authored andcommitted
SDK update
GitOrigin-RevId: fae22520f69e21d770997501d447a130ce7edd91
1 parent 466e88a commit 2578334

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

intrinsic/platform/pubsub/kvstore.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@
3737

3838
ABSL_FLAG(bool, use_replicated_kv_store, false,
3939
"If true, use the replicated KV store.");
40+
ABSL_FLAG(std::string, admin_set_proxy_endpoint,
41+
"zenoh-router.app-intrinsic-base.svc.cluster.local:8081",
42+
"Override the default admin set proxy URL");
4043

4144
namespace intrinsic {
4245

4346
using platform::proto::WorkcellInfo;
4447

4548
namespace {
4649
constexpr static absl::Duration kHighConsistencyTimeout = absl::Seconds(30);
47-
constexpr static absl::string_view kAdminSetProxyEndpoint =
48-
"zenoh-router.app-intrinsic-base.svc.cluster.local:8081";
4950
constexpr static absl::string_view kWorkcellInfoKey = "workcell_info";
5051
} // namespace
5152

@@ -324,7 +325,7 @@ absl::Status KeyValueStore::AdminCloudCopy(absl::string_view source_key,
324325
GetAny(source_key, timeout));
325326

326327
std::shared_ptr<::grpc::Channel> channel = ::grpc::CreateCustomChannel(
327-
std::string(kAdminSetProxyEndpoint),
328+
absl::GetFlag(FLAGS_admin_set_proxy_endpoint),
328329
::grpc:: // NOLINTNEXTLINE
329330
InsecureChannelCredentials(), // NO_LINT(grpc_insecure_credential_linter)
330331
::grpc::ChannelArguments());

intrinsic/platform/pubsub/kvstore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "intrinsic/util/status/status_macros.h"
2929

3030
ABSL_DECLARE_FLAG(bool, use_replicated_kv_store);
31+
ABSL_DECLARE_FLAG(std::string, admin_set_proxy_endpoint);
3132

3233
namespace intrinsic {
3334

intrinsic/platform/pubsub/python/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ pybind_extension(
1616
"//intrinsic/platform/pubsub:publisher",
1717
"//intrinsic/platform/pubsub:subscription",
1818
"@abseil-cpp//absl/container:flat_hash_map",
19+
"@abseil-cpp//absl/flags:parse",
1920
"@abseil-cpp//absl/status",
2021
"@abseil-cpp//absl/status:statusor",
2122
"@abseil-cpp//absl/strings",

intrinsic/platform/pubsub/python/pubsub.cc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <vector>
1616

1717
#include "absl/container/flat_hash_map.h"
18+
#include "absl/flags/parse.h"
1819
#include "absl/log/log.h"
1920
#include "absl/status/status.h"
2021
#include "absl/status/statusor.h"
@@ -267,6 +268,17 @@ std::string MakeKey(pybind11::args args) {
267268
return KeyValueStore::MakeKeyFromVector(parts);
268269
}
269270

271+
void ParseCommandLine(const std::vector<std::string>& args) {
272+
std::vector<char*> argv_c;
273+
for (const auto& arg : args) {
274+
argv_c.push_back(const_cast<char*>(arg.c_str()));
275+
}
276+
int argc_c = argv_c.size();
277+
char** argv_c_ptr = argv_c.data();
278+
279+
absl::ParseCommandLine(argc_c, argv_c_ptr);
280+
}
281+
270282
struct PySubscriptionDeleter {
271283
void operator()(Subscription* s) {
272284
// To avoid deadlock, the call to Zenoh.imw_destroy_subscription() needs
@@ -377,6 +389,11 @@ PYBIND11_MODULE(pubsub, m) {
377389
m, "Subscription")
378390
.def("TopicName", &Subscription::TopicName)
379391
.def("Unsubscribe", &Subscription::Unsubscribe);
392+
393+
// Helper function for passing command line flags from Python code
394+
// to C++. Can be used in Python tests which start their own Zenoh routers,
395+
// and need to pass their URLs to C++ code.
396+
m.def("parse_command_line", &ParseCommandLine);
380397
}
381398

382399
} // namespace pubsub

0 commit comments

Comments
 (0)