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

Support direct connections to ent from the rest api #1932

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

mdeicas
Copy link
Collaborator

@mdeicas mdeicas commented May 28, 2024

Description of the PR

Adds configuration to allow endpoints from the REST API to connect directly to Ent. This will allow bypassing the GraphQl API to use database native functionality.

This option can be enabled with guacrest --db-direct-connection. Current endpoint implementations can be overridden to use this optimized implementation by adding methods to EntConnectedServer. If --db-direct-connection is specified but an endpoint does not have a corresponding EntConnectedServer implementation, then the default one will be used.

PR Checklist

  • All commits have a Developer Certificate of Origin (DCO) -- they are generated using -s flag to git commit.
  • All new changes are covered by tests
  • If GraphQL schema is changed, make generate has been run
  • If OpenAPI spec is changed, make generate has been run
  • If collectsub protobuf has been changed, make proto has been run
  • All CI checks are passing (tests and formatting)
  • All dependent PRs have already been merged

@pxp928
Copy link
Collaborator

pxp928 commented May 29, 2024

Very nice! @mdeicas

cmd/guacrest/cmd/server.go Outdated Show resolved Hide resolved
pkg/cli/store.go Outdated Show resolved Hide resolved
@mdeicas mdeicas force-pushed the ent branch 2 times, most recently from 2cc22b2 to 3734059 Compare June 3, 2024 16:22
@mihaimaruseac
Copy link
Collaborator

Hmm, won't this create opportunities for the two backends to get out of sync? You'll now be able to write data that would not pass graphql ontology validations.

@mdeicas
Copy link
Collaborator Author

mdeicas commented Jun 5, 2024

Hmm, won't this create opportunities for the two backends to get out of sync? You'll now be able to write data that would not pass graphql ontology validations.

Good point, that's true. This should only be for read access to the database, though. I think we can enforce this by adding a hook to the ent client to reject all writes, and also generally through code reviews.

@mihaimaruseac
Copy link
Collaborator

If we make it only read queries that works for me

@mdeicas
Copy link
Collaborator Author

mdeicas commented Jun 10, 2024

@mrizzi @dejanb for visibility and any thoughts, I think you were interested in this!

Copy link
Collaborator

@mihaimaruseac mihaimaruseac left a comment

Choose a reason for hiding this comment

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

Thank you!

Signed-off-by: Marco Deicas <mdeicas@google.com>
@kodiakhq kodiakhq bot merged commit e2486e1 into guacsec:main Jun 12, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants