mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 22:19:40 -08:00
375ad1185c
* *: bump gRPC dependencies This change updates the gRPC dependencies to more recent versions: * github.com/gogo/protobuf => v1.2.0 * github.com/grpc-ecosystem/grpc-gateway => v1.6.3 * google.golang.org/grpc => v1.17.0 In addition scripts/genproto.sh leverages Go modules information instead of hardcoding SHA1 commits. This ensures that the code is generated from the exact same sources. Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Run 'make proto' in CI Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Revert tabs -> spaces change Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Fix 'make proto' step Signed-off-by: Simon Pasquier <spasquie@redhat.com> * 'go get' grpc/protobuf dependencies Signed-off-by: Simon Pasquier <spasquie@redhat.com> * Prepopulate cache with go mod download Signed-off-by: Simon Pasquier <spasquie@redhat.com>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
// Copyright 2014 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// Flow control
|
|
|
|
package http2
|
|
|
|
// flow is the flow control window's size.
|
|
type flow struct {
|
|
// n is the number of DATA bytes we're allowed to send.
|
|
// A flow is kept both on a conn and a per-stream.
|
|
n int32
|
|
|
|
// conn points to the shared connection-level flow that is
|
|
// shared by all streams on that conn. It is nil for the flow
|
|
// that's on the conn directly.
|
|
conn *flow
|
|
}
|
|
|
|
func (f *flow) setConnFlow(cf *flow) { f.conn = cf }
|
|
|
|
func (f *flow) available() int32 {
|
|
n := f.n
|
|
if f.conn != nil && f.conn.n < n {
|
|
n = f.conn.n
|
|
}
|
|
return n
|
|
}
|
|
|
|
func (f *flow) take(n int32) {
|
|
if n > f.available() {
|
|
panic("internal error: took too much")
|
|
}
|
|
f.n -= n
|
|
if f.conn != nil {
|
|
f.conn.n -= n
|
|
}
|
|
}
|
|
|
|
// add adds n bytes (positive or negative) to the flow control window.
|
|
// It returns false if the sum would exceed 2^31-1.
|
|
func (f *flow) add(n int32) bool {
|
|
sum := f.n + n
|
|
if (sum > n) == (f.n > 0) {
|
|
f.n = sum
|
|
return true
|
|
}
|
|
return false
|
|
}
|