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

Add core proto message and replace v0 usage #449

Merged
merged 4 commits into from
Mar 11, 2022
Merged

Conversation

samkim
Copy link
Member

@samkim samkim commented Mar 4, 2022

  • Add a copy of v0 core and namespace proto messages under core/v1
  • Update interfaces and method signatures to use core where possible
  • Introduce message converters (v0 -> core, core -> v0) as needed for existing v0 method calls

@github-actions github-actions bot added area/api v0 Affects the v0 API area/api v1 Affects the v1 API area/datastore Affects the storage system area/dispatch Affects dispatching of requests area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Mar 4, 2022
@samkim samkim force-pushed the core-protos branch 7 times, most recently from 0087326 to 44e1e24 Compare March 7, 2022 18:42
@@ -4,7 +4,7 @@ package dispatch.v1;
option go_package = "github.com/authzed/spicedb/pkg/proto/dispatch/v1";

import "validate/validate.proto";
import "authzed/api/v0/core.proto";
import "core/v1/core.proto";
Copy link
Member Author

Choose a reason for hiding this comment

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

Dispatch proto definitions updated to reference core messages

import "google/protobuf/any.proto";
import "validate/validate.proto";

message RelationTuple {
Copy link
Member Author

Choose a reason for hiding this comment

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

core has copies of v0 core and v0 namespace message defintions

@@ -1,7 +1,7 @@
---
version: "v1"
deps:
- "buf.build/beta/protoc-gen-validate"
- "buf.build/envoyproxy/protoc-gen-validate:bb405eae115246f0b5ccf8997136e3d8"
Copy link
Member Author

Choose a reason for hiding this comment

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

Pin to the specific version as of the date this file was last updated

pkg/proto/core/v1/util.go Outdated Show resolved Hide resolved

//revive:enable

func panicOnError(err error) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Attempt at a shared error handler for all the marshal/unmarshal calls

@samkim samkim force-pushed the core-protos branch 4 times, most recently from 09c071a to bee58a1 Compare March 8, 2022 00:14
breaking:
use:
- "WIRE"
ignore_only:
FIELD_WIRE_COMPATIBLE_TYPE:
- "dispatch/v1/dispatch.proto" # TODO: Remove after core v1 is merged
Copy link
Member Author

Choose a reason for hiding this comment

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

This ignore allows the conversion from v0 to core in the dispatch api to be merged

@samkim samkim marked this pull request as ready for review March 8, 2022 00:40
@samkim samkim requested a review from josephschorr March 8, 2022 00:40
@@ -344,8 +345,8 @@ func checkDataNoNewEnemy(ctx context.Context, t testing.TB, schemaData []SchemaD
r1leader, r2leader := getLeaderNode(ctx, crdb[1].Conn(), exclude.Tuple), getLeaderNode(ctx, crdb[1].Conn(), direct.Tuple)
ns1Leader := getLeaderNodeForNamespace(ctx, crdb[1].Conn(), exclude.Tuple.ObjectAndRelation.Namespace)
ns2Leader := getLeaderNodeForNamespace(ctx, crdb[1].Conn(), exclude.Tuple.User.GetUserset().Namespace)
z1, _ := zookie.DecodeRevision(r1.GetRevision())
z2, _ := zookie.DecodeRevision(r2.GetRevision())
z1, _ := zookie.DecodeRevision(core.CoreZookie(r1.GetRevision()))
Copy link
Member

Choose a reason for hiding this comment

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

Might be worth naming these slightly differently, like V0ToCoreZookie

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually started with the XToY naming but it got hard to read so I landed on just the desired type as the name.

Copy link
Member

Choose a reason for hiding this comment

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

Then maybe just ToCoreZookie? The current names are a bit ambiguous to me

pkg/proto/core/v1/util.go Outdated Show resolved Hide resolved
pkg/proto/core/v1/util.go Outdated Show resolved Hide resolved
"type.googleapis.com/impl.v1.RelationMetadata": {},
}

//revive:enable
Copy link
Member

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to a separate file and updated the lint ignores for the name of the map. Both revive and stylecheck complain about the var name format.

}
}

// Core
Copy link
Member

Choose a reason for hiding this comment

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

Remove and add doc comments on all exported functions

pkg/proto/core/v1/util.go Outdated Show resolved Hide resolved
@samkim samkim requested a review from josephschorr March 9, 2022 00:31
@samkim samkim force-pushed the core-protos branch 2 times, most recently from 1bd9b2f to 8cf9d46 Compare March 9, 2022 22:15
func CoreRelationTupleTreeNode(treenode *v0.RelationTupleTreeNode) *RelationTupleTreeNode {
coreNode := RelationTupleTreeNode{}
bytes, err := proto.Marshal(treenode)
defer panicOnError(err)
panicOnError(err)
Copy link
Member

Choose a reason for hiding this comment

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

newline after each panicOnError

return &coreRef
}

// CoreNamespaceDefinition converts the input to a core NamespaceDefinition.
func CoreNamespaceDefinition(def *v0.NamespaceDefinition) *NamespaceDefinition {
Copy link
Member

Choose a reason for hiding this comment

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

Add To in front of all of these

Copy link
Member Author

Choose a reason for hiding this comment

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

Those should've been renamed in the last push but I'll double check

- Create core manual validation file
- Add go docs
Copy link
Member

@josephschorr josephschorr left a comment

Choose a reason for hiding this comment

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

LGTM

@samkim samkim merged commit 5d6468a into authzed:main Mar 11, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Mar 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/api v0 Affects the v0 API area/api v1 Affects the v1 API area/datastore Affects the storage system area/dispatch Affects dispatching of requests area/schema Affects the Schema Language area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants