Skip to content
Open
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
18 changes: 14 additions & 4 deletions dialoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,21 +207,31 @@ func WithReadBufferSize(s int) DialOption {

// WithInitialWindowSize returns a DialOption which sets the value for initial
// window size on a stream. The lower bound for window size is 64K and any value
// smaller than that will be ignored.
// smaller than that will be ignored. This does not disable dynamic flow control.
//
// Deprecated: use WithInitialStreamWindowSize instead. Will be supported
// throughout 1.x.
func WithInitialWindowSize(s int32) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.InitialWindowSize = s
o.copts.StaticWindowSize = true
})
}

// WithInitialStreamWindowSize returns a DialOption that sets the value for
// initial window size on a stream. The lower bound for window size is 64K and
// any value smaller than that will be ignored. This does not disable dynamic
// flow control.
func WithInitialStreamWindowSize(s int32) DialOption {
return WithInitialWindowSize(s)
}

// WithInitialConnWindowSize returns a DialOption which sets the value for
// initial window size on a connection. The lower bound for window size is 64K
// and any value smaller than that will be ignored.
// and any value smaller than that will be ignored. This does not disable
// dynamic flow control.
func WithInitialConnWindowSize(s int32) DialOption {
return newFuncDialOption(func(o *dialOptions) {
o.copts.InitialConnWindowSize = s
o.copts.StaticWindowSize = true
})
}

Expand Down
20 changes: 15 additions & 5 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,30 @@ func ReadBufferSize(s int) ServerOption {
}

// InitialWindowSize returns a ServerOption that sets window size for stream.
// The lower bound for window size is 64K and any value smaller than that will be ignored.
// The lower bound for window size is 64K and any value smaller than that will
// be ignored. This does not disable dynamic flow control.
//
// Deprecated: use InitialStreamWindowSize instead. Will be supported
// throughout 1.x.
func InitialWindowSize(s int32) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.initialWindowSize = s
o.staticWindowSize = true
})
}

// InitialConnWindowSize returns a ServerOption that sets window size for a connection.
// The lower bound for window size is 64K and any value smaller than that will be ignored.
// InitialStreamWindowSize returns a ServerOption that sets window size for
// stream. The lower bound for window size is 64K and any value smaller than
// that will be ignored. This does not disable dynamic flow control.
func InitialStreamWindowSize(s int32) ServerOption {
return InitialWindowSize(s)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a super nit but I would make the other one call this, since that one is deprecated, and you could even just document the other one as being the same as InitialStreamWindowSize (or "calls" this one or whatever). And similar for the dial option.

}

// InitialConnWindowSize returns a ServerOption that sets window size for a
// connection. The lower bound for window size is 64K and any value smaller than
// that will be ignored. This does not disable dynamic flow control.
func InitialConnWindowSize(s int32) ServerOption {
return newFuncServerOption(func(o *serverOptions) {
o.initialConnWindowSize = s
o.staticWindowSize = true
})
}

Expand Down
10 changes: 6 additions & 4 deletions test/end2end_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,10 @@ func (te *test) listenAndServe(ts testgrpc.TestServiceServer, listen func(networ
sopts = append(sopts, grpc.UnknownServiceHandler(te.unknownHandler))
}
if te.serverInitialWindowSize > 0 {
sopts = append(sopts, grpc.InitialWindowSize(te.serverInitialWindowSize))
sopts = append(sopts, grpc.StaticStreamWindowSize(te.serverInitialWindowSize))
}
if te.serverInitialConnWindowSize > 0 {
sopts = append(sopts, grpc.InitialConnWindowSize(te.serverInitialConnWindowSize))
sopts = append(sopts, grpc.StaticConnWindowSize(te.serverInitialConnWindowSize))
}
la := ":0"
if te.e.network == "unix" {
Expand Down Expand Up @@ -818,10 +818,10 @@ func (te *test) configDial(opts ...grpc.DialOption) ([]grpc.DialOption, string)
opts = append(opts, grpc.WithDefaultServiceConfig(fmt.Sprintf(`{"loadBalancingConfig": [{"%s":{}}]}`, te.e.balancer)))
}
if te.clientInitialWindowSize > 0 {
opts = append(opts, grpc.WithInitialWindowSize(te.clientInitialWindowSize))
opts = append(opts, grpc.WithStaticStreamWindowSize(te.clientInitialWindowSize))
}
if te.clientInitialConnWindowSize > 0 {
opts = append(opts, grpc.WithInitialConnWindowSize(te.clientInitialConnWindowSize))
opts = append(opts, grpc.WithStaticConnWindowSize(te.clientInitialConnWindowSize))
}
if te.perRPCCreds != nil {
opts = append(opts, grpc.WithPerRPCCredentials(te.perRPCCreds))
Expand Down Expand Up @@ -5490,6 +5490,7 @@ func testConfigurableWindowSize(t *testing.T, e env, wc windowSizeConfig) {
// Set message size to exhaust largest of window sizes.
messageSize := max(max(wc.serverStream, wc.serverConn), max(wc.clientStream, wc.clientConn)) / int32(numOfIter-1)
messageSize = max(messageSize, 64*1024)
t.Logf("easwars: messageSize=%d", messageSize)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like some debugging logs got pushed by mistake. Can you please remove these?

payload, err := newPayload(testpb.PayloadType_COMPRESSABLE, messageSize)
if err != nil {
t.Fatal(err)
Expand All @@ -5505,6 +5506,7 @@ func testConfigurableWindowSize(t *testing.T, e env, wc windowSizeConfig) {
Payload: payload,
}
for i := 0; i < numOfIter; i++ {
t.Logf("easwars: iteration %d", i)
if err := stream.Send(req); err != nil {
t.Fatalf("%v.Send(%v) = %v, want <nil>", stream, req, err)
}
Expand Down
Loading
Loading