Skip to content

Commit 4b7e035

Browse files
Jozott00Mr3zee
authored andcommitted
grpc-native: Support client calls on native (#452)
* grpc-native: Initial client setup Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Working CompletionQueue Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Working version of NativeClientCall Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Working rewrite state Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Add callback future Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Refactor to use callbacks instead of coroutines Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Fixes after rebase Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Implement bridge to common Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Remove unnecessary C header definitions Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Rename grpcpp_c to kgrpc Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Reduce library dependencies (fixes KRPC-185) Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Write docs Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Address PR comments Signed-off-by: Johannes Zottele <[email protected]> * grpc-native: Address PR comments Signed-off-by: Johannes Zottele <[email protected]> --------- Signed-off-by: Johannes Zottele <[email protected]>
1 parent b0a8905 commit 4b7e035

File tree

39 files changed

+1745
-586
lines changed

39 files changed

+1745
-586
lines changed

cinterop-c/BUILD.bazel

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,21 @@
11
load("@rules_cc//cc:defs.bzl", "cc_library")
22

3-
cc_binary(
4-
name = "testdemo",
5-
srcs = ["src/main.cpp"],
6-
deps = [
7-
":protowire",
8-
],
9-
)
10-
113
cc_static_library(
12-
name = "grpcpp_c_static",
4+
name = "kgrpc_static",
135
deps = [
14-
":grpcpp_c",
6+
":kgrpc",
157
],
168
)
179

1810
cc_library(
19-
name = "grpcpp_c",
20-
srcs = ["src/grpcpp_c.cpp"],
21-
hdrs = glob(["include/**/*.h"]),
11+
name = "kgrpc",
12+
srcs = ["src/kgrpc.cpp"],
13+
hdrs = glob(["include/kgrpc.h"]),
2214
copts = ["-std=c++20"],
2315
includes = ["include"],
2416
visibility = ["//visibility:public"],
2517
deps = [
26-
# TODO: Reduce the dependencies and only use required once. KRPC-185
27-
"@com_github_grpc_grpc//:channelz",
28-
"@com_github_grpc_grpc//:generic_stub",
29-
"@com_github_grpc_grpc//:grpc++",
30-
"@com_github_grpc_grpc//:grpc_credentials_util",
31-
"@com_google_protobuf//:protobuf",
18+
"@com_github_grpc_grpc//:grpc"
3219
],
3320
)
3421

@@ -42,7 +29,7 @@ cc_static_library(
4229
cc_library(
4330
name = "protowire",
4431
srcs = ["src/protowire.cpp"],
45-
hdrs = glob(["include/*.h"]),
32+
hdrs = glob(["include/protowire.h"]),
4633
copts = ["-std=c++20"],
4734
includes = ["include"],
4835
visibility = ["//visibility:public"],

cinterop-c/MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module(
2-
name = "grpcpp_c",
2+
name = "kgrpc",
33
version = "0.1",
44
)
55

@@ -16,7 +16,7 @@ bazel_dep(
1616
repo_name = "com_google_protobuf",
1717
)
1818

19-
# gRPC C++ library
19+
# gRPC library
2020
bazel_dep(
2121
name = "grpc",
2222
version = "1.73.1",

cinterop-c/include/grpcpp_c.h

Lines changed: 0 additions & 66 deletions
This file was deleted.

cinterop-c/include/kgrpc.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
/*
6+
* Helper functions required for gRPC Core cinterop.
7+
*/
8+
9+
#ifndef GRPCPP_C_H
10+
#define GRPCPP_C_H
11+
12+
#include <stdbool.h>
13+
#include <grpc/grpc.h>
14+
15+
#ifdef __cplusplus
16+
extern "C" {
17+
#endif
18+
19+
/*
20+
* Struct that layouts a grpc_completion_queue_functor and user opaque data pointer,
21+
* to implement the callback mechanism in the K/N CompletionQueue.
22+
*/
23+
typedef struct {
24+
grpc_completion_queue_functor functor;
25+
void *user_data;
26+
} kgrpc_cb_tag;
27+
28+
/*
29+
* Call to grpc_iomgr_run_in_background(), which is not exposed as extern "C" and therefore must be wrapped.
30+
*/
31+
bool kgrpc_iomgr_run_in_background();
32+
33+
#ifdef __cplusplus
34+
}
35+
#endif
36+
37+
#endif //GRPCPP_C_H

cinterop-c/include/protowire.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
15
#ifndef PROTOWIRE_H
26
#define PROTOWIRE_H
37

cinterop-c/src/grpcpp_c.cpp

Lines changed: 0 additions & 201 deletions
This file was deleted.

cinterop-c/src/kgrpc.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
#include <kgrpc.h>
6+
7+
#include "src/core/lib/iomgr/iomgr.h"
8+
9+
extern "C" {
10+
11+
bool kgrpc_iomgr_run_in_background() {
12+
return grpc_iomgr_run_in_background();
13+
}
14+
15+
}
16+
17+

0 commit comments

Comments
 (0)