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

Streaming Interceptors #3641

Merged
merged 28 commits into from
Feb 9, 2025
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9f853b8
Add read/write streaming payload/result methods to interceptor DSL
douglaswth Jan 24, 2025
e547e64
Weave streaming interceptor stuff through codegen
douglaswth Jan 24, 2025
d6d779d
Do not try to use a field from an interface for the raw payload when …
douglaswth Jan 25, 2025
fa0bdde
Fix golden files
douglaswth Jan 25, 2025
946b677
Collect attributes from a method that actually has the interceptor ap…
douglaswth Jan 28, 2025
28789b0
Fix StreamingResult accessor signature and return
douglaswth Jan 28, 2025
905c5d8
Add SendWithContext and RecvWithContext methods to the stream interfa…
douglaswth Jan 29, 2025
5905958
Progress on wrapping streams with interceptors
douglaswth Jan 30, 2025
6e8e746
Finish generating the stream wrapping for interceptors; remove the En…
douglaswth Jan 31, 2025
3826f70
Progress on adding comments and fixing tests; fix a bug where refs we…
douglaswth Jan 31, 2025
0261a0c
Finish fixing tests
douglaswth Feb 1, 2025
9c35929
Add more tests for streaming interceptor service codegen
douglaswth Feb 1, 2025
cc0e16a
Fix bug where the CLI ParseEndpoint method would try to wrap every me…
douglaswth Feb 1, 2025
79eafc5
Merge branch 'v3' into streaming-interceptors
douglaswth Feb 3, 2025
81835c3
Update InterceptorInfo comment and replace Send and Recv boolean fiel…
douglaswth Feb 3, 2025
ebd3114
Merge branch 'v3' into streaming-interceptors
douglaswth Feb 3, 2025
1e1c7ab
Update Golden files to make the Interceptor tests happy
douglaswth Feb 3, 2025
712ab19
Add a ReturnContext field to goa.InterceptorInfo to allow interceptor…
douglaswth Feb 4, 2025
3161e0b
Scrap ReturnContext field in favor of changing the interceptor interf…
douglaswth Feb 4, 2025
c236fce
Merge branch 'v3' into streaming-interceptors
douglaswth Feb 4, 2025
6a734fe
Update Golden files to make the Interceptor tests happy again
douglaswth Feb 4, 2025
c36dfb6
Change goa.InterceptorInfo to an interface that generated interceptor…
douglaswth Feb 5, 2025
8035d69
Separate StreamingPayload and StreamingResult methods to Client and S…
douglaswth Feb 5, 2025
2ba73ae
Use goa.Endpoint for next again and do not return contexts from SendW…
douglaswth Feb 6, 2025
a1f2a91
Merge branch 'v3' into streaming-interceptors
douglaswth Feb 6, 2025
edbbca8
Address lint issues
raphael Feb 8, 2025
e4eb8a1
Merge branch 'v3' into streaming-interceptors
raphael Feb 8, 2025
77667dc
Fix lint issue
raphael Feb 8, 2025
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
Prev Previous commit
Next Next commit
Collect attributes from a method that actually has the interceptor ap…
…plied; import the correct user types packages when rendering service_interceptors.go; fix an ancient typo
douglaswth committed Jan 30, 2025
commit 946b6776e2b562c10a37b57593eb5e7aa581156e
1 change: 1 addition & 0 deletions codegen/service/interceptors.go
Original file line number Diff line number Diff line change
@@ -78,6 +78,7 @@ func interceptorFile(svc *Data, server bool) *codegen.File {
},
}
if len(interceptors) > 0 {
codegen.AddImport(sections[0], svc.UserTypeImports...)
sections = append(sections, &codegen.SectionTemplate{
Name: "interceptor-types",
Source: readTemplate("interceptors_types"),
2 changes: 1 addition & 1 deletion codegen/service/service.go
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ func Files(genpkg string, service *expr.ServiceExpr, userTypePkgs map[string][]s
if m.StreamingPayloadDef != "" {
if _, ok := seen[m.StreamingPayload]; !ok {
addTypeDefSection(payloadPath, m.StreamingPayload, &codegen.SectionTemplate{
Name: "service-streamig-payload",
Name: "service-streaming-payload",
Source: readTemplate("streaming_payload"),
Data: m,
})
46 changes: 25 additions & 21 deletions codegen/service/service_data.go
Original file line number Diff line number Diff line change
@@ -1226,27 +1226,7 @@ func buildInterceptorData(svc *expr.ServiceExpr, methods []*MethodData, i *expr.
if len(svc.Methods) == 0 {
return data
}
payload, result, streamingPayload := svc.Methods[0].Payload, svc.Methods[0].Result, svc.Methods[0].StreamingPayload
data.ReadPayload = collectAttributes(i.ReadPayload, payload, scope)
data.WritePayload = collectAttributes(i.WritePayload, payload, scope)
data.ReadResult = collectAttributes(i.ReadResult, result, scope)
data.WriteResult = collectAttributes(i.WriteResult, result, scope)
data.ReadStreamingPayload = collectAttributes(i.ReadStreamingPayload, streamingPayload, scope)
data.WriteStreamingPayload = collectAttributes(i.WriteStreamingPayload, streamingPayload, scope)
data.ReadStreamingResult = collectAttributes(i.ReadStreamingResult, result, scope)
data.WriteStreamingResult = collectAttributes(i.WriteStreamingResult, result, scope)
if len(data.ReadPayload) > 0 || len(data.WritePayload) > 0 {
data.HasPayloadAccess = true
}
if len(data.ReadResult) > 0 || len(data.WriteResult) > 0 {
data.HasResultAccess = true
}
if len(data.ReadStreamingPayload) > 0 || len(data.WriteStreamingPayload) > 0 {
data.HasStreamingPayloadAccess = true
}
if len(data.ReadStreamingResult) > 0 || len(data.WriteStreamingResult) > 0 {
data.HasStreamingResultAccess = true
}
attributesCollected := false
for _, m := range svc.Methods {
applies := false
intExprs := m.ServerInterceptors
@@ -1255,6 +1235,30 @@ func buildInterceptorData(svc *expr.ServiceExpr, methods []*MethodData, i *expr.
}
for _, in := range intExprs {
if in.Name == i.Name {
if !attributesCollected {
payload, result, streamingPayload := m.Payload, m.Result, m.StreamingPayload
data.ReadPayload = collectAttributes(i.ReadPayload, payload, scope)
data.WritePayload = collectAttributes(i.WritePayload, payload, scope)
data.ReadResult = collectAttributes(i.ReadResult, result, scope)
data.WriteResult = collectAttributes(i.WriteResult, result, scope)
data.ReadStreamingPayload = collectAttributes(i.ReadStreamingPayload, streamingPayload, scope)
data.WriteStreamingPayload = collectAttributes(i.WriteStreamingPayload, streamingPayload, scope)
data.ReadStreamingResult = collectAttributes(i.ReadStreamingResult, result, scope)
data.WriteStreamingResult = collectAttributes(i.WriteStreamingResult, result, scope)
if len(data.ReadPayload) > 0 || len(data.WritePayload) > 0 {
data.HasPayloadAccess = true
}
if len(data.ReadResult) > 0 || len(data.WriteResult) > 0 {
data.HasResultAccess = true
}
if len(data.ReadStreamingPayload) > 0 || len(data.WriteStreamingPayload) > 0 {
data.HasStreamingPayloadAccess = true
}
if len(data.ReadStreamingResult) > 0 || len(data.WriteStreamingResult) > 0 {
data.HasStreamingResultAccess = true
}
attributesCollected = true
}
applies = true
break
}