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

ARC-1699: Spicegen gRPC client binding #2

Merged
merged 4 commits into from
May 23, 2024
Merged

Conversation

thomasrichner-oviva
Copy link
Contributor

@thomasrichner-oviva thomasrichner-oviva commented May 21, 2024

Changes:

  • spicedb-binding/ - Moved the largely borrowed authzed-client implementation from our permission library.
  • example/ - Basic example on how to use everything together.

We can pull out more in the future, but let's keep it managable for now. PR is already huge.

@thomasrichner-oviva thomasrichner-oviva force-pushed the feature/arc-1699 branch 2 times, most recently from d6af8ab to 6cec415 Compare May 21, 2024 13:58
@@ -0,0 +1,15 @@
package com.oviva.spicegen.api;

public interface PermissionService {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can extend in the future with e.g. checks etc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a full example. Testing with generated sources directly is a bit problematic, because support for generated test-sources is a bit lackluster ;)

Comment on lines +124 to +145
return permissionServiceStub.checkPermission(
com.authzed.api.v1.PermissionService.CheckPermissionRequest.newBuilder()
.setPermission(permission)
.setResource(
Core.ObjectReference.newBuilder()
.setObjectType(object.kind())
.setObjectId(object.id())
.build())
.setSubject(
Core.SubjectReference.newBuilder()
.setObject(
Core.ObjectReference.newBuilder()
.setObjectType(subject.kind())
.setObjectId(subject.id())
.build())
.build())
.setConsistency(
com.authzed.api.v1.PermissionService.Consistency.newBuilder()
.setAtLeastAsFresh(
Core.ZedToken.newBuilder().setToken(consistencyToken).build())
.build())
.build());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's a good argument to also generate more of the permission checks ;)
This could be as short as the updates.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done! See #3

Copy link
Collaborator

Choose a reason for hiding this comment

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

Great, will also have a look once I'm done with this PR. But it already looks great!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

not needed, was just here for ease of test

@thomasrichner-oviva thomasrichner-oviva marked this pull request as ready for review May 22, 2024 16:22
Copy link
Collaborator

@shivantaher-oviva shivantaher-oviva left a comment

Choose a reason for hiding this comment

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

Starts to look good left some basic comments. I noticed that many things in spicedb-binding have been copied over from permissions. That's also fine for now but I think in the future we should also add a note in the permissions repo to use the generator instead and "deprecate" things over there.

@@ -0,0 +1,15 @@
package com.oviva.spicegen.api;

public interface PermissionService {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Comment on lines +124 to +145
return permissionServiceStub.checkPermission(
com.authzed.api.v1.PermissionService.CheckPermissionRequest.newBuilder()
.setPermission(permission)
.setResource(
Core.ObjectReference.newBuilder()
.setObjectType(object.kind())
.setObjectId(object.id())
.build())
.setSubject(
Core.SubjectReference.newBuilder()
.setObject(
Core.ObjectReference.newBuilder()
.setObjectType(subject.kind())
.setObjectId(subject.id())
.build())
.build())
.setConsistency(
com.authzed.api.v1.PermissionService.Consistency.newBuilder()
.setAtLeastAsFresh(
Core.ZedToken.newBuilder().setToken(consistencyToken).build())
.build())
.build());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great, will also have a look once I'm done with this PR. But it already looks great!

import com.authzed.api.v1.Core;
import com.oviva.spicegen.api.UpdateRelationship;

public class CreateRelationshipUpdateToSpiceDBUpdateRelationshipMapper {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just:

Suggested change
public class CreateRelationshipUpdateToSpiceDBUpdateRelationshipMapper {
public class UpdateRelationshipMapper {

? :) Like all other mapper classes in this package.

Copy link
Collaborator

@annadurrer-oviva annadurrer-oviva left a comment

Choose a reason for hiding this comment

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

Looks great! Except for having a consistent naming of the mappers and its tests, everything approved!

@thomasrichner-oviva
Copy link
Contributor Author

Thanks both! I'll address Shivan's point in the follow-up PR>

@thomasrichner-oviva thomasrichner-oviva merged commit 365d857 into main May 23, 2024
1 check passed
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.

None yet

3 participants