Skip to content

Goa generates streaming client methods that omit stream result #3771

@c4rlo

Description

@c4rlo

With the release of Goa v3.22.1, I'm seeing it generate client code for server-to-client streaming methods that does not seem usable.

As a minimal example, I have this design.go:

package design

import . "goa.design/goa/v3/dsl"

var _ = Service("goa-stream-issue", func() {
	Method("Blah", func() {
		StreamingResult(Int32)
		HTTP(func() {
			GET("/blah")
		})
	})
})

Running goa gen on that results in a gen/goa_stream_issue/client.go file with the following content:

// Code generated by goa v3.22.1, DO NOT EDIT.
//
// goa-stream-issue client
//
// Command:
// $ goa gen goa-stream-issue/design --output ..

package goastreamissue

import (
	"context"

	goa "goa.design/goa/v3/pkg"
)

// Client is the "goa-stream-issue" service client.
type Client struct {
	BlahEndpoint goa.Endpoint
}

// NewClient initializes a "goa-stream-issue" service client given the
// endpoints.
func NewClient(blah goa.Endpoint) *Client {
	return &Client{
		BlahEndpoint: blah,
	}
}

// Blah calls the "Blah" endpoint of the "goa-stream-issue" service.
func (c *Client) Blah(ctx context.Context) (err error) {
	_, err = c.BlahEndpoint(ctx, nil)
	return
}

Notice that Client.Blah() return an error only, discarding the result object it receives from BlahEndpoint(). Hence there seems no way to use this client to get the streamed result items.

Compare this to Goa v3.21.5, where client.go has:

// Blah calls the "Blah" endpoint of the "goa-stream-issue" service.
func (c *Client) Blah(ctx context.Context) (res BlahClientStream, err error) {
	var ires any
	ires, err = c.BlahEndpoint(ctx, nil)
	if err != nil {
		return
	}
	return ires.(BlahClientStream), nil
}

Am I missing something obvious here? I didn't see anything relevant in the release notes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions