Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cmd-api-server): add ConnectRPC auto-registration for plugins #3183

Conversation

petermetz
Copy link
Contributor

  1. This is enabling plugins to expose their operations via ConnectRPC
    services which is very similar to gRPC but it comes with a few extra
    bells and whistles that can come in very handy.
  2. There is an upcoming pull request that makes it so that the keychain
    memory plugin implements and registers its services via this newly added
    hook of the API server. The importance of this is that test coverage for
    the code in this commit resides on another branch, meaning that even though
    there are no new test cases on this branch, the feature has been extensively
    tested and there is test-automation in place to continue verifying it
    as well.
  3. The main difference between the hook methods are that for CRPC the
    API server expects an array of service definition+implementation pairs
    instead of just a single one. This was a design decision forced by the
    issues with implementing separate services in a single class: The compiler
    was hard to appease in a way that kept the code clean. gRPC did not suffer
    from this and therefore the registration methods defined for that only
    return a single gRPC service defintion+implementation pair which can combine
    any number of .proto services.

Signed-off-by: Peter Somogyvari [email protected]

Pull Request Requirements

  • Rebased onto upstream/main branch and squashed into single commit to help maintainers review it more efficient and to avoid spaghetti git commit graphs that obfuscate which commit did exactly what change, when and, why.
  • Have git sign off at the end of commit message to avoid being marked red. You can add -s flag when using git commit command. You may refer to this link for more information.
  • Follow the Commit Linting specification. You may refer to this link for more information.

Character Limit

  • Pull Request Title and Commit Subject must not exceed 72 characters (including spaces and special characters).
  • Commit Message per line must not exceed 80 characters (including spaces and special characters).

A Must Read for Beginners
For rebasing and squashing, here's a must read guide for beginners.

@petermetz petermetz enabled auto-merge (rebase) April 4, 2024 16:49
@petermetz petermetz requested a review from RafaelAPB April 4, 2024 16:49
petermetz added a commit to petermetz/cacti that referenced this pull request Apr 4, 2024
1. This leverages the newly introduced methods in core-api that the API
server is using to probe if a plugin has ConnectRPC support or not.
2. There is support for both HTTP 1.1 and HTTP 2. The caveat here is that
HTTP 2 is not supported by ExpressJS so we pulled in Fastify to handle
those type of requests and that means that HTTP 2 ConnectRPC traffic has
to go through a different port compared to the HTTP 1.1 ConnectRPC traffic.
3. The lesson here is that we probably need to migrate away from ExpressJS
longer term because it does not (and from the looks of it will not ever)
support HTTP 2 which is probably going to be a bit of technical debt/
limiting factor in architectural decisions going forward for both Cacti
maintainers and Cacti users.
4. A new code generator has been introduced by this commit as well which
is @buf/build - the tool where ConnectRPC originates from. The scripts are
structured in such a way that this should be seamlessly integrated into the
existing `codegen` root level script and therefore also the CI.
5. There is test coverage for both HTTP 1.1 and HTTP 2 traffic in the file at
```sh
packages/cactus-test-plugin-keychain-memory/src/test/typescript/integration/
test-keychain-memory-crpc-api-server.test.ts
```
6. The test case referenced above is also the example on how to use the
ConnectRPC client (very similar to the HTTP client we already had before)

Depends on hyperledger-cacti#3183

Signed-off-by: Peter Somogyvari <[email protected]>
Copy link
Contributor

@jagpreetsinghsasan jagpreetsinghsasan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@petermetz petermetz force-pushed the feat-cmd-api-server-connect-grpc-flavor branch from d27643c to 132c9af Compare April 8, 2024 18:48
1. This is enabling plugins to expose their operations via ConnectRPC
services which is very similar to gRPC but it comes with a few extra
bells and whistles that can come in very handy.
2. There is an upcoming pull request that makes it so that the keychain
memory plugin implements and registers its services via this newly added
hook of the API server. The importance of this is that test coverage for
the code in this commit resides on another branch, meaning that even though
there are no new test cases on this branch, the feature has been extensively
tested and there is test-automation in place to continue verifying it
as well.
3. The main difference between the hook methods are that for CRPC the
API server expects an array of service definition+implementation pairs
instead of just a single one. This was a design decision forced by the
issues with implementing separate services in a single class: The compiler
was hard to appease in a way that kept the code clean. gRPC did not suffer
from this and therefore the registration methods defined for that only
return a single gRPC service defintion+implementation pair which can combine
any number of .proto services.

Signed-off-by: Peter Somogyvari <[email protected]>
@petermetz petermetz force-pushed the feat-cmd-api-server-connect-grpc-flavor branch from 132c9af to f422ab1 Compare April 8, 2024 23:59
@petermetz petermetz merged commit c569460 into hyperledger-cacti:main Apr 9, 2024
128 of 142 checks passed
@petermetz petermetz deleted the feat-cmd-api-server-connect-grpc-flavor branch April 9, 2024 00:32
petermetz added a commit to petermetz/cacti that referenced this pull request Apr 11, 2024
1. This leverages the newly introduced methods in core-api that the API
server is using to probe if a plugin has ConnectRPC support or not.
2. There is support for both HTTP 1.1 and HTTP 2. The caveat here is that
HTTP 2 is not supported by ExpressJS so we pulled in Fastify to handle
those type of requests and that means that HTTP 2 ConnectRPC traffic has
to go through a different port compared to the HTTP 1.1 ConnectRPC traffic.
3. The lesson here is that we probably need to migrate away from ExpressJS
longer term because it does not (and from the looks of it will not ever)
support HTTP 2 which is probably going to be a bit of technical debt/
limiting factor in architectural decisions going forward for both Cacti
maintainers and Cacti users.
4. A new code generator has been introduced by this commit as well which
is @buf/build - the tool where ConnectRPC originates from. The scripts are
structured in such a way that this should be seamlessly integrated into the
existing `codegen` root level script and therefore also the CI.
5. There is test coverage for both HTTP 1.1 and HTTP 2 traffic in the file at
```sh
packages/cactus-test-plugin-keychain-memory/src/test/typescript/integration/
test-keychain-memory-crpc-api-server.test.ts
```
6. The test case referenced above is also the example on how to use the
ConnectRPC client (very similar to the HTTP client we already had before)

Depends on hyperledger-cacti#3183

Signed-off-by: Peter Somogyvari <[email protected]>
petermetz added a commit to petermetz/cacti that referenced this pull request Apr 11, 2024
1. This leverages the newly introduced methods in core-api that the API
server is using to probe if a plugin has ConnectRPC support or not.
2. There is support for both HTTP 1.1 and HTTP 2. The caveat here is that
HTTP 2 is not supported by ExpressJS so we pulled in Fastify to handle
those type of requests and that means that HTTP 2 ConnectRPC traffic has
to go through a different port compared to the HTTP 1.1 ConnectRPC traffic.
3. The lesson here is that we probably need to migrate away from ExpressJS
longer term because it does not (and from the looks of it will not ever)
support HTTP 2 which is probably going to be a bit of technical debt/
limiting factor in architectural decisions going forward for both Cacti
maintainers and Cacti users.
4. A new code generator has been introduced by this commit as well which
is @buf/build - the tool where ConnectRPC originates from. The scripts are
structured in such a way that this should be seamlessly integrated into the
existing `codegen` root level script and therefore also the CI.
5. There is test coverage for both HTTP 1.1 and HTTP 2 traffic in the file at
```sh
packages/cactus-test-plugin-keychain-memory/src/test/typescript/integration/
test-keychain-memory-crpc-api-server.test.ts
```
6. The test case referenced above is also the example on how to use the
ConnectRPC client (very similar to the HTTP client we already had before)

Depends on hyperledger-cacti#3183

Signed-off-by: Peter Somogyvari <[email protected]>
petermetz added a commit that referenced this pull request Apr 11, 2024
1. This leverages the newly introduced methods in core-api that the API
server is using to probe if a plugin has ConnectRPC support or not.
2. There is support for both HTTP 1.1 and HTTP 2. The caveat here is that
HTTP 2 is not supported by ExpressJS so we pulled in Fastify to handle
those type of requests and that means that HTTP 2 ConnectRPC traffic has
to go through a different port compared to the HTTP 1.1 ConnectRPC traffic.
3. The lesson here is that we probably need to migrate away from ExpressJS
longer term because it does not (and from the looks of it will not ever)
support HTTP 2 which is probably going to be a bit of technical debt/
limiting factor in architectural decisions going forward for both Cacti
maintainers and Cacti users.
4. A new code generator has been introduced by this commit as well which
is @buf/build - the tool where ConnectRPC originates from. The scripts are
structured in such a way that this should be seamlessly integrated into the
existing `codegen` root level script and therefore also the CI.
5. There is test coverage for both HTTP 1.1 and HTTP 2 traffic in the file at
```sh
packages/cactus-test-plugin-keychain-memory/src/test/typescript/integration/
test-keychain-memory-crpc-api-server.test.ts
```
6. The test case referenced above is also the example on how to use the
ConnectRPC client (very similar to the HTTP client we already had before)

Depends on #3183

Signed-off-by: Peter Somogyvari <[email protected]>
sandeepnRES pushed a commit to sandeepnRES/cacti that referenced this pull request Jul 30, 2024
1. This leverages the newly introduced methods in core-api that the API
server is using to probe if a plugin has ConnectRPC support or not.
2. There is support for both HTTP 1.1 and HTTP 2. The caveat here is that
HTTP 2 is not supported by ExpressJS so we pulled in Fastify to handle
those type of requests and that means that HTTP 2 ConnectRPC traffic has
to go through a different port compared to the HTTP 1.1 ConnectRPC traffic.
3. The lesson here is that we probably need to migrate away from ExpressJS
longer term because it does not (and from the looks of it will not ever)
support HTTP 2 which is probably going to be a bit of technical debt/
limiting factor in architectural decisions going forward for both Cacti
maintainers and Cacti users.
4. A new code generator has been introduced by this commit as well which
is @buf/build - the tool where ConnectRPC originates from. The scripts are
structured in such a way that this should be seamlessly integrated into the
existing `codegen` root level script and therefore also the CI.
5. There is test coverage for both HTTP 1.1 and HTTP 2 traffic in the file at
```sh
packages/cactus-test-plugin-keychain-memory/src/test/typescript/integration/
test-keychain-memory-crpc-api-server.test.ts
```
6. The test case referenced above is also the example on how to use the
ConnectRPC client (very similar to the HTTP client we already had before)

Depends on hyperledger-cacti#3183

Signed-off-by: Peter Somogyvari <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants