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

Address style feedback #58

Merged
merged 2 commits into from
Jan 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions client_duplex_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var _ Receiver = (*clientReceiver)(nil)
func (cr *clientReceiver) Receive(m any) error { return cr.stream.Receive(m) }
func (cr *clientReceiver) Close() error { return cr.stream.CloseReceive() }
func (cr *clientReceiver) Spec() Specification { return cr.stream.Spec() }
func (cr *clientReceiver) Header() http.Header { return cr.stream.ReceivedHeader() }
func (cr *clientReceiver) Header() http.Header { return cr.stream.ResponseHeader() }

// clientStream represents a bidirectional exchange of protobuf messages
// between the client and server. The request body is the stream from client to
Expand Down Expand Up @@ -186,7 +186,7 @@ func (cs *clientStream) CloseReceive() error {
return nil
}

func (cs *clientStream) ReceivedHeader() http.Header {
func (cs *clientStream) ResponseHeader() http.Header {
<-cs.responseReady
return cs.response.Header
}
Expand Down
2 changes: 1 addition & 1 deletion client_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func ExampleClient() {
// idle connections per host.
MaxIdleConnsPerHost: 16,
IdleConnTimeout: 90 * time.Second,
MaxResponseHeaderBytes: rerpc.MaxHeaderBytes,
MaxResponseHeaderBytes: 8 * 1024, // 8 KiB, gRPC's recommended setting
},
CheckRedirect: func(_ *http.Request, _ []*http.Request) error {
// Don't follow any redirects.
Expand Down
8 changes: 4 additions & 4 deletions clientstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ func (s *Server[Res]) Receive() (*Res, error) {
return &res, nil
}

// ReceivedHeader returns the headers received from the server. It blocks until
// ResponseHeader returns the headers received from the server. It blocks until
// the first call to Receive returns.
func (s *Server[Res]) ReceivedHeader() http.Header {
func (s *Server[Res]) ResponseHeader() http.Header {
return s.receiver.Header()
}

Expand Down Expand Up @@ -122,8 +122,8 @@ func (b *Bidirectional[Req, Res]) CloseReceive() error {
return b.receiver.Close()
}

// ReceivedHeader returns the headers received from the server. It blocks until
// ResponseHeader returns the headers received from the server. It blocks until
// the first call to Receive returns.
func (b *Bidirectional[Req, Res]) ReceivedHeader() http.Header {
func (b *Bidirectional[Req, Res]) ResponseHeader() http.Header {
return b.receiver.Header()
}
8 changes: 4 additions & 4 deletions handlerstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func NewClient[Req, Res any](s rerpc.Sender, r rerpc.Receiver) *Client[Req, Res]
return &Client[Req, Res]{sender: s, receiver: r}
}

// ReceivedHeader returns the headers received from the client.
func (c *Client[Req, Res]) ReceivedHeader() http.Header {
// RequestHeader returns the headers received from the client.
func (c *Client[Req, Res]) RequestHeader() http.Header {
return c.receiver.Header()
}

Expand Down Expand Up @@ -80,8 +80,8 @@ func NewBidirectional[Req, Res any](s rerpc.Sender, r rerpc.Receiver) *Bidirecti
return &Bidirectional[Req, Res]{sender: s, receiver: r}
}

// ReceivedHeader returns the headers received from the client.
func (b *Bidirectional[Req, Res]) ReceivedHeader() http.Header {
// RequestHeader returns the headers received from the client.
func (b *Bidirectional[Req, Res]) RequestHeader() http.Header {
return b.receiver.Header()
}

Expand Down
4 changes: 0 additions & 4 deletions rerpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ package rerpc
// Version is the semantic version of the reRPC module.
const Version = "0.0.1"

// MaxHeaderBytes is 8KiB, gRPC's recommended maximum header size. To enforce
// this limit, set MaxHeaderBytes on your http.Server.
const MaxHeaderBytes = 1024 * 8

// StreamType describes whether the client, server, neither, or both is
// streaming.
type StreamType uint8
Expand Down
2 changes: 1 addition & 1 deletion server_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func Example() {
Handler: mux,
ReadTimeout: 2500 * time.Millisecond,
WriteTimeout: 5 * time.Second,
MaxHeaderBytes: rerpc.MaxHeaderBytes,
MaxHeaderBytes: 8 * 1024, // 8KiB, gRPC's recommendation
}
// You could also use golang.org/x/net/http2/h2c to serve gRPC requests
// without TLS.
Expand Down