Skip to content

Commit

Permalink
Merge pull request #2245 from yarpc/vitalii/release
Browse files Browse the repository at this point in the history
Vitalii/release
  • Loading branch information
biosvs authored Feb 21, 2024
2 parents cd46ab0 + b955c60 commit 1310bc0
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 41 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

=======
## [1.72.0] - 2024-02-21
- Removed gonum.org/v1/gonum dependency.
- Enable rpc-caller-procedure via yarpc outbound middleware.

## [1.71.0] - 2023-12-14
- tchannel: optional transport-level config to allow reusing a buffer for reading a tchannel response body.
- grpc: returned outbound response body is no longer writable.
Expand All @@ -14,7 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [1.70.4] - 2023-08-31
- logging: fix logged error in observability middleware when fields of transport.Request is in the tagsBlocklist
- `go.mod`: update minimum requirements to go1.21 instead of go1.14 and update `golang.org/x/net v0.7.0` to v0.14.0
- middleware stack usage: remove ~2KB of stack usage from the rpc handler function,
- middleware stack usage: remove ~2KB of stack usage from the rpc handler function,
so that it decreases the chance of needing more stack. It can improve the
performance of the application.

Expand Down Expand Up @@ -1493,6 +1497,7 @@ This release requires regeneration of ThriftRW code.
## 0.1.0 - 2016-08-31
- Initial release.
[1.72.0]: https://github.com/yarpc/yarpc-go/compare/v1.71.0...v1.72.0
[1.71.0]: https://github.com/yarpc/yarpc-go/compare/v1.70.4...v1.71.0
[1.70.4]: https://github.com/yarpc/yarpc-go/compare/v1.70.3...v1.70.4
[1.70.3]: https://github.com/yarpc/yarpc-go/compare/v1.70.2...v1.70.3
Expand Down
2 changes: 1 addition & 1 deletion encoding/protobuf/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ type BuildProceduresStreamHandlerParams struct {

// BuildProcedures builds the transport.Procedures.
func BuildProcedures(params BuildProceduresParams) []transport.Procedure {
procedures := make([]transport.Procedure, 0, 2*(len(params.UnaryHandlerParams)+len(params.OnewayHandlerParams)))
procedures := make([]transport.Procedure, 0, 2*(len(params.UnaryHandlerParams)+len(params.OnewayHandlerParams)+len(params.StreamHandlerParams)))
for _, unaryHandlerParams := range params.UnaryHandlerParams {
procedures = append(
procedures,
Expand Down
2 changes: 1 addition & 1 deletion encoding/protobuf/v2/protobuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type BuildProceduresStreamHandlerParams struct {

// BuildProcedures builds the transport.Procedures.
func BuildProcedures(params BuildProceduresParams) []transport.Procedure {
procedures := make([]transport.Procedure, 0, 2*(len(params.UnaryHandlerParams)+len(params.OnewayHandlerParams)))
procedures := make([]transport.Procedure, 0, 2*(len(params.UnaryHandlerParams)+len(params.OnewayHandlerParams)+len(params.StreamHandlerParams)))
for _, unaryHandlerParams := range params.UnaryHandlerParams {
procedures = append(
procedures,
Expand Down
45 changes: 17 additions & 28 deletions encoding/thrift/benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,13 @@ import (
"go.uber.org/yarpc/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalueclient"
"go.uber.org/yarpc/internal/examples/thrift-keyvalue/keyvalue/kv/keyvalueserver"
"go.uber.org/yarpc/transport/tchannel"
"gonum.org/v1/gonum/stat/distuv"
)

const (
_kvServer = "callee"
_kvClient = "caller"
)

type generator struct {
norm distuv.Normal
min int
max int
}

func (g generator) next() int {
out := int(g.norm.Rand())
if out < g.min {
out = 0
}
if out > g.max {
out = g.max
}
return out
}

func BenchmarkThriftClientCallNormalDist(b *testing.B) {
handler := &keyValueHandler{}
serverAddr := newKeyValServer(b, handler)
Expand All @@ -51,20 +33,14 @@ func BenchmarkThriftClientCallNormalDist(b *testing.B) {
clientWithReuse := newKeyValueClient(b, serverAddr, true)

// Create a normal distribution
g := generator{
norm: distuv.Normal{
Mu: 3 * 1024, // 3KB
Sigma: 10000,
},
min: 0,
max: 2 * 1024 * 1024, // 2MB
}
// deviation 10k, mean 3KB, minimum 0, maximum 2MB
g := createNormalDistribution(3*1024, 10_000, 0, 2*1024*1024)

var samples []string
for i := 0; i < 10000; i++ {
key := "foo" + strconv.FormatInt(int64(i), 10)
len := g.next()
value := generateRandomString(len)
length := g()
value := generateRandomString(length)
samples = append(samples, value)
handler.SetValue(context.Background(), &key, &value)
}
Expand Down Expand Up @@ -172,3 +148,16 @@ func newKeyValueClient(t testing.TB, serverAddr string, enableBufferReuse bool)
t.Cleanup(func() { assert.NoError(t, dispatcher.Stop(), "could not stop dispatcher") })
return client
}

func createNormalDistribution(mean, deviation float64, minimum, maximum int) func() int {
r := rand.New(rand.NewSource(time.Now().UnixNano()))
return func() int {
n := int(r.NormFloat64()*mean + deviation)

// 0 <= n <= 2MB
n = max(n, minimum)
n = min(n, maximum)

return n
}
}
3 changes: 1 addition & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ require (
golang.org/x/lint v0.0.0-20200130185559-910be7a94367
golang.org/x/net v0.14.0
golang.org/x/tools v0.7.0
gonum.org/v1/gonum v0.14.0
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013
google.golang.org/grpc v1.40.1
google.golang.org/protobuf v1.26.0
Expand All @@ -47,6 +46,7 @@ require (
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/google/go-cmp v0.5.8 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/kr/pretty v0.2.0 // indirect
Expand All @@ -62,7 +62,6 @@ require (
github.com/uber-common/bark v1.2.1 // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
go.uber.org/dig v1.8.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/sys v0.11.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 h1:ooxPy7fPvB4kwsA2h+iBNHkAbp/4JxTSwCmvdjEYmug=
golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=
golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down Expand Up @@ -313,8 +311,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.14.0 h1:2NiG67LD1tEH0D7kM+ps2V+fXmsAnpUeec7n8tcr4S0=
gonum.org/v1/gonum v0.14.0/go.mod h1:AoWeoz0becf9QMWtE8iWXNXc27fK4fNeHNf/oMejGfU=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180518175338-11a468237815/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
Expand Down
13 changes: 13 additions & 0 deletions internal/firstoutboundmiddleware/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package firstoutboundmiddleware
import (
"context"

"go.uber.org/yarpc/api/encoding"
"go.uber.org/yarpc/api/middleware"
"go.uber.org/yarpc/api/transport"
)
Expand Down Expand Up @@ -73,6 +74,12 @@ func update(ctx context.Context, req *transport.Request, out transport.Outbound)
if namer, ok := out.(transport.Namer); ok {
req.Transport = namer.TransportName()
}

// Update the caller procedure to the current procedure making this request
call := encoding.CallFromContext(ctx)
if call != nil {
req.CallerProcedure = call.Procedure()
}
}

func updateStream(ctx context.Context, req *transport.StreamRequest, out transport.Outbound) {
Expand All @@ -85,4 +92,10 @@ func updateStream(ctx context.Context, req *transport.StreamRequest, out transpo
if namer, ok := out.(transport.Namer); ok {
req.Meta.Transport = namer.TransportName()
}

// Update the caller procedure to the current procedure making this request
call := encoding.CallFromContext(ctx)
if call != nil {
req.Meta.CallerProcedure = call.Procedure()
}
}
6 changes: 3 additions & 3 deletions internal/firstoutboundmiddleware/middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func TestFirstOutboundMidleware(t *testing.T) {
require.NoError(t, err)

assert.Equal(t, "fake", string(req.Transport))
assert.Equal(t, "", string(req.CallerProcedure))
assert.Equal(t, "ABC", string(req.CallerProcedure))
})

t.Run("oneway", func(t *testing.T) {
Expand All @@ -66,7 +66,7 @@ func TestFirstOutboundMidleware(t *testing.T) {
require.NoError(t, err)

assert.Equal(t, "fake", string(req.Transport))
assert.Equal(t, "", string(req.CallerProcedure))
assert.Equal(t, "ABC", string(req.CallerProcedure))
})

t.Run("stream", func(t *testing.T) {
Expand All @@ -78,6 +78,6 @@ func TestFirstOutboundMidleware(t *testing.T) {
require.NoError(t, err)

assert.Equal(t, "fake", string(streamReq.Meta.Transport))
assert.Equal(t, "", string(streamReq.Meta.CallerProcedure))
assert.Equal(t, "ABC", string(streamReq.Meta.CallerProcedure))
})
}
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
package yarpc // import "go.uber.org/yarpc"

// Version is the current version of YARPC.
const Version = "1.71.0"
const Version = "1.72.0"

0 comments on commit 1310bc0

Please sign in to comment.