Skip to content

Commit

Permalink
Merge pull request #115
Browse files Browse the repository at this point in the history
Cleanup protos
  • Loading branch information
uatuko authored Nov 14, 2024
2 parents 31d51d3 + 29331e3 commit 3ef1052
Show file tree
Hide file tree
Showing 17 changed files with 368 additions and 253 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ if (RUEK_ENABLE_COVERAGE)
endif()

include(cmake/dependencies.cmake)
include(cmake/googleapis.cmake)

if (RUEK_BUILD_TESTING)
enable_testing()
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ docker run --network=ruek-net --name=ruek -e PGHOST=pg -e PGUSER=ruek -e PGPASSW
## Built with

* [fmt](https://github.com/fmtlib/fmt) - For string formatting.
* [googleapis](https://github.com/googleapis/googleapis) - For annotations to help with gRPC/JSON transcoding.
* [googletest](https://github.com/google/googletest) - For tests.
* [benchmark](https://github.com/google/benchmark) - For benchmarks.
* [grpcxx](https://github.com/uatuko/grpcxx) - For the gRPC server.
Expand Down
7 changes: 0 additions & 7 deletions cmake/dependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ FetchContent_Declare(fmt
)
FetchContent_MakeAvailable(fmt)

# googleapis
FetchContent_Declare(googleapis
URL https://github.com/googleapis/googleapis/archive/0e3b813b0d0da539eacbe86b8716feeed00943c5.tar.gz
URL_HASH SHA256=44f3b9c73a5df760c4fad3cf0c5cc54732b881f00708308f7635ff75a13dcaa5
)
FetchContent_MakeAvailable(googleapis)

# grpcxx
FetchContent_Declare(grpcxx
URL https://github.com/uatuko/grpcxx/archive/refs/tags/v0.2.0.tar.gz
Expand Down
56 changes: 0 additions & 56 deletions cmake/googleapis.cmake

This file was deleted.

35 changes: 5 additions & 30 deletions docs/api/v1/principals.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ service Principals {}
Create a new principal.

```proto
rpc Create(PrincipalsCreateRequest) returns (Principal) {
option (google.api.http) = {
post : "/v1/principals"
body : "*"
};
}
rpc Create(PrincipalsCreateRequest) returns (Principal);
```

### Request message
Expand All @@ -61,7 +56,6 @@ rpc Create(PrincipalsCreateRequest) returns (Principal) {
```
❯ grpcurl \
-import-path proto \
-import-path ./.build/_deps/googleapis-src \
-proto proto/ruek/api/v1/principals.proto \
-plaintext \
localhost:8080 ruek.api.v1.Principals/Create
Expand All @@ -77,12 +71,7 @@ rpc Create(PrincipalsCreateRequest) returns (Principal) {
Delete an existing principal.

```proto
rpc Delete(PrincipalsDeleteRequest) returns (PrincipalsDeleteResponse) {
option (google.api.http) = {
delete : "/v1/principals/{id}"
body : "*"
};
}
rpc Delete(PrincipalsDeleteRequest) returns (PrincipalsDeleteResponse);
```

### Request message
Expand All @@ -99,11 +88,7 @@ rpc Delete(PrincipalsDeleteRequest) returns (PrincipalsDeleteResponse) {
List principals.

```proto
rpc List(PrincipalsListRequest) returns (PrincipalsListResponse) {
option (google.api.http) = {
get : "/v1/principals?segment={segment}&_limit={pagination_limit}&_start={pagination_token}"
};
}
rpc List(PrincipalsListRequest) returns (PrincipalsListResponse);
```

### Request message
Expand All @@ -119,7 +104,6 @@ rpc List(PrincipalsListRequest) returns (PrincipalsListResponse) {
```
❯ grpcurl \
-import-path proto \
-import-path ./.build/_deps/googleapis-src \
-proto proto/ruek/api/v1/principals.proto \
-plaintext \
localhost:8080 ruek.api.v1.Principals/List
Expand All @@ -142,11 +126,7 @@ rpc List(PrincipalsListRequest) returns (PrincipalsListResponse) {
Retrieve a principal.

```proto
rpc Retrieve(PrincipalsRetrieveRequest) returns (Principal) {
option (google.api.http) = {
get : "/v1/principals/{id}"
};
}
rpc Retrieve(PrincipalsRetrieveRequest) returns (Principal);
```

### Request message
Expand All @@ -163,12 +143,7 @@ rpc Retrieve(PrincipalsRetrieveRequest) returns (Principal) {
Update a principal.

```proto
rpc Update(PrincipalsUpdateRequest) returns (Principal) {
option (google.api.http) = {
put : "/v1/principals/{id}"
body : "*"
};
}
rpc Update(PrincipalsUpdateRequest) returns (Principal);
```

### Request message
Expand Down
33 changes: 5 additions & 28 deletions docs/api/v1/relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,7 @@ service Relations {}
Check if a relation exists.

```proto
rpc Check(RelationsCheckRequest) returns (RelationsCheckResponse) {
option (google.api.http) = {
post : "/v1/relations:check"
body : "*"
};
}
rpc Check(RelationsCheckRequest) returns (RelationsCheckResponse);
```

### Request message
Expand All @@ -67,12 +62,7 @@ rpc Check(RelationsCheckRequest) returns (RelationsCheckResponse) {
Create a new relation.

```proto
rpc Create(RelationsCreateRequest) returns (RelationsCreateResponse) {
option (google.api.http) = {
post : "/v1/relations"
body : "*"
};
}
rpc Create(RelationsCreateRequest) returns (RelationsCreateResponse);
```

### Request message
Expand All @@ -89,12 +79,7 @@ rpc Create(RelationsCreateRequest) returns (RelationsCreateResponse) {
Delete an existing relation.

```proto
rpc Delete(RelationsDeleteRequest) returns (RelationsDeleteResponse) {
option (google.api.http) = {
post : "/v1/relations:delete"
body : "*"
};
}
rpc Delete(RelationsDeleteRequest) returns (RelationsDeleteResponse);
```

### Request message
Expand All @@ -111,11 +96,7 @@ rpc Delete(RelationsDeleteRequest) returns (RelationsDeleteResponse) {
List relations to the left of a relation.

```proto
rpc ListLeft(RelationsListLeftRequest) returns (RelationsListLeftResponse) {
option (google.api.http) = {
get : "/v1/relations:left?_limit={pagination_limit}&_start={pagination_token}"
};
}
rpc ListLeft(RelationsListLeftRequest) returns (RelationsListLeftResponse);
```

### Request message
Expand All @@ -132,11 +113,7 @@ rpc ListLeft(RelationsListLeftRequest) returns (RelationsListLeftResponse) {
List relations to the right of a relation.

```proto
rpc ListRight(RelationsListRightRequest) returns (RelationsListRightResponse) {
option (google.api.http) = {
get : "/v1/relations:right?_limit={pagination_limit}&_start={pagination_token}"
};
}
rpc ListRight(RelationsListRightRequest) returns (RelationsListRightResponse);
```

### Request message
Expand Down
41 changes: 39 additions & 2 deletions proto/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# ruek/api/v1/**/*.proto
cmake_path(SET authz_proto ${CMAKE_CURRENT_SOURCE_DIR}/ruek/api/v1/authz.proto)
cmake_path(SET authz_grpcxx_header ${CMAKE_CURRENT_BINARY_DIR}/ruek/api/v1/authz.grpcxx.pb.h)
cmake_path(SET authz_header ${CMAKE_CURRENT_BINARY_DIR}/ruek/api/v1/authz.pb.h)
Expand Down Expand Up @@ -45,7 +46,6 @@ add_custom_command(
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
ARGS
--proto_path=${CMAKE_CURRENT_SOURCE_DIR}
--proto_path=${googleapis_SOURCE_DIR}
--proto_path=${Protobuf_INCLUDE_DIR}
--cpp_out=${CMAKE_CURRENT_BINARY_DIR}
--grpcxx_out=${CMAKE_CURRENT_BINARY_DIR}
Expand All @@ -54,6 +54,7 @@ add_custom_command(
)


# ruek/detail/**/*.proto
cmake_path(SET detail_pagination_proto ${CMAKE_CURRENT_SOURCE_DIR}/ruek/detail/pagination.proto)
cmake_path(SET detail_pagination_header ${CMAKE_CURRENT_BINARY_DIR}/ruek/detail/pagination.pb.h)
cmake_path(SET detail_pagination_source ${CMAKE_CURRENT_BINARY_DIR}/ruek/detail/pagination.pb.cc)
Expand Down Expand Up @@ -82,17 +83,53 @@ add_custom_command(
)


# google/rpc/**/*.proto
cmake_path(SET google_rpc_code_proto ${CMAKE_CURRENT_SOURCE_DIR}/google/rpc/code.proto)
cmake_path(SET google_rpc_code_header ${CMAKE_CURRENT_BINARY_DIR}/google/rpc/code.pb.h)
cmake_path(SET google_rpc_code_source ${CMAKE_CURRENT_BINARY_DIR}/google/rpc/code.pb.cc)

cmake_path(SET google_rpc_status_proto ${CMAKE_CURRENT_SOURCE_DIR}/google/rpc/status.proto)
cmake_path(SET google_rpc_status_header ${CMAKE_CURRENT_BINARY_DIR}/google/rpc/status.pb.h)
cmake_path(SET google_rpc_status_source ${CMAKE_CURRENT_BINARY_DIR}/google/rpc/status.pb.cc)

set(google_protos
${google_rpc_code_proto}
${google_rpc_status_proto}
)

set(google_headers
${google_rpc_code_header}
${google_rpc_status_header}
)

set(google_sources
${google_rpc_code_source}
${google_rpc_status_source}
)

add_custom_command(
OUTPUT ${google_headers} ${google_sources}
DEPENDS ${google_protos}
COMMAND ${Protobuf_PROTOC_EXECUTABLE}
ARGS
--proto_path=${CMAKE_CURRENT_SOURCE_DIR}
--proto_path=${Protobuf_INCLUDE_DIR}
--cpp_out=${CMAKE_CURRENT_BINARY_DIR}
${google_protos}
)


add_library(proto
${sources}
${detail_sources}
${google_sources}
)

target_include_directories(proto
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
)

target_link_libraries(proto
googleapis
libgrpcxx::grpcxx
protobuf::libprotobuf
)
Expand Down
1 change: 1 addition & 0 deletions proto/google/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DisableFormat: true
Loading

0 comments on commit 3ef1052

Please sign in to comment.