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 Schema field to Spec for introspection #629

Merged
merged 6 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions client_ext_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,10 @@ func (a *assertSchemaInterceptor) WrapUnary(next connect.UnaryFunc) connect.Unar
return next(ctx, req)
}
methodDesc, ok := req.Spec().Schema.(protoreflect.MethodDescriptor)
assert.True(a.tb, ok)
procedure := fmt.Sprintf("/%s/%s", methodDesc.Parent().FullName(), methodDesc.Name())
assert.Equal(a.tb, procedure, req.Spec().Procedure)
if assert.True(a.tb, ok) {
procedure := fmt.Sprintf("/%s/%s", methodDesc.Parent().FullName(), methodDesc.Name())
assert.Equal(a.tb, procedure, req.Spec().Procedure)
}
return next(ctx, req)
}
}
Expand All @@ -298,9 +299,10 @@ func (a *assertSchemaInterceptor) WrapStreamingClient(next connect.StreamingClie
return conn
}
methodDescriptor, ok := spec.Schema.(protoreflect.MethodDescriptor)
assert.True(a.tb, ok)
procedure := fmt.Sprintf("/%s/%s", methodDescriptor.Parent().FullName(), methodDescriptor.Name())
assert.Equal(a.tb, procedure, spec.Procedure)
if assert.True(a.tb, ok) {
procedure := fmt.Sprintf("/%s/%s", methodDescriptor.Parent().FullName(), methodDescriptor.Name())
assert.Equal(a.tb, procedure, spec.Procedure)
}
return conn
}
}
Expand All @@ -311,9 +313,10 @@ func (a *assertSchemaInterceptor) WrapStreamingHandler(next connect.StreamingHan
return next(ctx, conn)
}
methodDesc, ok := conn.Spec().Schema.(protoreflect.MethodDescriptor)
assert.True(a.tb, ok)
procedure := fmt.Sprintf("/%s/%s", methodDesc.Parent().FullName(), methodDesc.Name())
assert.Equal(a.tb, procedure, conn.Spec().Procedure)
if assert.True(a.tb, ok) {
procedure := fmt.Sprintf("/%s/%s", methodDesc.Parent().FullName(), methodDesc.Name())
assert.Equal(a.tb, procedure, conn.Spec().Procedure)
}
return next(ctx, conn)
}
}
3 changes: 1 addition & 2 deletions cmd/protoc-gen-connect-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,7 @@ func generateServiceNameConstants(g *protogen.GeneratedFile, services []*protoge
}

func generateServiceNameVariables(g *protogen.GeneratedFile, file *protogen.File) {
wrapComments(g, "These variables are the protoreflect.Descriptor objects for the ", file.Desc.Name(),
" service's methods.")
wrapComments(g, "These variables are the protoreflect.Descriptor objects for the RPCs defined in this package.")
jhump marked this conversation as resolved.
Show resolved Hide resolved
g.P("var (")
for _, service := range file.Services {
serviceDescName := unexport(fmt.Sprintf("%sServiceDescriptor", service.Desc.Name()))
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion internal/gen/connect/ping/v1/pingv1connect/ping.connect.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.