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

Delete client and handler stream constructors #193

Merged
merged 3 commits into from
Apr 9, 2022

Conversation

akshayjshah
Copy link
Member

These aren't used in the generated code anymore, so we don't need to
export them. They don't do much work either, so we can just delete the
constructors and use a linter to make sure we always initialize future
fields.

These aren't used in the generated code anymore, so we don't need to
export them. They don't do much work either, so we can just delete the
constructors and use a linter to make sure we always initialize future
fields.
@akshayjshah akshayjshah requested a review from bufdev April 7, 2022 23:07
Copy link
Member

@bufdev bufdev left a comment

Choose a reason for hiding this comment

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

Just want to look over this again tomorrow, will check before EOD

@bufdev
Copy link
Member

bufdev commented Apr 8, 2022

Can we add godoc comments to each of the *ForClient structs that they should only be created by the connect package? All other public structs other than Specification have constructors, and it's worth calling out why the *ForClient structs are special (and I'd argue that Specification is special as well compared to other public structs, but no need to comment on it).

const StreamTypeUnary StreamType = 0b00 ...
const IsAtLeastVersion0_0_1 = true
const Version = "0.0.1"
func DecodeBinaryHeader(data string) ([]byte, error)
func EncodeBinaryHeader(data []byte) string
type AnyRequest interface{ ... }
type AnyResponse interface{ ... }
type BidiStream[Req, Res any] struct{ ... }
    func NewBidiStream[Req, Res any](s Sender, r Receiver) *BidiStream[Req, Res]
type BidiStreamForClient[Req, Res any] struct{ ... }
    func NewBidiStreamForClient[Req, Res any](s Sender, r Receiver) *BidiStreamForClient[Req, Res]
type Client[Req, Res any] struct{ ... }
    func NewClient[Req, Res any](httpClient HTTPClient, url string, options ...ClientOption) (*Client[Req, Res], error)
type ClientOption interface{ ... }
    func WithClientOptions(options ...ClientOption) ClientOption
    func WithGRPC() ClientOption
    func WithGRPCWeb() ClientOption
    func WithGzipRequests() ClientOption
    func WithRequestCompression(name string) ClientOption
type ClientStream[Req, Res any] struct{ ... }
    func NewClientStream[Req, Res any](s Sender, r Receiver) *ClientStream[Req, Res]
type ClientStreamForClient[Req, Res any] struct{ ... }
    func NewClientStreamForClient[Req, Res any](s Sender, r Receiver) *ClientStreamForClient[Req, Res]
type Code uint32
    const CodeCanceled Code = 1 ...
    func CodeOf(err error) Code
type Codec interface{ ... }
type Compressor interface{ ... }
type Decompressor interface{ ... }
type Error struct{ ... }
    func NewError(c Code, underlying error) *Error
type ErrorDetail interface{ ... }
type HTTPClient interface{ ... }
type Handler struct{ ... }
    func NewBidiStreamHandler[Req, Res any](procedure string, ...) *Handler
    func NewClientStreamHandler[Req, Res any](procedure string, ...) *Handler
    func NewServerStreamHandler[Req, Res any](procedure string, ...) *Handler
    func NewUnaryHandler[Req, Res any](procedure string, ...) *Handler
type HandlerOption interface{ ... }
    func WithHandlerOptions(options ...HandlerOption) HandlerOption
type Interceptor interface{ ... }
type Option interface{ ... }
    func WithCodec(codec Codec) Option
    func WithCompressMinBytes(min int) Option
    func WithCompression(name string, newDecompressor func() Decompressor, ...) Option
    func WithGzip() Option
    func WithInterceptors(interceptors ...Interceptor) Option
    func WithOptions(options ...Option) Option
    func WithProtoBinaryCodec() Option
    func WithProtoJSONCodec() Option
type Receiver interface{ ... }
type Request[T any] struct{ ... }
    func NewRequest[T any](message *T) *Request[T]
type Response[T any] struct{ ... }
    func NewResponse[T any](message *T) *Response[T]
type Sender interface{ ... }
type ServerStream[Res any] struct{ ... }
    func NewServerStream[Res any](s Sender) *ServerStream[Res]
type ServerStreamForClient[Res any] struct{ ... }
    func NewServerStreamForClient[Res any](r Receiver) *ServerStreamForClient[Res]
type Specification struct{ ... }
type StreamType uint8
type UnaryFunc func(context.Context, AnyRequest) (AnyResponse, error)
type UnaryInterceptorFunc func(UnaryFunc) UnaryFunc

@akshayjshah
Copy link
Member Author

Sure, can do.

Similar to previous changes to client_stream.go, use the `mergeHeaders`
helper now that all this code is in the same package.
@akshayjshah
Copy link
Member Author

Added docs, squash or rebase this in if it looks good to you.

@bufdev bufdev merged commit fd76f3a into main Apr 9, 2022
@bufdev bufdev deleted the ajs/unexport-constructors branch April 9, 2022 15:07
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.

2 participants