mirror of
https://github.com/containers/skopeo.git
synced 2025-07-07 19:59:32 +00:00
fix(deps): update module github.com/containers/ocicrypt to v1.2.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
parent
19c7373efa
commit
527a8655a5
10
go.mod
10
go.mod
@ -10,7 +10,7 @@ require (
|
|||||||
github.com/Masterminds/semver/v3 v3.2.1
|
github.com/Masterminds/semver/v3 v3.2.1
|
||||||
github.com/containers/common v0.59.1
|
github.com/containers/common v0.59.1
|
||||||
github.com/containers/image/v5 v5.31.1
|
github.com/containers/image/v5 v5.31.1
|
||||||
github.com/containers/ocicrypt v1.1.10
|
github.com/containers/ocicrypt v1.2.0
|
||||||
github.com/containers/storage v1.54.0
|
github.com/containers/storage v1.54.0
|
||||||
github.com/docker/distribution v2.8.3+incompatible
|
github.com/docker/distribution v2.8.3+incompatible
|
||||||
github.com/opencontainers/go-digest v1.0.0
|
github.com/opencontainers/go-digest v1.0.0
|
||||||
@ -50,7 +50,7 @@ require (
|
|||||||
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
|
github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5 // indirect
|
||||||
github.com/felixge/httpsnoop v1.0.4 // indirect
|
github.com/felixge/httpsnoop v1.0.4 // indirect
|
||||||
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
|
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
|
||||||
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
|
github.com/go-jose/go-jose/v4 v4.0.2 // indirect
|
||||||
github.com/go-logr/logr v1.4.1 // indirect
|
github.com/go-logr/logr v1.4.1 // indirect
|
||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-openapi/analysis v0.23.0 // indirect
|
github.com/go-openapi/analysis v0.23.0 // indirect
|
||||||
@ -125,15 +125,15 @@ require (
|
|||||||
go.opentelemetry.io/otel v1.24.0 // indirect
|
go.opentelemetry.io/otel v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
go.opentelemetry.io/otel/metric v1.24.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
go.opentelemetry.io/otel/trace v1.24.0 // indirect
|
||||||
golang.org/x/crypto v0.23.0 // indirect
|
golang.org/x/crypto v0.24.0 // indirect
|
||||||
golang.org/x/mod v0.18.0 // indirect
|
golang.org/x/mod v0.18.0 // indirect
|
||||||
golang.org/x/net v0.25.0 // indirect
|
golang.org/x/net v0.25.0 // indirect
|
||||||
golang.org/x/oauth2 v0.20.0 // indirect
|
golang.org/x/oauth2 v0.20.0 // indirect
|
||||||
golang.org/x/sync v0.7.0 // indirect
|
golang.org/x/sync v0.7.0 // indirect
|
||||||
golang.org/x/sys v0.21.0 // indirect
|
golang.org/x/sys v0.21.0 // indirect
|
||||||
golang.org/x/text v0.15.0 // indirect
|
golang.org/x/text v0.16.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
|
||||||
google.golang.org/grpc v1.62.1 // indirect
|
google.golang.org/grpc v1.64.0 // indirect
|
||||||
google.golang.org/protobuf v1.33.0 // indirect
|
google.golang.org/protobuf v1.33.0 // indirect
|
||||||
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
|
gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect
|
||||||
)
|
)
|
||||||
|
24
go.sum
24
go.sum
@ -43,8 +43,8 @@ github.com/containers/image/v5 v5.31.1 h1:3x9soI6Biml/GiDLpkSmKrkRSwVGctxu/vONpo
|
|||||||
github.com/containers/image/v5 v5.31.1/go.mod h1:5QfOqSackPkSbF7Qxc1DnVNnPJKQ+KWLkfEfDpK590Q=
|
github.com/containers/image/v5 v5.31.1/go.mod h1:5QfOqSackPkSbF7Qxc1DnVNnPJKQ+KWLkfEfDpK590Q=
|
||||||
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA=
|
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01 h1:Qzk5C6cYglewc+UyGf6lc8Mj2UaPTHy/iF2De0/77CA=
|
||||||
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
|
github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01/go.mod h1:9rfv8iPl1ZP7aqh9YA68wnZv2NUDbXdcdPHVz0pFbPY=
|
||||||
github.com/containers/ocicrypt v1.1.10 h1:r7UR6o8+lyhkEywetubUUgcKFjOWOaWz8cEBrCPX0ic=
|
github.com/containers/ocicrypt v1.2.0 h1:X14EgRK3xNFvJEfI5O4Qn4T3E25ANudSOZz/sirVuPM=
|
||||||
github.com/containers/ocicrypt v1.1.10/go.mod h1:YfzSSr06PTHQwSTUKqDSjish9BeW1E4HUmreluQcMd8=
|
github.com/containers/ocicrypt v1.2.0/go.mod h1:ZNviigQajtdlxIZGibvblVuIFBKIuUI2M0QM12SD31U=
|
||||||
github.com/containers/storage v1.54.0 h1:xwYAlf6n9OnIlURQLLg3FYHbO74fQ/2W2N6EtQEUM4I=
|
github.com/containers/storage v1.54.0 h1:xwYAlf6n9OnIlURQLLg3FYHbO74fQ/2W2N6EtQEUM4I=
|
||||||
github.com/containers/storage v1.54.0/go.mod h1:PlMOoinRrBSnhYODLxt4EXl0nmJt+X0kjG0Xdt9fMTw=
|
github.com/containers/storage v1.54.0/go.mod h1:PlMOoinRrBSnhYODLxt4EXl0nmJt+X0kjG0Xdt9fMTw=
|
||||||
github.com/coreos/go-oidc/v3 v3.10.0 h1:tDnXHnLyiTVyT/2zLDGj09pFPkhND8Gl8lnTRhoEaJU=
|
github.com/coreos/go-oidc/v3 v3.10.0 h1:tDnXHnLyiTVyT/2zLDGj09pFPkhND8Gl8lnTRhoEaJU=
|
||||||
@ -87,8 +87,8 @@ github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2
|
|||||||
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||||
github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k=
|
github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k=
|
||||||
github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ=
|
github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ=
|
||||||
github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U=
|
github.com/go-jose/go-jose/v4 v4.0.2 h1:R3l3kkBds16bO7ZFAEEcofK0MkrAJt3jlJznWZG0nvk=
|
||||||
github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
|
github.com/go-jose/go-jose/v4 v4.0.2/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
|
||||||
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
||||||
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
|
github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ=
|
||||||
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||||
@ -371,8 +371,8 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
golang.org/x/crypto v0.24.0 h1:mnl8DM0o513X8fdIkmyFE/5hTYxbwYOjDS/+rK6qpRI=
|
||||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
golang.org/x/crypto v0.24.0/go.mod h1:Z1PMYSOR5nyMcyAVAIQSKCDwalqy85Aqn1x3Ws4L5DM=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
|
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8 h1:yixxcjnhBmY0nkL253HFVIm0JsFHwrHdT3Yh6szTnfY=
|
||||||
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
|
golang.org/x/exp v0.0.0-20240613232115-7f521ea00fb8/go.mod h1:jj3sYF3dwk5D+ghuXyeI3r5MFf+NT2An6/9dOA95KSI=
|
||||||
@ -439,8 +439,8 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
|||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||||
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||||
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
@ -465,8 +465,8 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
|
|||||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 h1:ImUcDPHjTrAqNhlOkSocDLfG9rrNHH7w7uoKWPaWZ8s=
|
google.golang.org/genproto v0.0.0-20240311173647-c811ad7063a7 h1:ImUcDPHjTrAqNhlOkSocDLfG9rrNHH7w7uoKWPaWZ8s=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7 h1:oqta3O3AnlWbmIE3bFnWbu4bRxZjfbWCp0cKSuZh01E=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4=
|
||||||
google.golang.org/genproto/googleapis/api v0.0.0-20240311173647-c811ad7063a7/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s=
|
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc=
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY=
|
||||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
@ -474,8 +474,8 @@ google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyac
|
|||||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||||
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
|
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
|
||||||
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
|
||||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
2
vendor/github.com/containers/ocicrypt/.golangci.yml
generated
vendored
2
vendor/github.com/containers/ocicrypt/.golangci.yml
generated
vendored
@ -7,7 +7,7 @@ linters:
|
|||||||
- goimports
|
- goimports
|
||||||
- revive
|
- revive
|
||||||
- ineffassign
|
- ineffassign
|
||||||
- vet
|
- govet
|
||||||
- unused
|
- unused
|
||||||
- misspell
|
- misspell
|
||||||
|
|
||||||
|
3
vendor/github.com/containers/ocicrypt/blockcipher/blockcipher.go
generated
vendored
3
vendor/github.com/containers/ocicrypt/blockcipher/blockcipher.go
generated
vendored
@ -96,9 +96,8 @@ func (lbco LayerBlockCipherOptions) GetOpt(key string) (value []byte, ok bool) {
|
|||||||
return v, ok
|
return v, ok
|
||||||
} else if v, ok := lbco.Private.CipherOptions[key]; ok {
|
} else if v, ok := lbco.Private.CipherOptions[key]; ok {
|
||||||
return v, ok
|
return v, ok
|
||||||
} else {
|
|
||||||
return nil, false
|
|
||||||
}
|
}
|
||||||
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func wrapFinalizerWithType(fin Finalizer, typ LayerCipherType) Finalizer {
|
func wrapFinalizerWithType(fin Finalizer, typ LayerCipherType) Finalizer {
|
||||||
|
3
vendor/github.com/containers/ocicrypt/gpg.go
generated
vendored
3
vendor/github.com/containers/ocicrypt/gpg.go
generated
vendored
@ -79,9 +79,8 @@ func GuessGPGVersion() GPGVersion {
|
|||||||
return GPGv2
|
return GPGv2
|
||||||
} else if err := exec.Command("gpg", "--version").Run(); err == nil {
|
} else if err := exec.Command("gpg", "--version").Run(); err == nil {
|
||||||
return GPGv1
|
return GPGv1
|
||||||
} else {
|
|
||||||
return GPGVersionUndetermined
|
|
||||||
}
|
}
|
||||||
|
return GPGVersionUndetermined
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewGPGClient creates a new GPGClient object representing the given version
|
// NewGPGClient creates a new GPGClient object representing the given version
|
||||||
|
8
vendor/github.com/containers/ocicrypt/keywrap/jwe/keywrapper_jwe.go
generated
vendored
8
vendor/github.com/containers/ocicrypt/keywrap/jwe/keywrapper_jwe.go
generated
vendored
@ -24,7 +24,7 @@ import (
|
|||||||
"github.com/containers/ocicrypt/config"
|
"github.com/containers/ocicrypt/config"
|
||||||
"github.com/containers/ocicrypt/keywrap"
|
"github.com/containers/ocicrypt/keywrap"
|
||||||
"github.com/containers/ocicrypt/utils"
|
"github.com/containers/ocicrypt/utils"
|
||||||
"github.com/go-jose/go-jose/v3"
|
"github.com/go-jose/go-jose/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
type jweKeyWrapper struct {
|
type jweKeyWrapper struct {
|
||||||
@ -65,7 +65,11 @@ func (kw *jweKeyWrapper) WrapKeys(ec *config.EncryptConfig, optsData []byte) ([]
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (kw *jweKeyWrapper) UnwrapKey(dc *config.DecryptConfig, jweString []byte) ([]byte, error) {
|
func (kw *jweKeyWrapper) UnwrapKey(dc *config.DecryptConfig, jweString []byte) ([]byte, error) {
|
||||||
jwe, err := jose.ParseEncrypted(string(jweString))
|
// cf. list of algorithms in func addPubKeys() below
|
||||||
|
keyEncryptionAlgorithms := []jose.KeyAlgorithm{jose.RSA_OAEP, jose.RSA_OAEP_256, jose.ECDH_ES_A128KW, jose.ECDH_ES_A192KW, jose.ECDH_ES_A256KW}
|
||||||
|
// accept all algorithms defined in RFC 7518, section 5.1
|
||||||
|
contentEncryption := []jose.ContentEncryption{jose.A128CBC_HS256, jose.A192CBC_HS384, jose.A256CBC_HS512, jose.A128GCM, jose.A192GCM, jose.A256GCM}
|
||||||
|
jwe, err := jose.ParseEncrypted(string(jweString), keyEncryptionAlgorithms, contentEncryption)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.New("jose.ParseEncrypted failed")
|
return nil, errors.New("jose.ParseEncrypted failed")
|
||||||
}
|
}
|
||||||
|
6
vendor/github.com/containers/ocicrypt/keywrap/keyprovider/keyprovider.go
generated
vendored
6
vendor/github.com/containers/ocicrypt/keywrap/keyprovider/keyprovider.go
generated
vendored
@ -124,9 +124,8 @@ func (kw *keyProviderKeyWrapper) WrapKeys(ec *config.EncryptConfig, optsData []b
|
|||||||
}
|
}
|
||||||
|
|
||||||
return protocolOuput.KeyWrapResults.Annotation, nil
|
return protocolOuput.KeyWrapResults.Annotation, nil
|
||||||
} else {
|
|
||||||
return nil, errors.New("Unsupported keyprovider invocation. Supported invocation methods are grpc and cmd")
|
|
||||||
}
|
}
|
||||||
|
return nil, errors.New("Unsupported keyprovider invocation. Supported invocation methods are grpc and cmd")
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
@ -162,9 +161,8 @@ func (kw *keyProviderKeyWrapper) UnwrapKey(dc *config.DecryptConfig, jsonString
|
|||||||
}
|
}
|
||||||
|
|
||||||
return protocolOuput.KeyUnwrapResults.OptsData, nil
|
return protocolOuput.KeyUnwrapResults.OptsData, nil
|
||||||
} else {
|
|
||||||
return nil, errors.New("Unsupported keyprovider invocation. Supported invocation methods are grpc and cmd")
|
|
||||||
}
|
}
|
||||||
|
return nil, errors.New("Unsupported keyprovider invocation. Supported invocation methods are grpc and cmd")
|
||||||
}
|
}
|
||||||
|
|
||||||
func getProviderGRPCOutput(input []byte, connString string, operation KeyProviderKeyWrapProtocolOperation) (*KeyProviderKeyWrapProtocolOutput, error) {
|
func getProviderGRPCOutput(input []byte, connString string, operation KeyProviderKeyWrapProtocolOperation) (*KeyProviderKeyWrapProtocolOutput, error) {
|
||||||
|
2
vendor/github.com/containers/ocicrypt/utils/utils.go
generated
vendored
2
vendor/github.com/containers/ocicrypt/utils/utils.go
generated
vendored
@ -26,7 +26,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/containers/ocicrypt/crypto/pkcs11"
|
"github.com/containers/ocicrypt/crypto/pkcs11"
|
||||||
"github.com/go-jose/go-jose/v3"
|
"github.com/go-jose/go-jose/v4"
|
||||||
"golang.org/x/crypto/openpgp"
|
"golang.org/x/crypto/openpgp"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
10
vendor/github.com/go-jose/go-jose/v4/shared.go
generated
vendored
10
vendor/github.com/go-jose/go-jose/v4/shared.go
generated
vendored
@ -71,6 +71,12 @@ var (
|
|||||||
// ErrUnprotectedNonce indicates that while parsing a JWS or JWE object, a
|
// ErrUnprotectedNonce indicates that while parsing a JWS or JWE object, a
|
||||||
// nonce header parameter was included in an unprotected header object.
|
// nonce header parameter was included in an unprotected header object.
|
||||||
ErrUnprotectedNonce = errors.New("go-jose/go-jose: Nonce parameter included in unprotected header")
|
ErrUnprotectedNonce = errors.New("go-jose/go-jose: Nonce parameter included in unprotected header")
|
||||||
|
|
||||||
|
// ErrMissingX5cHeader indicates that the JWT header is missing x5c headers.
|
||||||
|
ErrMissingX5cHeader = errors.New("go-jose/go-jose: no x5c header present in message")
|
||||||
|
|
||||||
|
// ErrUnsupportedEllipticCurve indicates unsupported or unknown elliptic curve has been found.
|
||||||
|
ErrUnsupportedEllipticCurve = errors.New("go-jose/go-jose: unsupported/unknown elliptic curve")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Key management algorithms
|
// Key management algorithms
|
||||||
@ -199,7 +205,7 @@ type Header struct {
|
|||||||
// not be validated with the given verify options.
|
// not be validated with the given verify options.
|
||||||
func (h Header) Certificates(opts x509.VerifyOptions) ([][]*x509.Certificate, error) {
|
func (h Header) Certificates(opts x509.VerifyOptions) ([][]*x509.Certificate, error) {
|
||||||
if len(h.certificates) == 0 {
|
if len(h.certificates) == 0 {
|
||||||
return nil, errors.New("go-jose/go-jose: no x5c header present in message")
|
return nil, ErrMissingX5cHeader
|
||||||
}
|
}
|
||||||
|
|
||||||
leaf := h.certificates[0]
|
leaf := h.certificates[0]
|
||||||
@ -501,7 +507,7 @@ func curveName(crv elliptic.Curve) (string, error) {
|
|||||||
case elliptic.P521():
|
case elliptic.P521():
|
||||||
return "P-521", nil
|
return "P-521", nil
|
||||||
default:
|
default:
|
||||||
return "", fmt.Errorf("go-jose/go-jose: unsupported/unknown elliptic curve")
|
return "", ErrUnsupportedEllipticCurve
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
vendor/github.com/go-jose/go-jose/v4/signing.go
generated
vendored
2
vendor/github.com/go-jose/go-jose/v4/signing.go
generated
vendored
@ -358,6 +358,8 @@ func (ctx *genericSigner) Options() SignerOptions {
|
|||||||
// - *rsa.PublicKey
|
// - *rsa.PublicKey
|
||||||
// - *JSONWebKey
|
// - *JSONWebKey
|
||||||
// - JSONWebKey
|
// - JSONWebKey
|
||||||
|
// - *JSONWebKeySet
|
||||||
|
// - JSONWebKeySet
|
||||||
// - []byte (an HMAC key)
|
// - []byte (an HMAC key)
|
||||||
// - Any type that implements the OpaqueVerifier interface.
|
// - Any type that implements the OpaqueVerifier interface.
|
||||||
//
|
//
|
||||||
|
34
vendor/golang.org/x/crypto/sha3/hashes.go
generated
vendored
34
vendor/golang.org/x/crypto/sha3/hashes.go
generated
vendored
@ -16,39 +16,43 @@ import (
|
|||||||
// Its generic security strength is 224 bits against preimage attacks,
|
// Its generic security strength is 224 bits against preimage attacks,
|
||||||
// and 112 bits against collision attacks.
|
// and 112 bits against collision attacks.
|
||||||
func New224() hash.Hash {
|
func New224() hash.Hash {
|
||||||
if h := new224Asm(); h != nil {
|
return new224()
|
||||||
return h
|
|
||||||
}
|
|
||||||
return &state{rate: 144, outputLen: 28, dsbyte: 0x06}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New256 creates a new SHA3-256 hash.
|
// New256 creates a new SHA3-256 hash.
|
||||||
// Its generic security strength is 256 bits against preimage attacks,
|
// Its generic security strength is 256 bits against preimage attacks,
|
||||||
// and 128 bits against collision attacks.
|
// and 128 bits against collision attacks.
|
||||||
func New256() hash.Hash {
|
func New256() hash.Hash {
|
||||||
if h := new256Asm(); h != nil {
|
return new256()
|
||||||
return h
|
|
||||||
}
|
|
||||||
return &state{rate: 136, outputLen: 32, dsbyte: 0x06}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New384 creates a new SHA3-384 hash.
|
// New384 creates a new SHA3-384 hash.
|
||||||
// Its generic security strength is 384 bits against preimage attacks,
|
// Its generic security strength is 384 bits against preimage attacks,
|
||||||
// and 192 bits against collision attacks.
|
// and 192 bits against collision attacks.
|
||||||
func New384() hash.Hash {
|
func New384() hash.Hash {
|
||||||
if h := new384Asm(); h != nil {
|
return new384()
|
||||||
return h
|
|
||||||
}
|
|
||||||
return &state{rate: 104, outputLen: 48, dsbyte: 0x06}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// New512 creates a new SHA3-512 hash.
|
// New512 creates a new SHA3-512 hash.
|
||||||
// Its generic security strength is 512 bits against preimage attacks,
|
// Its generic security strength is 512 bits against preimage attacks,
|
||||||
// and 256 bits against collision attacks.
|
// and 256 bits against collision attacks.
|
||||||
func New512() hash.Hash {
|
func New512() hash.Hash {
|
||||||
if h := new512Asm(); h != nil {
|
return new512()
|
||||||
return h
|
}
|
||||||
}
|
|
||||||
|
func new224Generic() *state {
|
||||||
|
return &state{rate: 144, outputLen: 28, dsbyte: 0x06}
|
||||||
|
}
|
||||||
|
|
||||||
|
func new256Generic() *state {
|
||||||
|
return &state{rate: 136, outputLen: 32, dsbyte: 0x06}
|
||||||
|
}
|
||||||
|
|
||||||
|
func new384Generic() *state {
|
||||||
|
return &state{rate: 104, outputLen: 48, dsbyte: 0x06}
|
||||||
|
}
|
||||||
|
|
||||||
|
func new512Generic() *state {
|
||||||
return &state{rate: 72, outputLen: 64, dsbyte: 0x06}
|
return &state{rate: 72, outputLen: 64, dsbyte: 0x06}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
27
vendor/golang.org/x/crypto/sha3/hashes_generic.go
generated
vendored
27
vendor/golang.org/x/crypto/sha3/hashes_generic.go
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
// Copyright 2017 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.
|
|
||||||
|
|
||||||
//go:build !gc || purego || !s390x
|
|
||||||
|
|
||||||
package sha3
|
|
||||||
|
|
||||||
import (
|
|
||||||
"hash"
|
|
||||||
)
|
|
||||||
|
|
||||||
// new224Asm returns an assembly implementation of SHA3-224 if available,
|
|
||||||
// otherwise it returns nil.
|
|
||||||
func new224Asm() hash.Hash { return nil }
|
|
||||||
|
|
||||||
// new256Asm returns an assembly implementation of SHA3-256 if available,
|
|
||||||
// otherwise it returns nil.
|
|
||||||
func new256Asm() hash.Hash { return nil }
|
|
||||||
|
|
||||||
// new384Asm returns an assembly implementation of SHA3-384 if available,
|
|
||||||
// otherwise it returns nil.
|
|
||||||
func new384Asm() hash.Hash { return nil }
|
|
||||||
|
|
||||||
// new512Asm returns an assembly implementation of SHA3-512 if available,
|
|
||||||
// otherwise it returns nil.
|
|
||||||
func new512Asm() hash.Hash { return nil }
|
|
23
vendor/golang.org/x/crypto/sha3/hashes_noasm.go
generated
vendored
Normal file
23
vendor/golang.org/x/crypto/sha3/hashes_noasm.go
generated
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// Copyright 2023 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.
|
||||||
|
|
||||||
|
//go:build !gc || purego || !s390x
|
||||||
|
|
||||||
|
package sha3
|
||||||
|
|
||||||
|
func new224() *state {
|
||||||
|
return new224Generic()
|
||||||
|
}
|
||||||
|
|
||||||
|
func new256() *state {
|
||||||
|
return new256Generic()
|
||||||
|
}
|
||||||
|
|
||||||
|
func new384() *state {
|
||||||
|
return new384Generic()
|
||||||
|
}
|
||||||
|
|
||||||
|
func new512() *state {
|
||||||
|
return new512Generic()
|
||||||
|
}
|
62
vendor/golang.org/x/crypto/sha3/sha3.go
generated
vendored
62
vendor/golang.org/x/crypto/sha3/sha3.go
generated
vendored
@ -23,7 +23,6 @@ const (
|
|||||||
type state struct {
|
type state struct {
|
||||||
// Generic sponge components.
|
// Generic sponge components.
|
||||||
a [25]uint64 // main state of the hash
|
a [25]uint64 // main state of the hash
|
||||||
buf []byte // points into storage
|
|
||||||
rate int // the number of bytes of state to use
|
rate int // the number of bytes of state to use
|
||||||
|
|
||||||
// dsbyte contains the "domain separation" bits and the first bit of
|
// dsbyte contains the "domain separation" bits and the first bit of
|
||||||
@ -40,7 +39,8 @@ type state struct {
|
|||||||
// Extendable-Output Functions (May 2014)"
|
// Extendable-Output Functions (May 2014)"
|
||||||
dsbyte byte
|
dsbyte byte
|
||||||
|
|
||||||
storage storageBuf
|
i, n int // storage[i:n] is the buffer, i is only used while squeezing
|
||||||
|
storage [maxRate]byte
|
||||||
|
|
||||||
// Specific to SHA-3 and SHAKE.
|
// Specific to SHA-3 and SHAKE.
|
||||||
outputLen int // the default output size in bytes
|
outputLen int // the default output size in bytes
|
||||||
@ -54,24 +54,18 @@ func (d *state) BlockSize() int { return d.rate }
|
|||||||
func (d *state) Size() int { return d.outputLen }
|
func (d *state) Size() int { return d.outputLen }
|
||||||
|
|
||||||
// Reset clears the internal state by zeroing the sponge state and
|
// Reset clears the internal state by zeroing the sponge state and
|
||||||
// the byte buffer, and setting Sponge.state to absorbing.
|
// the buffer indexes, and setting Sponge.state to absorbing.
|
||||||
func (d *state) Reset() {
|
func (d *state) Reset() {
|
||||||
// Zero the permutation's state.
|
// Zero the permutation's state.
|
||||||
for i := range d.a {
|
for i := range d.a {
|
||||||
d.a[i] = 0
|
d.a[i] = 0
|
||||||
}
|
}
|
||||||
d.state = spongeAbsorbing
|
d.state = spongeAbsorbing
|
||||||
d.buf = d.storage.asBytes()[:0]
|
d.i, d.n = 0, 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *state) clone() *state {
|
func (d *state) clone() *state {
|
||||||
ret := *d
|
ret := *d
|
||||||
if ret.state == spongeAbsorbing {
|
|
||||||
ret.buf = ret.storage.asBytes()[:len(ret.buf)]
|
|
||||||
} else {
|
|
||||||
ret.buf = ret.storage.asBytes()[d.rate-cap(d.buf) : d.rate]
|
|
||||||
}
|
|
||||||
|
|
||||||
return &ret
|
return &ret
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,43 +76,40 @@ func (d *state) permute() {
|
|||||||
case spongeAbsorbing:
|
case spongeAbsorbing:
|
||||||
// If we're absorbing, we need to xor the input into the state
|
// If we're absorbing, we need to xor the input into the state
|
||||||
// before applying the permutation.
|
// before applying the permutation.
|
||||||
xorIn(d, d.buf)
|
xorIn(d, d.storage[:d.rate])
|
||||||
d.buf = d.storage.asBytes()[:0]
|
d.n = 0
|
||||||
keccakF1600(&d.a)
|
keccakF1600(&d.a)
|
||||||
case spongeSqueezing:
|
case spongeSqueezing:
|
||||||
// If we're squeezing, we need to apply the permutation before
|
// If we're squeezing, we need to apply the permutation before
|
||||||
// copying more output.
|
// copying more output.
|
||||||
keccakF1600(&d.a)
|
keccakF1600(&d.a)
|
||||||
d.buf = d.storage.asBytes()[:d.rate]
|
d.i = 0
|
||||||
copyOut(d, d.buf)
|
copyOut(d, d.storage[:d.rate])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pads appends the domain separation bits in dsbyte, applies
|
// pads appends the domain separation bits in dsbyte, applies
|
||||||
// the multi-bitrate 10..1 padding rule, and permutes the state.
|
// the multi-bitrate 10..1 padding rule, and permutes the state.
|
||||||
func (d *state) padAndPermute(dsbyte byte) {
|
func (d *state) padAndPermute() {
|
||||||
if d.buf == nil {
|
|
||||||
d.buf = d.storage.asBytes()[:0]
|
|
||||||
}
|
|
||||||
// Pad with this instance's domain-separator bits. We know that there's
|
// Pad with this instance's domain-separator bits. We know that there's
|
||||||
// at least one byte of space in d.buf because, if it were full,
|
// at least one byte of space in d.buf because, if it were full,
|
||||||
// permute would have been called to empty it. dsbyte also contains the
|
// permute would have been called to empty it. dsbyte also contains the
|
||||||
// first one bit for the padding. See the comment in the state struct.
|
// first one bit for the padding. See the comment in the state struct.
|
||||||
d.buf = append(d.buf, dsbyte)
|
d.storage[d.n] = d.dsbyte
|
||||||
zerosStart := len(d.buf)
|
d.n++
|
||||||
d.buf = d.storage.asBytes()[:d.rate]
|
for d.n < d.rate {
|
||||||
for i := zerosStart; i < d.rate; i++ {
|
d.storage[d.n] = 0
|
||||||
d.buf[i] = 0
|
d.n++
|
||||||
}
|
}
|
||||||
// This adds the final one bit for the padding. Because of the way that
|
// This adds the final one bit for the padding. Because of the way that
|
||||||
// bits are numbered from the LSB upwards, the final bit is the MSB of
|
// bits are numbered from the LSB upwards, the final bit is the MSB of
|
||||||
// the last byte.
|
// the last byte.
|
||||||
d.buf[d.rate-1] ^= 0x80
|
d.storage[d.rate-1] ^= 0x80
|
||||||
// Apply the permutation
|
// Apply the permutation
|
||||||
d.permute()
|
d.permute()
|
||||||
d.state = spongeSqueezing
|
d.state = spongeSqueezing
|
||||||
d.buf = d.storage.asBytes()[:d.rate]
|
d.n = d.rate
|
||||||
copyOut(d, d.buf)
|
copyOut(d, d.storage[:d.rate])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write absorbs more data into the hash's state. It panics if any
|
// Write absorbs more data into the hash's state. It panics if any
|
||||||
@ -127,28 +118,25 @@ func (d *state) Write(p []byte) (written int, err error) {
|
|||||||
if d.state != spongeAbsorbing {
|
if d.state != spongeAbsorbing {
|
||||||
panic("sha3: Write after Read")
|
panic("sha3: Write after Read")
|
||||||
}
|
}
|
||||||
if d.buf == nil {
|
|
||||||
d.buf = d.storage.asBytes()[:0]
|
|
||||||
}
|
|
||||||
written = len(p)
|
written = len(p)
|
||||||
|
|
||||||
for len(p) > 0 {
|
for len(p) > 0 {
|
||||||
if len(d.buf) == 0 && len(p) >= d.rate {
|
if d.n == 0 && len(p) >= d.rate {
|
||||||
// The fast path; absorb a full "rate" bytes of input and apply the permutation.
|
// The fast path; absorb a full "rate" bytes of input and apply the permutation.
|
||||||
xorIn(d, p[:d.rate])
|
xorIn(d, p[:d.rate])
|
||||||
p = p[d.rate:]
|
p = p[d.rate:]
|
||||||
keccakF1600(&d.a)
|
keccakF1600(&d.a)
|
||||||
} else {
|
} else {
|
||||||
// The slow path; buffer the input until we can fill the sponge, and then xor it in.
|
// The slow path; buffer the input until we can fill the sponge, and then xor it in.
|
||||||
todo := d.rate - len(d.buf)
|
todo := d.rate - d.n
|
||||||
if todo > len(p) {
|
if todo > len(p) {
|
||||||
todo = len(p)
|
todo = len(p)
|
||||||
}
|
}
|
||||||
d.buf = append(d.buf, p[:todo]...)
|
d.n += copy(d.storage[d.n:], p[:todo])
|
||||||
p = p[todo:]
|
p = p[todo:]
|
||||||
|
|
||||||
// If the sponge is full, apply the permutation.
|
// If the sponge is full, apply the permutation.
|
||||||
if len(d.buf) == d.rate {
|
if d.n == d.rate {
|
||||||
d.permute()
|
d.permute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -161,19 +149,19 @@ func (d *state) Write(p []byte) (written int, err error) {
|
|||||||
func (d *state) Read(out []byte) (n int, err error) {
|
func (d *state) Read(out []byte) (n int, err error) {
|
||||||
// If we're still absorbing, pad and apply the permutation.
|
// If we're still absorbing, pad and apply the permutation.
|
||||||
if d.state == spongeAbsorbing {
|
if d.state == spongeAbsorbing {
|
||||||
d.padAndPermute(d.dsbyte)
|
d.padAndPermute()
|
||||||
}
|
}
|
||||||
|
|
||||||
n = len(out)
|
n = len(out)
|
||||||
|
|
||||||
// Now, do the squeezing.
|
// Now, do the squeezing.
|
||||||
for len(out) > 0 {
|
for len(out) > 0 {
|
||||||
n := copy(out, d.buf)
|
n := copy(out, d.storage[d.i:d.n])
|
||||||
d.buf = d.buf[n:]
|
d.i += n
|
||||||
out = out[n:]
|
out = out[n:]
|
||||||
|
|
||||||
// Apply the permutation if we've squeezed the sponge dry.
|
// Apply the permutation if we've squeezed the sponge dry.
|
||||||
if len(d.buf) == 0 {
|
if d.i == d.rate {
|
||||||
d.permute()
|
d.permute()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
48
vendor/golang.org/x/crypto/sha3/sha3_s390x.go
generated
vendored
48
vendor/golang.org/x/crypto/sha3/sha3_s390x.go
generated
vendored
@ -248,56 +248,56 @@ func (s *asmState) Clone() ShakeHash {
|
|||||||
return s.clone()
|
return s.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
// new224Asm returns an assembly implementation of SHA3-224 if available,
|
// new224 returns an assembly implementation of SHA3-224 if available,
|
||||||
// otherwise it returns nil.
|
// otherwise it returns a generic implementation.
|
||||||
func new224Asm() hash.Hash {
|
func new224() hash.Hash {
|
||||||
if cpu.S390X.HasSHA3 {
|
if cpu.S390X.HasSHA3 {
|
||||||
return newAsmState(sha3_224)
|
return newAsmState(sha3_224)
|
||||||
}
|
}
|
||||||
return nil
|
return new224Generic()
|
||||||
}
|
}
|
||||||
|
|
||||||
// new256Asm returns an assembly implementation of SHA3-256 if available,
|
// new256 returns an assembly implementation of SHA3-256 if available,
|
||||||
// otherwise it returns nil.
|
// otherwise it returns a generic implementation.
|
||||||
func new256Asm() hash.Hash {
|
func new256() hash.Hash {
|
||||||
if cpu.S390X.HasSHA3 {
|
if cpu.S390X.HasSHA3 {
|
||||||
return newAsmState(sha3_256)
|
return newAsmState(sha3_256)
|
||||||
}
|
}
|
||||||
return nil
|
return new256Generic()
|
||||||
}
|
}
|
||||||
|
|
||||||
// new384Asm returns an assembly implementation of SHA3-384 if available,
|
// new384 returns an assembly implementation of SHA3-384 if available,
|
||||||
// otherwise it returns nil.
|
// otherwise it returns a generic implementation.
|
||||||
func new384Asm() hash.Hash {
|
func new384() hash.Hash {
|
||||||
if cpu.S390X.HasSHA3 {
|
if cpu.S390X.HasSHA3 {
|
||||||
return newAsmState(sha3_384)
|
return newAsmState(sha3_384)
|
||||||
}
|
}
|
||||||
return nil
|
return new384Generic()
|
||||||
}
|
}
|
||||||
|
|
||||||
// new512Asm returns an assembly implementation of SHA3-512 if available,
|
// new512 returns an assembly implementation of SHA3-512 if available,
|
||||||
// otherwise it returns nil.
|
// otherwise it returns a generic implementation.
|
||||||
func new512Asm() hash.Hash {
|
func new512() hash.Hash {
|
||||||
if cpu.S390X.HasSHA3 {
|
if cpu.S390X.HasSHA3 {
|
||||||
return newAsmState(sha3_512)
|
return newAsmState(sha3_512)
|
||||||
}
|
}
|
||||||
return nil
|
return new512Generic()
|
||||||
}
|
}
|
||||||
|
|
||||||
// newShake128Asm returns an assembly implementation of SHAKE-128 if available,
|
// newShake128 returns an assembly implementation of SHAKE-128 if available,
|
||||||
// otherwise it returns nil.
|
// otherwise it returns a generic implementation.
|
||||||
func newShake128Asm() ShakeHash {
|
func newShake128() ShakeHash {
|
||||||
if cpu.S390X.HasSHA3 {
|
if cpu.S390X.HasSHA3 {
|
||||||
return newAsmState(shake_128)
|
return newAsmState(shake_128)
|
||||||
}
|
}
|
||||||
return nil
|
return newShake128Generic()
|
||||||
}
|
}
|
||||||
|
|
||||||
// newShake256Asm returns an assembly implementation of SHAKE-256 if available,
|
// newShake256 returns an assembly implementation of SHAKE-256 if available,
|
||||||
// otherwise it returns nil.
|
// otherwise it returns a generic implementation.
|
||||||
func newShake256Asm() ShakeHash {
|
func newShake256() ShakeHash {
|
||||||
if cpu.S390X.HasSHA3 {
|
if cpu.S390X.HasSHA3 {
|
||||||
return newAsmState(shake_256)
|
return newAsmState(shake_256)
|
||||||
}
|
}
|
||||||
return nil
|
return newShake256Generic()
|
||||||
}
|
}
|
||||||
|
16
vendor/golang.org/x/crypto/sha3/shake.go
generated
vendored
16
vendor/golang.org/x/crypto/sha3/shake.go
generated
vendored
@ -115,19 +115,21 @@ func (c *state) Clone() ShakeHash {
|
|||||||
// Its generic security strength is 128 bits against all attacks if at
|
// Its generic security strength is 128 bits against all attacks if at
|
||||||
// least 32 bytes of its output are used.
|
// least 32 bytes of its output are used.
|
||||||
func NewShake128() ShakeHash {
|
func NewShake128() ShakeHash {
|
||||||
if h := newShake128Asm(); h != nil {
|
return newShake128()
|
||||||
return h
|
|
||||||
}
|
|
||||||
return &state{rate: rate128, outputLen: 32, dsbyte: dsbyteShake}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewShake256 creates a new SHAKE256 variable-output-length ShakeHash.
|
// NewShake256 creates a new SHAKE256 variable-output-length ShakeHash.
|
||||||
// Its generic security strength is 256 bits against all attacks if
|
// Its generic security strength is 256 bits against all attacks if
|
||||||
// at least 64 bytes of its output are used.
|
// at least 64 bytes of its output are used.
|
||||||
func NewShake256() ShakeHash {
|
func NewShake256() ShakeHash {
|
||||||
if h := newShake256Asm(); h != nil {
|
return newShake256()
|
||||||
return h
|
}
|
||||||
}
|
|
||||||
|
func newShake128Generic() *state {
|
||||||
|
return &state{rate: rate128, outputLen: 32, dsbyte: dsbyteShake}
|
||||||
|
}
|
||||||
|
|
||||||
|
func newShake256Generic() *state {
|
||||||
return &state{rate: rate256, outputLen: 64, dsbyte: dsbyteShake}
|
return &state{rate: rate256, outputLen: 64, dsbyte: dsbyteShake}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
vendor/golang.org/x/crypto/sha3/shake_generic.go
generated
vendored
19
vendor/golang.org/x/crypto/sha3/shake_generic.go
generated
vendored
@ -1,19 +0,0 @@
|
|||||||
// Copyright 2017 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.
|
|
||||||
|
|
||||||
//go:build !gc || purego || !s390x
|
|
||||||
|
|
||||||
package sha3
|
|
||||||
|
|
||||||
// newShake128Asm returns an assembly implementation of SHAKE-128 if available,
|
|
||||||
// otherwise it returns nil.
|
|
||||||
func newShake128Asm() ShakeHash {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// newShake256Asm returns an assembly implementation of SHAKE-256 if available,
|
|
||||||
// otherwise it returns nil.
|
|
||||||
func newShake256Asm() ShakeHash {
|
|
||||||
return nil
|
|
||||||
}
|
|
15
vendor/golang.org/x/crypto/sha3/shake_noasm.go
generated
vendored
Normal file
15
vendor/golang.org/x/crypto/sha3/shake_noasm.go
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Copyright 2023 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.
|
||||||
|
|
||||||
|
//go:build !gc || purego || !s390x
|
||||||
|
|
||||||
|
package sha3
|
||||||
|
|
||||||
|
func newShake128() *state {
|
||||||
|
return newShake128Generic()
|
||||||
|
}
|
||||||
|
|
||||||
|
func newShake256() *state {
|
||||||
|
return newShake256Generic()
|
||||||
|
}
|
45
vendor/golang.org/x/crypto/sha3/xor.go
generated
vendored
45
vendor/golang.org/x/crypto/sha3/xor.go
generated
vendored
@ -2,22 +2,39 @@
|
|||||||
// Use of this source code is governed by a BSD-style
|
// Use of this source code is governed by a BSD-style
|
||||||
// license that can be found in the LICENSE file.
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
//go:build (!amd64 && !386 && !ppc64le) || purego
|
|
||||||
|
|
||||||
package sha3
|
package sha3
|
||||||
|
|
||||||
// A storageBuf is an aligned array of maxRate bytes.
|
import (
|
||||||
type storageBuf [maxRate]byte
|
"crypto/subtle"
|
||||||
|
"encoding/binary"
|
||||||
|
"unsafe"
|
||||||
|
|
||||||
func (b *storageBuf) asBytes() *[maxRate]byte {
|
"golang.org/x/sys/cpu"
|
||||||
return (*[maxRate]byte)(b)
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
xorIn = xorInGeneric
|
|
||||||
copyOut = copyOutGeneric
|
|
||||||
xorInUnaligned = xorInGeneric
|
|
||||||
copyOutUnaligned = copyOutGeneric
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const xorImplementationUnaligned = "generic"
|
// xorIn xors the bytes in buf into the state.
|
||||||
|
func xorIn(d *state, buf []byte) {
|
||||||
|
if cpu.IsBigEndian {
|
||||||
|
for i := 0; len(buf) >= 8; i++ {
|
||||||
|
a := binary.LittleEndian.Uint64(buf)
|
||||||
|
d.a[i] ^= a
|
||||||
|
buf = buf[8:]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ab := (*[25 * 64 / 8]byte)(unsafe.Pointer(&d.a))
|
||||||
|
subtle.XORBytes(ab[:], ab[:], buf)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// copyOut copies uint64s to a byte buffer.
|
||||||
|
func copyOut(d *state, b []byte) {
|
||||||
|
if cpu.IsBigEndian {
|
||||||
|
for i := 0; len(b) >= 8; i++ {
|
||||||
|
binary.LittleEndian.PutUint64(b, d.a[i])
|
||||||
|
b = b[8:]
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
ab := (*[25 * 64 / 8]byte)(unsafe.Pointer(&d.a))
|
||||||
|
copy(b, ab[:])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
28
vendor/golang.org/x/crypto/sha3/xor_generic.go
generated
vendored
28
vendor/golang.org/x/crypto/sha3/xor_generic.go
generated
vendored
@ -1,28 +0,0 @@
|
|||||||
// Copyright 2015 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.
|
|
||||||
|
|
||||||
package sha3
|
|
||||||
|
|
||||||
import "encoding/binary"
|
|
||||||
|
|
||||||
// xorInGeneric xors the bytes in buf into the state; it
|
|
||||||
// makes no non-portable assumptions about memory layout
|
|
||||||
// or alignment.
|
|
||||||
func xorInGeneric(d *state, buf []byte) {
|
|
||||||
n := len(buf) / 8
|
|
||||||
|
|
||||||
for i := 0; i < n; i++ {
|
|
||||||
a := binary.LittleEndian.Uint64(buf)
|
|
||||||
d.a[i] ^= a
|
|
||||||
buf = buf[8:]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// copyOutGeneric copies uint64s to a byte buffer.
|
|
||||||
func copyOutGeneric(d *state, b []byte) {
|
|
||||||
for i := 0; len(b) >= 8; i++ {
|
|
||||||
binary.LittleEndian.PutUint64(b, d.a[i])
|
|
||||||
b = b[8:]
|
|
||||||
}
|
|
||||||
}
|
|
66
vendor/golang.org/x/crypto/sha3/xor_unaligned.go
generated
vendored
66
vendor/golang.org/x/crypto/sha3/xor_unaligned.go
generated
vendored
@ -1,66 +0,0 @@
|
|||||||
// Copyright 2015 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.
|
|
||||||
|
|
||||||
//go:build (amd64 || 386 || ppc64le) && !purego
|
|
||||||
|
|
||||||
package sha3
|
|
||||||
|
|
||||||
import "unsafe"
|
|
||||||
|
|
||||||
// A storageBuf is an aligned array of maxRate bytes.
|
|
||||||
type storageBuf [maxRate / 8]uint64
|
|
||||||
|
|
||||||
func (b *storageBuf) asBytes() *[maxRate]byte {
|
|
||||||
return (*[maxRate]byte)(unsafe.Pointer(b))
|
|
||||||
}
|
|
||||||
|
|
||||||
// xorInUnaligned uses unaligned reads and writes to update d.a to contain d.a
|
|
||||||
// XOR buf.
|
|
||||||
func xorInUnaligned(d *state, buf []byte) {
|
|
||||||
n := len(buf)
|
|
||||||
bw := (*[maxRate / 8]uint64)(unsafe.Pointer(&buf[0]))[: n/8 : n/8]
|
|
||||||
if n >= 72 {
|
|
||||||
d.a[0] ^= bw[0]
|
|
||||||
d.a[1] ^= bw[1]
|
|
||||||
d.a[2] ^= bw[2]
|
|
||||||
d.a[3] ^= bw[3]
|
|
||||||
d.a[4] ^= bw[4]
|
|
||||||
d.a[5] ^= bw[5]
|
|
||||||
d.a[6] ^= bw[6]
|
|
||||||
d.a[7] ^= bw[7]
|
|
||||||
d.a[8] ^= bw[8]
|
|
||||||
}
|
|
||||||
if n >= 104 {
|
|
||||||
d.a[9] ^= bw[9]
|
|
||||||
d.a[10] ^= bw[10]
|
|
||||||
d.a[11] ^= bw[11]
|
|
||||||
d.a[12] ^= bw[12]
|
|
||||||
}
|
|
||||||
if n >= 136 {
|
|
||||||
d.a[13] ^= bw[13]
|
|
||||||
d.a[14] ^= bw[14]
|
|
||||||
d.a[15] ^= bw[15]
|
|
||||||
d.a[16] ^= bw[16]
|
|
||||||
}
|
|
||||||
if n >= 144 {
|
|
||||||
d.a[17] ^= bw[17]
|
|
||||||
}
|
|
||||||
if n >= 168 {
|
|
||||||
d.a[18] ^= bw[18]
|
|
||||||
d.a[19] ^= bw[19]
|
|
||||||
d.a[20] ^= bw[20]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func copyOutUnaligned(d *state, buf []byte) {
|
|
||||||
ab := (*[maxRate]uint8)(unsafe.Pointer(&d.a[0]))
|
|
||||||
copy(buf, ab[:])
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
xorIn = xorInUnaligned
|
|
||||||
copyOut = copyOutUnaligned
|
|
||||||
)
|
|
||||||
|
|
||||||
const xorImplementationUnaligned = "unaligned"
|
|
2
vendor/google.golang.org/grpc/CONTRIBUTING.md
generated
vendored
2
vendor/google.golang.org/grpc/CONTRIBUTING.md
generated
vendored
@ -66,7 +66,7 @@ How to get your contributions merged smoothly and quickly.
|
|||||||
- **All tests need to be passing** before your change can be merged. We
|
- **All tests need to be passing** before your change can be merged. We
|
||||||
recommend you **run tests locally** before creating your PR to catch breakages
|
recommend you **run tests locally** before creating your PR to catch breakages
|
||||||
early on.
|
early on.
|
||||||
- `VET_SKIP_PROTO=1 ./vet.sh` to catch vet errors
|
- `./scripts/vet.sh` to catch vet errors
|
||||||
- `go test -cpu 1,4 -timeout 7m ./...` to run the tests
|
- `go test -cpu 1,4 -timeout 7m ./...` to run the tests
|
||||||
- `go test -race -cpu 1,4 -timeout 7m ./...` to run tests in race mode
|
- `go test -race -cpu 1,4 -timeout 7m ./...` to run tests in race mode
|
||||||
|
|
||||||
|
1
vendor/google.golang.org/grpc/MAINTAINERS.md
generated
vendored
1
vendor/google.golang.org/grpc/MAINTAINERS.md
generated
vendored
@ -9,6 +9,7 @@ for general contribution guidelines.
|
|||||||
|
|
||||||
## Maintainers (in alphabetical order)
|
## Maintainers (in alphabetical order)
|
||||||
|
|
||||||
|
- [atollena](https://github.com/atollena), Datadog, Inc.
|
||||||
- [cesarghali](https://github.com/cesarghali), Google LLC
|
- [cesarghali](https://github.com/cesarghali), Google LLC
|
||||||
- [dfawley](https://github.com/dfawley), Google LLC
|
- [dfawley](https://github.com/dfawley), Google LLC
|
||||||
- [easwars](https://github.com/easwars), Google LLC
|
- [easwars](https://github.com/easwars), Google LLC
|
||||||
|
7
vendor/google.golang.org/grpc/Makefile
generated
vendored
7
vendor/google.golang.org/grpc/Makefile
generated
vendored
@ -30,17 +30,20 @@ testdeps:
|
|||||||
GO111MODULE=on go get -d -v -t google.golang.org/grpc/...
|
GO111MODULE=on go get -d -v -t google.golang.org/grpc/...
|
||||||
|
|
||||||
vet: vetdeps
|
vet: vetdeps
|
||||||
./vet.sh
|
./scripts/vet.sh
|
||||||
|
|
||||||
vetdeps:
|
vetdeps:
|
||||||
./vet.sh -install
|
./scripts/vet.sh -install
|
||||||
|
|
||||||
.PHONY: \
|
.PHONY: \
|
||||||
all \
|
all \
|
||||||
build \
|
build \
|
||||||
clean \
|
clean \
|
||||||
|
deps \
|
||||||
proto \
|
proto \
|
||||||
test \
|
test \
|
||||||
|
testsubmodule \
|
||||||
testrace \
|
testrace \
|
||||||
|
testdeps \
|
||||||
vet \
|
vet \
|
||||||
vetdeps
|
vetdeps
|
||||||
|
9
vendor/google.golang.org/grpc/balancer/balancer.go
generated
vendored
9
vendor/google.golang.org/grpc/balancer/balancer.go
generated
vendored
@ -54,13 +54,14 @@ var (
|
|||||||
// an init() function), and is not thread-safe. If multiple Balancers are
|
// an init() function), and is not thread-safe. If multiple Balancers are
|
||||||
// registered with the same name, the one registered last will take effect.
|
// registered with the same name, the one registered last will take effect.
|
||||||
func Register(b Builder) {
|
func Register(b Builder) {
|
||||||
if strings.ToLower(b.Name()) != b.Name() {
|
name := strings.ToLower(b.Name())
|
||||||
|
if name != b.Name() {
|
||||||
// TODO: Skip the use of strings.ToLower() to index the map after v1.59
|
// TODO: Skip the use of strings.ToLower() to index the map after v1.59
|
||||||
// is released to switch to case sensitive balancer registry. Also,
|
// is released to switch to case sensitive balancer registry. Also,
|
||||||
// remove this warning and update the docstrings for Register and Get.
|
// remove this warning and update the docstrings for Register and Get.
|
||||||
logger.Warningf("Balancer registered with name %q. grpc-go will be switching to case sensitive balancer registries soon", b.Name())
|
logger.Warningf("Balancer registered with name %q. grpc-go will be switching to case sensitive balancer registries soon", b.Name())
|
||||||
}
|
}
|
||||||
m[strings.ToLower(b.Name())] = b
|
m[name] = b
|
||||||
}
|
}
|
||||||
|
|
||||||
// unregisterForTesting deletes the balancer with the given name from the
|
// unregisterForTesting deletes the balancer with the given name from the
|
||||||
@ -232,8 +233,8 @@ type BuildOptions struct {
|
|||||||
// implementations which do not communicate with a remote load balancer
|
// implementations which do not communicate with a remote load balancer
|
||||||
// server can ignore this field.
|
// server can ignore this field.
|
||||||
Authority string
|
Authority string
|
||||||
// ChannelzParentID is the parent ClientConn's channelz ID.
|
// ChannelzParent is the parent ClientConn's channelz channel.
|
||||||
ChannelzParentID *channelz.Identifier
|
ChannelzParent channelz.Identifier
|
||||||
// CustomUserAgent is the custom user agent set on the parent ClientConn.
|
// CustomUserAgent is the custom user agent set on the parent ClientConn.
|
||||||
// The balancer should set the same custom user agent if it creates a
|
// The balancer should set the same custom user agent if it creates a
|
||||||
// ClientConn.
|
// ClientConn.
|
||||||
|
77
vendor/google.golang.org/grpc/balancer_wrapper.go
generated
vendored
77
vendor/google.golang.org/grpc/balancer_wrapper.go
generated
vendored
@ -21,7 +21,6 @@ package grpc
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"google.golang.org/grpc/balancer"
|
"google.golang.org/grpc/balancer"
|
||||||
@ -66,19 +65,20 @@ type ccBalancerWrapper struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newCCBalancerWrapper creates a new balancer wrapper in idle state. The
|
// newCCBalancerWrapper creates a new balancer wrapper in idle state. The
|
||||||
// underlying balancer is not created until the switchTo() method is invoked.
|
// underlying balancer is not created until the updateClientConnState() method
|
||||||
|
// is invoked.
|
||||||
func newCCBalancerWrapper(cc *ClientConn) *ccBalancerWrapper {
|
func newCCBalancerWrapper(cc *ClientConn) *ccBalancerWrapper {
|
||||||
ctx, cancel := context.WithCancel(cc.ctx)
|
ctx, cancel := context.WithCancel(cc.ctx)
|
||||||
ccb := &ccBalancerWrapper{
|
ccb := &ccBalancerWrapper{
|
||||||
cc: cc,
|
cc: cc,
|
||||||
opts: balancer.BuildOptions{
|
opts: balancer.BuildOptions{
|
||||||
DialCreds: cc.dopts.copts.TransportCredentials,
|
DialCreds: cc.dopts.copts.TransportCredentials,
|
||||||
CredsBundle: cc.dopts.copts.CredsBundle,
|
CredsBundle: cc.dopts.copts.CredsBundle,
|
||||||
Dialer: cc.dopts.copts.Dialer,
|
Dialer: cc.dopts.copts.Dialer,
|
||||||
Authority: cc.authority,
|
Authority: cc.authority,
|
||||||
CustomUserAgent: cc.dopts.copts.UserAgent,
|
CustomUserAgent: cc.dopts.copts.UserAgent,
|
||||||
ChannelzParentID: cc.channelzID,
|
ChannelzParent: cc.channelz,
|
||||||
Target: cc.parsedTarget,
|
Target: cc.parsedTarget,
|
||||||
},
|
},
|
||||||
serializer: grpcsync.NewCallbackSerializer(ctx),
|
serializer: grpcsync.NewCallbackSerializer(ctx),
|
||||||
serializerCancel: cancel,
|
serializerCancel: cancel,
|
||||||
@ -97,6 +97,11 @@ func (ccb *ccBalancerWrapper) updateClientConnState(ccs *balancer.ClientConnStat
|
|||||||
if ctx.Err() != nil || ccb.balancer == nil {
|
if ctx.Err() != nil || ccb.balancer == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
name := gracefulswitch.ChildName(ccs.BalancerConfig)
|
||||||
|
if ccb.curBalancerName != name {
|
||||||
|
ccb.curBalancerName = name
|
||||||
|
channelz.Infof(logger, ccb.cc.channelz, "Channel switches to new LB policy %q", name)
|
||||||
|
}
|
||||||
err := ccb.balancer.UpdateClientConnState(*ccs)
|
err := ccb.balancer.UpdateClientConnState(*ccs)
|
||||||
if logger.V(2) && err != nil {
|
if logger.V(2) && err != nil {
|
||||||
logger.Infof("error from balancer.UpdateClientConnState: %v", err)
|
logger.Infof("error from balancer.UpdateClientConnState: %v", err)
|
||||||
@ -120,54 +125,6 @@ func (ccb *ccBalancerWrapper) resolverError(err error) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// switchTo is invoked by grpc to instruct the balancer wrapper to switch to the
|
|
||||||
// LB policy identified by name.
|
|
||||||
//
|
|
||||||
// ClientConn calls newCCBalancerWrapper() at creation time. Upon receipt of the
|
|
||||||
// first good update from the name resolver, it determines the LB policy to use
|
|
||||||
// and invokes the switchTo() method. Upon receipt of every subsequent update
|
|
||||||
// from the name resolver, it invokes this method.
|
|
||||||
//
|
|
||||||
// the ccBalancerWrapper keeps track of the current LB policy name, and skips
|
|
||||||
// the graceful balancer switching process if the name does not change.
|
|
||||||
func (ccb *ccBalancerWrapper) switchTo(name string) {
|
|
||||||
ccb.serializer.Schedule(func(ctx context.Context) {
|
|
||||||
if ctx.Err() != nil || ccb.balancer == nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// TODO: Other languages use case-sensitive balancer registries. We should
|
|
||||||
// switch as well. See: https://github.com/grpc/grpc-go/issues/5288.
|
|
||||||
if strings.EqualFold(ccb.curBalancerName, name) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ccb.buildLoadBalancingPolicy(name)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// buildLoadBalancingPolicy performs the following:
|
|
||||||
// - retrieve a balancer builder for the given name. Use the default LB
|
|
||||||
// policy, pick_first, if no LB policy with name is found in the registry.
|
|
||||||
// - instruct the gracefulswitch balancer to switch to the above builder. This
|
|
||||||
// will actually build the new balancer.
|
|
||||||
// - update the `curBalancerName` field
|
|
||||||
//
|
|
||||||
// Must be called from a serializer callback.
|
|
||||||
func (ccb *ccBalancerWrapper) buildLoadBalancingPolicy(name string) {
|
|
||||||
builder := balancer.Get(name)
|
|
||||||
if builder == nil {
|
|
||||||
channelz.Warningf(logger, ccb.cc.channelzID, "Channel switches to new LB policy %q, since the specified LB policy %q was not registered", PickFirstBalancerName, name)
|
|
||||||
builder = newPickfirstBuilder()
|
|
||||||
} else {
|
|
||||||
channelz.Infof(logger, ccb.cc.channelzID, "Channel switches to new LB policy %q", name)
|
|
||||||
}
|
|
||||||
|
|
||||||
if err := ccb.balancer.SwitchTo(builder); err != nil {
|
|
||||||
channelz.Errorf(logger, ccb.cc.channelzID, "Channel failed to build new LB policy %q: %v", name, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
ccb.curBalancerName = builder.Name()
|
|
||||||
}
|
|
||||||
|
|
||||||
// close initiates async shutdown of the wrapper. cc.mu must be held when
|
// close initiates async shutdown of the wrapper. cc.mu must be held when
|
||||||
// calling this function. To determine the wrapper has finished shutting down,
|
// calling this function. To determine the wrapper has finished shutting down,
|
||||||
// the channel should block on ccb.serializer.Done() without cc.mu held.
|
// the channel should block on ccb.serializer.Done() without cc.mu held.
|
||||||
@ -175,7 +132,7 @@ func (ccb *ccBalancerWrapper) close() {
|
|||||||
ccb.mu.Lock()
|
ccb.mu.Lock()
|
||||||
ccb.closed = true
|
ccb.closed = true
|
||||||
ccb.mu.Unlock()
|
ccb.mu.Unlock()
|
||||||
channelz.Info(logger, ccb.cc.channelzID, "ccBalancerWrapper: closing")
|
channelz.Info(logger, ccb.cc.channelz, "ccBalancerWrapper: closing")
|
||||||
ccb.serializer.Schedule(func(context.Context) {
|
ccb.serializer.Schedule(func(context.Context) {
|
||||||
if ccb.balancer == nil {
|
if ccb.balancer == nil {
|
||||||
return
|
return
|
||||||
@ -212,7 +169,7 @@ func (ccb *ccBalancerWrapper) NewSubConn(addrs []resolver.Address, opts balancer
|
|||||||
}
|
}
|
||||||
ac, err := ccb.cc.newAddrConnLocked(addrs, opts)
|
ac, err := ccb.cc.newAddrConnLocked(addrs, opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
channelz.Warningf(logger, ccb.cc.channelzID, "acBalancerWrapper: NewSubConn: failed to newAddrConn: %v", err)
|
channelz.Warningf(logger, ccb.cc.channelz, "acBalancerWrapper: NewSubConn: failed to newAddrConn: %v", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
acbw := &acBalancerWrapper{
|
acbw := &acBalancerWrapper{
|
||||||
@ -304,7 +261,7 @@ func (acbw *acBalancerWrapper) updateState(s connectivity.State, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (acbw *acBalancerWrapper) String() string {
|
func (acbw *acBalancerWrapper) String() string {
|
||||||
return fmt.Sprintf("SubConn(id:%d)", acbw.ac.channelzID.Int())
|
return fmt.Sprintf("SubConn(id:%d)", acbw.ac.channelz.ID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (acbw *acBalancerWrapper) UpdateAddresses(addrs []resolver.Address) {
|
func (acbw *acBalancerWrapper) UpdateAddresses(addrs []resolver.Address) {
|
||||||
|
2
vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go
generated
vendored
2
vendor/google.golang.org/grpc/binarylog/grpc_binarylog_v1/binarylog.pb.go
generated
vendored
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||||
// versions:
|
// versions:
|
||||||
// protoc-gen-go v1.32.0
|
// protoc-gen-go v1.33.0
|
||||||
// protoc v4.25.2
|
// protoc v4.25.2
|
||||||
// source: grpc/binlog/v1/binarylog.proto
|
// source: grpc/binlog/v1/binarylog.proto
|
||||||
|
|
||||||
|
319
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
319
vendor/google.golang.org/grpc/clientconn.go
generated
vendored
@ -37,7 +37,6 @@ import (
|
|||||||
"google.golang.org/grpc/internal/channelz"
|
"google.golang.org/grpc/internal/channelz"
|
||||||
"google.golang.org/grpc/internal/grpcsync"
|
"google.golang.org/grpc/internal/grpcsync"
|
||||||
"google.golang.org/grpc/internal/idle"
|
"google.golang.org/grpc/internal/idle"
|
||||||
"google.golang.org/grpc/internal/pretty"
|
|
||||||
iresolver "google.golang.org/grpc/internal/resolver"
|
iresolver "google.golang.org/grpc/internal/resolver"
|
||||||
"google.golang.org/grpc/internal/transport"
|
"google.golang.org/grpc/internal/transport"
|
||||||
"google.golang.org/grpc/keepalive"
|
"google.golang.org/grpc/keepalive"
|
||||||
@ -67,7 +66,7 @@ var (
|
|||||||
errConnDrain = errors.New("grpc: the connection is drained")
|
errConnDrain = errors.New("grpc: the connection is drained")
|
||||||
// errConnClosing indicates that the connection is closing.
|
// errConnClosing indicates that the connection is closing.
|
||||||
errConnClosing = errors.New("grpc: the connection is closing")
|
errConnClosing = errors.New("grpc: the connection is closing")
|
||||||
// errConnIdling indicates the the connection is being closed as the channel
|
// errConnIdling indicates the connection is being closed as the channel
|
||||||
// is moving to an idle mode due to inactivity.
|
// is moving to an idle mode due to inactivity.
|
||||||
errConnIdling = errors.New("grpc: the connection is closing due to channel idleness")
|
errConnIdling = errors.New("grpc: the connection is closing due to channel idleness")
|
||||||
// invalidDefaultServiceConfigErrPrefix is used to prefix the json parsing error for the default
|
// invalidDefaultServiceConfigErrPrefix is used to prefix the json parsing error for the default
|
||||||
@ -101,11 +100,6 @@ const (
|
|||||||
defaultReadBufSize = 32 * 1024
|
defaultReadBufSize = 32 * 1024
|
||||||
)
|
)
|
||||||
|
|
||||||
// Dial creates a client connection to the given target.
|
|
||||||
func Dial(target string, opts ...DialOption) (*ClientConn, error) {
|
|
||||||
return DialContext(context.Background(), target, opts...)
|
|
||||||
}
|
|
||||||
|
|
||||||
type defaultConfigSelector struct {
|
type defaultConfigSelector struct {
|
||||||
sc *ServiceConfig
|
sc *ServiceConfig
|
||||||
}
|
}
|
||||||
@ -117,13 +111,23 @@ func (dcs *defaultConfigSelector) SelectConfig(rpcInfo iresolver.RPCInfo) (*ires
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// newClient returns a new client in idle mode.
|
// NewClient creates a new gRPC "channel" for the target URI provided. No I/O
|
||||||
func newClient(target string, opts ...DialOption) (conn *ClientConn, err error) {
|
// is performed. Use of the ClientConn for RPCs will automatically cause it to
|
||||||
|
// connect. Connect may be used to manually create a connection, but for most
|
||||||
|
// users this is unnecessary.
|
||||||
|
//
|
||||||
|
// The target name syntax is defined in
|
||||||
|
// https://github.com/grpc/grpc/blob/master/doc/naming.md. e.g. to use dns
|
||||||
|
// resolver, a "dns:///" prefix should be applied to the target.
|
||||||
|
//
|
||||||
|
// The DialOptions returned by WithBlock, WithTimeout,
|
||||||
|
// WithReturnConnectionError, and FailOnNonTempDialError are ignored by this
|
||||||
|
// function.
|
||||||
|
func NewClient(target string, opts ...DialOption) (conn *ClientConn, err error) {
|
||||||
cc := &ClientConn{
|
cc := &ClientConn{
|
||||||
target: target,
|
target: target,
|
||||||
conns: make(map[*addrConn]struct{}),
|
conns: make(map[*addrConn]struct{}),
|
||||||
dopts: defaultDialOptions(),
|
dopts: defaultDialOptions(),
|
||||||
czData: new(channelzData),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cc.retryThrottler.Store((*retryThrottler)(nil))
|
cc.retryThrottler.Store((*retryThrottler)(nil))
|
||||||
@ -175,15 +179,15 @@ func newClient(target string, opts ...DialOption) (conn *ClientConn, err error)
|
|||||||
|
|
||||||
// Determine the resolver to use.
|
// Determine the resolver to use.
|
||||||
if err := cc.parseTargetAndFindResolver(); err != nil {
|
if err := cc.parseTargetAndFindResolver(); err != nil {
|
||||||
channelz.RemoveEntry(cc.channelzID)
|
channelz.RemoveEntry(cc.channelz.ID)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if err = cc.determineAuthority(); err != nil {
|
if err = cc.determineAuthority(); err != nil {
|
||||||
channelz.RemoveEntry(cc.channelzID)
|
channelz.RemoveEntry(cc.channelz.ID)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cc.csMgr = newConnectivityStateManager(cc.ctx, cc.channelzID)
|
cc.csMgr = newConnectivityStateManager(cc.ctx, cc.channelz)
|
||||||
cc.pickerWrapper = newPickerWrapper(cc.dopts.copts.StatsHandlers)
|
cc.pickerWrapper = newPickerWrapper(cc.dopts.copts.StatsHandlers)
|
||||||
|
|
||||||
cc.initIdleStateLocked() // Safe to call without the lock, since nothing else has a reference to cc.
|
cc.initIdleStateLocked() // Safe to call without the lock, since nothing else has a reference to cc.
|
||||||
@ -191,39 +195,36 @@ func newClient(target string, opts ...DialOption) (conn *ClientConn, err error)
|
|||||||
return cc, nil
|
return cc, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialContext creates a client connection to the given target. By default, it's
|
// Dial calls DialContext(context.Background(), target, opts...).
|
||||||
// a non-blocking dial (the function won't wait for connections to be
|
|
||||||
// established, and connecting happens in the background). To make it a blocking
|
|
||||||
// dial, use WithBlock() dial option.
|
|
||||||
//
|
//
|
||||||
// In the non-blocking case, the ctx does not act against the connection. It
|
// Deprecated: use NewClient instead. Will be supported throughout 1.x.
|
||||||
// only controls the setup steps.
|
func Dial(target string, opts ...DialOption) (*ClientConn, error) {
|
||||||
|
return DialContext(context.Background(), target, opts...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DialContext calls NewClient and then exits idle mode. If WithBlock(true) is
|
||||||
|
// used, it calls Connect and WaitForStateChange until either the context
|
||||||
|
// expires or the state of the ClientConn is Ready.
|
||||||
//
|
//
|
||||||
// In the blocking case, ctx can be used to cancel or expire the pending
|
// One subtle difference between NewClient and Dial and DialContext is that the
|
||||||
// connection. Once this function returns, the cancellation and expiration of
|
// former uses "dns" as the default name resolver, while the latter use
|
||||||
// ctx will be noop. Users should call ClientConn.Close to terminate all the
|
// "passthrough" for backward compatibility. This distinction should not matter
|
||||||
// pending operations after this function returns.
|
// to most users, but could matter to legacy users that specify a custom dialer
|
||||||
|
// and expect it to receive the target string directly.
|
||||||
//
|
//
|
||||||
// The target name syntax is defined in
|
// Deprecated: use NewClient instead. Will be supported throughout 1.x.
|
||||||
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
|
|
||||||
// e.g. to use dns resolver, a "dns:///" prefix should be applied to the target.
|
|
||||||
func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *ClientConn, err error) {
|
func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *ClientConn, err error) {
|
||||||
cc, err := newClient(target, opts...)
|
// At the end of this method, we kick the channel out of idle, rather than
|
||||||
|
// waiting for the first rpc.
|
||||||
|
opts = append([]DialOption{withDefaultScheme("passthrough")}, opts...)
|
||||||
|
cc, err := NewClient(target, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// We start the channel off in idle mode, but kick it out of idle now,
|
// We start the channel off in idle mode, but kick it out of idle now,
|
||||||
// instead of waiting for the first RPC. Other gRPC implementations do wait
|
// instead of waiting for the first RPC. This is the legacy behavior of
|
||||||
// for the first RPC to kick the channel out of idle. But doing so would be
|
// Dial.
|
||||||
// a major behavior change for our users who are used to seeing the channel
|
|
||||||
// active after Dial.
|
|
||||||
//
|
|
||||||
// Taking this approach of kicking it out of idle at the end of this method
|
|
||||||
// allows us to share the code between channel creation and exiting idle
|
|
||||||
// mode. This will also make it easy for us to switch to starting the
|
|
||||||
// channel off in idle, i.e. by making newClient exported.
|
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
cc.Close()
|
cc.Close()
|
||||||
@ -291,17 +292,17 @@ func DialContext(ctx context.Context, target string, opts ...DialOption) (conn *
|
|||||||
// addTraceEvent is a helper method to add a trace event on the channel. If the
|
// addTraceEvent is a helper method to add a trace event on the channel. If the
|
||||||
// channel is a nested one, the same event is also added on the parent channel.
|
// channel is a nested one, the same event is also added on the parent channel.
|
||||||
func (cc *ClientConn) addTraceEvent(msg string) {
|
func (cc *ClientConn) addTraceEvent(msg string) {
|
||||||
ted := &channelz.TraceEventDesc{
|
ted := &channelz.TraceEvent{
|
||||||
Desc: fmt.Sprintf("Channel %s", msg),
|
Desc: fmt.Sprintf("Channel %s", msg),
|
||||||
Severity: channelz.CtInfo,
|
Severity: channelz.CtInfo,
|
||||||
}
|
}
|
||||||
if cc.dopts.channelzParentID != nil {
|
if cc.dopts.channelzParent != nil {
|
||||||
ted.Parent = &channelz.TraceEventDesc{
|
ted.Parent = &channelz.TraceEvent{
|
||||||
Desc: fmt.Sprintf("Nested channel(id:%d) %s", cc.channelzID.Int(), msg),
|
Desc: fmt.Sprintf("Nested channel(id:%d) %s", cc.channelz.ID, msg),
|
||||||
Severity: channelz.CtInfo,
|
Severity: channelz.CtInfo,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
channelz.AddTraceEvent(logger, cc.channelzID, 0, ted)
|
channelz.AddTraceEvent(logger, cc.channelz, 0, ted)
|
||||||
}
|
}
|
||||||
|
|
||||||
type idler ClientConn
|
type idler ClientConn
|
||||||
@ -418,14 +419,15 @@ func (cc *ClientConn) validateTransportCredentials() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// channelzRegistration registers the newly created ClientConn with channelz and
|
// channelzRegistration registers the newly created ClientConn with channelz and
|
||||||
// stores the returned identifier in `cc.channelzID` and `cc.csMgr.channelzID`.
|
// stores the returned identifier in `cc.channelz`. A channelz trace event is
|
||||||
// A channelz trace event is emitted for ClientConn creation. If the newly
|
// emitted for ClientConn creation. If the newly created ClientConn is a nested
|
||||||
// created ClientConn is a nested one, i.e a valid parent ClientConn ID is
|
// one, i.e a valid parent ClientConn ID is specified via a dial option, the
|
||||||
// specified via a dial option, the trace event is also added to the parent.
|
// trace event is also added to the parent.
|
||||||
//
|
//
|
||||||
// Doesn't grab cc.mu as this method is expected to be called only at Dial time.
|
// Doesn't grab cc.mu as this method is expected to be called only at Dial time.
|
||||||
func (cc *ClientConn) channelzRegistration(target string) {
|
func (cc *ClientConn) channelzRegistration(target string) {
|
||||||
cc.channelzID = channelz.RegisterChannel(&channelzChannel{cc}, cc.dopts.channelzParentID, target)
|
parentChannel, _ := cc.dopts.channelzParent.(*channelz.Channel)
|
||||||
|
cc.channelz = channelz.RegisterChannel(parentChannel, target)
|
||||||
cc.addTraceEvent("created")
|
cc.addTraceEvent("created")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -492,11 +494,11 @@ func getChainStreamer(interceptors []StreamClientInterceptor, curr int, finalStr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// newConnectivityStateManager creates an connectivityStateManager with
|
// newConnectivityStateManager creates an connectivityStateManager with
|
||||||
// the specified id.
|
// the specified channel.
|
||||||
func newConnectivityStateManager(ctx context.Context, id *channelz.Identifier) *connectivityStateManager {
|
func newConnectivityStateManager(ctx context.Context, channel *channelz.Channel) *connectivityStateManager {
|
||||||
return &connectivityStateManager{
|
return &connectivityStateManager{
|
||||||
channelzID: id,
|
channelz: channel,
|
||||||
pubSub: grpcsync.NewPubSub(ctx),
|
pubSub: grpcsync.NewPubSub(ctx),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,7 +512,7 @@ type connectivityStateManager struct {
|
|||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
state connectivity.State
|
state connectivity.State
|
||||||
notifyChan chan struct{}
|
notifyChan chan struct{}
|
||||||
channelzID *channelz.Identifier
|
channelz *channelz.Channel
|
||||||
pubSub *grpcsync.PubSub
|
pubSub *grpcsync.PubSub
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,9 +529,10 @@ func (csm *connectivityStateManager) updateState(state connectivity.State) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
csm.state = state
|
csm.state = state
|
||||||
|
csm.channelz.ChannelMetrics.State.Store(&state)
|
||||||
csm.pubSub.Publish(state)
|
csm.pubSub.Publish(state)
|
||||||
|
|
||||||
channelz.Infof(logger, csm.channelzID, "Channel Connectivity change to %v", state)
|
channelz.Infof(logger, csm.channelz, "Channel Connectivity change to %v", state)
|
||||||
if csm.notifyChan != nil {
|
if csm.notifyChan != nil {
|
||||||
// There are other goroutines waiting on this channel.
|
// There are other goroutines waiting on this channel.
|
||||||
close(csm.notifyChan)
|
close(csm.notifyChan)
|
||||||
@ -583,12 +586,12 @@ type ClientConn struct {
|
|||||||
cancel context.CancelFunc // Cancelled on close.
|
cancel context.CancelFunc // Cancelled on close.
|
||||||
|
|
||||||
// The following are initialized at dial time, and are read-only after that.
|
// The following are initialized at dial time, and are read-only after that.
|
||||||
target string // User's dial target.
|
target string // User's dial target.
|
||||||
parsedTarget resolver.Target // See parseTargetAndFindResolver().
|
parsedTarget resolver.Target // See parseTargetAndFindResolver().
|
||||||
authority string // See determineAuthority().
|
authority string // See determineAuthority().
|
||||||
dopts dialOptions // Default and user specified dial options.
|
dopts dialOptions // Default and user specified dial options.
|
||||||
channelzID *channelz.Identifier // Channelz identifier for the channel.
|
channelz *channelz.Channel // Channelz object.
|
||||||
resolverBuilder resolver.Builder // See parseTargetAndFindResolver().
|
resolverBuilder resolver.Builder // See parseTargetAndFindResolver().
|
||||||
idlenessMgr *idle.Manager
|
idlenessMgr *idle.Manager
|
||||||
|
|
||||||
// The following provide their own synchronization, and therefore don't
|
// The following provide their own synchronization, and therefore don't
|
||||||
@ -596,7 +599,6 @@ type ClientConn struct {
|
|||||||
csMgr *connectivityStateManager
|
csMgr *connectivityStateManager
|
||||||
pickerWrapper *pickerWrapper
|
pickerWrapper *pickerWrapper
|
||||||
safeConfigSelector iresolver.SafeConfigSelector
|
safeConfigSelector iresolver.SafeConfigSelector
|
||||||
czData *channelzData
|
|
||||||
retryThrottler atomic.Value // Updated from service config.
|
retryThrottler atomic.Value // Updated from service config.
|
||||||
|
|
||||||
// mu protects the following fields.
|
// mu protects the following fields.
|
||||||
@ -690,6 +692,7 @@ func (cc *ClientConn) waitForResolvedAddrs(ctx context.Context) error {
|
|||||||
var emptyServiceConfig *ServiceConfig
|
var emptyServiceConfig *ServiceConfig
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
balancer.Register(pickfirstBuilder{})
|
||||||
cfg := parseServiceConfig("{}")
|
cfg := parseServiceConfig("{}")
|
||||||
if cfg.Err != nil {
|
if cfg.Err != nil {
|
||||||
panic(fmt.Sprintf("impossible error parsing empty service config: %v", cfg.Err))
|
panic(fmt.Sprintf("impossible error parsing empty service config: %v", cfg.Err))
|
||||||
@ -707,15 +710,15 @@ func init() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) maybeApplyDefaultServiceConfig(addrs []resolver.Address) {
|
func (cc *ClientConn) maybeApplyDefaultServiceConfig() {
|
||||||
if cc.sc != nil {
|
if cc.sc != nil {
|
||||||
cc.applyServiceConfigAndBalancer(cc.sc, nil, addrs)
|
cc.applyServiceConfigAndBalancer(cc.sc, nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if cc.dopts.defaultServiceConfig != nil {
|
if cc.dopts.defaultServiceConfig != nil {
|
||||||
cc.applyServiceConfigAndBalancer(cc.dopts.defaultServiceConfig, &defaultConfigSelector{cc.dopts.defaultServiceConfig}, addrs)
|
cc.applyServiceConfigAndBalancer(cc.dopts.defaultServiceConfig, &defaultConfigSelector{cc.dopts.defaultServiceConfig})
|
||||||
} else {
|
} else {
|
||||||
cc.applyServiceConfigAndBalancer(emptyServiceConfig, &defaultConfigSelector{emptyServiceConfig}, addrs)
|
cc.applyServiceConfigAndBalancer(emptyServiceConfig, &defaultConfigSelector{emptyServiceConfig})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -733,7 +736,7 @@ func (cc *ClientConn) updateResolverStateAndUnlock(s resolver.State, err error)
|
|||||||
// May need to apply the initial service config in case the resolver
|
// May need to apply the initial service config in case the resolver
|
||||||
// doesn't support service configs, or doesn't provide a service config
|
// doesn't support service configs, or doesn't provide a service config
|
||||||
// with the new addresses.
|
// with the new addresses.
|
||||||
cc.maybeApplyDefaultServiceConfig(nil)
|
cc.maybeApplyDefaultServiceConfig()
|
||||||
|
|
||||||
cc.balancerWrapper.resolverError(err)
|
cc.balancerWrapper.resolverError(err)
|
||||||
|
|
||||||
@ -744,10 +747,10 @@ func (cc *ClientConn) updateResolverStateAndUnlock(s resolver.State, err error)
|
|||||||
|
|
||||||
var ret error
|
var ret error
|
||||||
if cc.dopts.disableServiceConfig {
|
if cc.dopts.disableServiceConfig {
|
||||||
channelz.Infof(logger, cc.channelzID, "ignoring service config from resolver (%v) and applying the default because service config is disabled", s.ServiceConfig)
|
channelz.Infof(logger, cc.channelz, "ignoring service config from resolver (%v) and applying the default because service config is disabled", s.ServiceConfig)
|
||||||
cc.maybeApplyDefaultServiceConfig(s.Addresses)
|
cc.maybeApplyDefaultServiceConfig()
|
||||||
} else if s.ServiceConfig == nil {
|
} else if s.ServiceConfig == nil {
|
||||||
cc.maybeApplyDefaultServiceConfig(s.Addresses)
|
cc.maybeApplyDefaultServiceConfig()
|
||||||
// TODO: do we need to apply a failing LB policy if there is no
|
// TODO: do we need to apply a failing LB policy if there is no
|
||||||
// default, per the error handling design?
|
// default, per the error handling design?
|
||||||
} else {
|
} else {
|
||||||
@ -755,12 +758,12 @@ func (cc *ClientConn) updateResolverStateAndUnlock(s resolver.State, err error)
|
|||||||
configSelector := iresolver.GetConfigSelector(s)
|
configSelector := iresolver.GetConfigSelector(s)
|
||||||
if configSelector != nil {
|
if configSelector != nil {
|
||||||
if len(s.ServiceConfig.Config.(*ServiceConfig).Methods) != 0 {
|
if len(s.ServiceConfig.Config.(*ServiceConfig).Methods) != 0 {
|
||||||
channelz.Infof(logger, cc.channelzID, "method configs in service config will be ignored due to presence of config selector")
|
channelz.Infof(logger, cc.channelz, "method configs in service config will be ignored due to presence of config selector")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
configSelector = &defaultConfigSelector{sc}
|
configSelector = &defaultConfigSelector{sc}
|
||||||
}
|
}
|
||||||
cc.applyServiceConfigAndBalancer(sc, configSelector, s.Addresses)
|
cc.applyServiceConfigAndBalancer(sc, configSelector)
|
||||||
} else {
|
} else {
|
||||||
ret = balancer.ErrBadResolverState
|
ret = balancer.ErrBadResolverState
|
||||||
if cc.sc == nil {
|
if cc.sc == nil {
|
||||||
@ -775,7 +778,7 @@ func (cc *ClientConn) updateResolverStateAndUnlock(s resolver.State, err error)
|
|||||||
|
|
||||||
var balCfg serviceconfig.LoadBalancingConfig
|
var balCfg serviceconfig.LoadBalancingConfig
|
||||||
if cc.sc != nil && cc.sc.lbConfig != nil {
|
if cc.sc != nil && cc.sc.lbConfig != nil {
|
||||||
balCfg = cc.sc.lbConfig.cfg
|
balCfg = cc.sc.lbConfig
|
||||||
}
|
}
|
||||||
bw := cc.balancerWrapper
|
bw := cc.balancerWrapper
|
||||||
cc.mu.Unlock()
|
cc.mu.Unlock()
|
||||||
@ -834,22 +837,20 @@ func (cc *ClientConn) newAddrConnLocked(addrs []resolver.Address, opts balancer.
|
|||||||
addrs: copyAddressesWithoutBalancerAttributes(addrs),
|
addrs: copyAddressesWithoutBalancerAttributes(addrs),
|
||||||
scopts: opts,
|
scopts: opts,
|
||||||
dopts: cc.dopts,
|
dopts: cc.dopts,
|
||||||
czData: new(channelzData),
|
channelz: channelz.RegisterSubChannel(cc.channelz, ""),
|
||||||
resetBackoff: make(chan struct{}),
|
resetBackoff: make(chan struct{}),
|
||||||
stateChan: make(chan struct{}),
|
stateChan: make(chan struct{}),
|
||||||
}
|
}
|
||||||
ac.ctx, ac.cancel = context.WithCancel(cc.ctx)
|
ac.ctx, ac.cancel = context.WithCancel(cc.ctx)
|
||||||
|
// Start with our address set to the first address; this may be updated if
|
||||||
|
// we connect to different addresses.
|
||||||
|
ac.channelz.ChannelMetrics.Target.Store(&addrs[0].Addr)
|
||||||
|
|
||||||
var err error
|
channelz.AddTraceEvent(logger, ac.channelz, 0, &channelz.TraceEvent{
|
||||||
ac.channelzID, err = channelz.RegisterSubChannel(ac, cc.channelzID, "")
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
channelz.AddTraceEvent(logger, ac.channelzID, 0, &channelz.TraceEventDesc{
|
|
||||||
Desc: "Subchannel created",
|
Desc: "Subchannel created",
|
||||||
Severity: channelz.CtInfo,
|
Severity: channelz.CtInfo,
|
||||||
Parent: &channelz.TraceEventDesc{
|
Parent: &channelz.TraceEvent{
|
||||||
Desc: fmt.Sprintf("Subchannel(id:%d) created", ac.channelzID.Int()),
|
Desc: fmt.Sprintf("Subchannel(id:%d) created", ac.channelz.ID),
|
||||||
Severity: channelz.CtInfo,
|
Severity: channelz.CtInfo,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -872,38 +873,27 @@ func (cc *ClientConn) removeAddrConn(ac *addrConn, err error) {
|
|||||||
ac.tearDown(err)
|
ac.tearDown(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) channelzMetric() *channelz.ChannelInternalMetric {
|
|
||||||
return &channelz.ChannelInternalMetric{
|
|
||||||
State: cc.GetState(),
|
|
||||||
Target: cc.target,
|
|
||||||
CallsStarted: atomic.LoadInt64(&cc.czData.callsStarted),
|
|
||||||
CallsSucceeded: atomic.LoadInt64(&cc.czData.callsSucceeded),
|
|
||||||
CallsFailed: atomic.LoadInt64(&cc.czData.callsFailed),
|
|
||||||
LastCallStartedTimestamp: time.Unix(0, atomic.LoadInt64(&cc.czData.lastCallStartedTime)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Target returns the target string of the ClientConn.
|
// Target returns the target string of the ClientConn.
|
||||||
//
|
|
||||||
// # Experimental
|
|
||||||
//
|
|
||||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
|
||||||
// later release.
|
|
||||||
func (cc *ClientConn) Target() string {
|
func (cc *ClientConn) Target() string {
|
||||||
return cc.target
|
return cc.target
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanonicalTarget returns the canonical target string of the ClientConn.
|
||||||
|
func (cc *ClientConn) CanonicalTarget() string {
|
||||||
|
return cc.parsedTarget.String()
|
||||||
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) incrCallsStarted() {
|
func (cc *ClientConn) incrCallsStarted() {
|
||||||
atomic.AddInt64(&cc.czData.callsStarted, 1)
|
cc.channelz.ChannelMetrics.CallsStarted.Add(1)
|
||||||
atomic.StoreInt64(&cc.czData.lastCallStartedTime, time.Now().UnixNano())
|
cc.channelz.ChannelMetrics.LastCallStartedTimestamp.Store(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) incrCallsSucceeded() {
|
func (cc *ClientConn) incrCallsSucceeded() {
|
||||||
atomic.AddInt64(&cc.czData.callsSucceeded, 1)
|
cc.channelz.ChannelMetrics.CallsSucceeded.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) incrCallsFailed() {
|
func (cc *ClientConn) incrCallsFailed() {
|
||||||
atomic.AddInt64(&cc.czData.callsFailed, 1)
|
cc.channelz.ChannelMetrics.CallsFailed.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// connect starts creating a transport.
|
// connect starts creating a transport.
|
||||||
@ -946,10 +936,14 @@ func equalAddresses(a, b []resolver.Address) bool {
|
|||||||
// updateAddrs updates ac.addrs with the new addresses list and handles active
|
// updateAddrs updates ac.addrs with the new addresses list and handles active
|
||||||
// connections or connection attempts.
|
// connections or connection attempts.
|
||||||
func (ac *addrConn) updateAddrs(addrs []resolver.Address) {
|
func (ac *addrConn) updateAddrs(addrs []resolver.Address) {
|
||||||
ac.mu.Lock()
|
|
||||||
channelz.Infof(logger, ac.channelzID, "addrConn: updateAddrs curAddr: %v, addrs: %v", pretty.ToJSON(ac.curAddr), pretty.ToJSON(addrs))
|
|
||||||
|
|
||||||
addrs = copyAddressesWithoutBalancerAttributes(addrs)
|
addrs = copyAddressesWithoutBalancerAttributes(addrs)
|
||||||
|
limit := len(addrs)
|
||||||
|
if limit > 5 {
|
||||||
|
limit = 5
|
||||||
|
}
|
||||||
|
channelz.Infof(logger, ac.channelz, "addrConn: updateAddrs addrs (%d of %d): %v", limit, len(addrs), addrs[:limit])
|
||||||
|
|
||||||
|
ac.mu.Lock()
|
||||||
if equalAddresses(ac.addrs, addrs) {
|
if equalAddresses(ac.addrs, addrs) {
|
||||||
ac.mu.Unlock()
|
ac.mu.Unlock()
|
||||||
return
|
return
|
||||||
@ -1067,7 +1061,7 @@ func (cc *ClientConn) getTransport(ctx context.Context, failfast bool, method st
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) applyServiceConfigAndBalancer(sc *ServiceConfig, configSelector iresolver.ConfigSelector, addrs []resolver.Address) {
|
func (cc *ClientConn) applyServiceConfigAndBalancer(sc *ServiceConfig, configSelector iresolver.ConfigSelector) {
|
||||||
if sc == nil {
|
if sc == nil {
|
||||||
// should never reach here.
|
// should never reach here.
|
||||||
return
|
return
|
||||||
@ -1088,17 +1082,6 @@ func (cc *ClientConn) applyServiceConfigAndBalancer(sc *ServiceConfig, configSel
|
|||||||
} else {
|
} else {
|
||||||
cc.retryThrottler.Store((*retryThrottler)(nil))
|
cc.retryThrottler.Store((*retryThrottler)(nil))
|
||||||
}
|
}
|
||||||
|
|
||||||
var newBalancerName string
|
|
||||||
if cc.sc == nil || (cc.sc.lbConfig == nil && cc.sc.LB == nil) {
|
|
||||||
// No service config or no LB policy specified in config.
|
|
||||||
newBalancerName = PickFirstBalancerName
|
|
||||||
} else if cc.sc.lbConfig != nil {
|
|
||||||
newBalancerName = cc.sc.lbConfig.name
|
|
||||||
} else { // cc.sc.LB != nil
|
|
||||||
newBalancerName = *cc.sc.LB
|
|
||||||
}
|
|
||||||
cc.balancerWrapper.switchTo(newBalancerName)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cc *ClientConn) resolveNow(o resolver.ResolveNowOptions) {
|
func (cc *ClientConn) resolveNow(o resolver.ResolveNowOptions) {
|
||||||
@ -1174,7 +1157,7 @@ func (cc *ClientConn) Close() error {
|
|||||||
// TraceEvent needs to be called before RemoveEntry, as TraceEvent may add
|
// TraceEvent needs to be called before RemoveEntry, as TraceEvent may add
|
||||||
// trace reference to the entity being deleted, and thus prevent it from being
|
// trace reference to the entity being deleted, and thus prevent it from being
|
||||||
// deleted right away.
|
// deleted right away.
|
||||||
channelz.RemoveEntry(cc.channelzID)
|
channelz.RemoveEntry(cc.channelz.ID)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -1195,6 +1178,10 @@ type addrConn struct {
|
|||||||
// is received, transport is closed, ac has been torn down).
|
// is received, transport is closed, ac has been torn down).
|
||||||
transport transport.ClientTransport // The current transport.
|
transport transport.ClientTransport // The current transport.
|
||||||
|
|
||||||
|
// This mutex is used on the RPC path, so its usage should be minimized as
|
||||||
|
// much as possible.
|
||||||
|
// TODO: Find a lock-free way to retrieve the transport and state from the
|
||||||
|
// addrConn.
|
||||||
mu sync.Mutex
|
mu sync.Mutex
|
||||||
curAddr resolver.Address // The current address.
|
curAddr resolver.Address // The current address.
|
||||||
addrs []resolver.Address // All addresses that the resolver resolved to.
|
addrs []resolver.Address // All addresses that the resolver resolved to.
|
||||||
@ -1206,8 +1193,7 @@ type addrConn struct {
|
|||||||
backoffIdx int // Needs to be stateful for resetConnectBackoff.
|
backoffIdx int // Needs to be stateful for resetConnectBackoff.
|
||||||
resetBackoff chan struct{}
|
resetBackoff chan struct{}
|
||||||
|
|
||||||
channelzID *channelz.Identifier
|
channelz *channelz.SubChannel
|
||||||
czData *channelzData
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: this requires a lock on ac.mu.
|
// Note: this requires a lock on ac.mu.
|
||||||
@ -1219,10 +1205,11 @@ func (ac *addrConn) updateConnectivityState(s connectivity.State, lastErr error)
|
|||||||
close(ac.stateChan)
|
close(ac.stateChan)
|
||||||
ac.stateChan = make(chan struct{})
|
ac.stateChan = make(chan struct{})
|
||||||
ac.state = s
|
ac.state = s
|
||||||
|
ac.channelz.ChannelMetrics.State.Store(&s)
|
||||||
if lastErr == nil {
|
if lastErr == nil {
|
||||||
channelz.Infof(logger, ac.channelzID, "Subchannel Connectivity change to %v", s)
|
channelz.Infof(logger, ac.channelz, "Subchannel Connectivity change to %v", s)
|
||||||
} else {
|
} else {
|
||||||
channelz.Infof(logger, ac.channelzID, "Subchannel Connectivity change to %v, last error: %s", s, lastErr)
|
channelz.Infof(logger, ac.channelz, "Subchannel Connectivity change to %v, last error: %s", s, lastErr)
|
||||||
}
|
}
|
||||||
ac.acbw.updateState(s, lastErr)
|
ac.acbw.updateState(s, lastErr)
|
||||||
}
|
}
|
||||||
@ -1320,6 +1307,7 @@ func (ac *addrConn) resetTransport() {
|
|||||||
func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, connectDeadline time.Time) error {
|
func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, connectDeadline time.Time) error {
|
||||||
var firstConnErr error
|
var firstConnErr error
|
||||||
for _, addr := range addrs {
|
for _, addr := range addrs {
|
||||||
|
ac.channelz.ChannelMetrics.Target.Store(&addr.Addr)
|
||||||
if ctx.Err() != nil {
|
if ctx.Err() != nil {
|
||||||
return errConnClosing
|
return errConnClosing
|
||||||
}
|
}
|
||||||
@ -1335,7 +1323,7 @@ func (ac *addrConn) tryAllAddrs(ctx context.Context, addrs []resolver.Address, c
|
|||||||
}
|
}
|
||||||
ac.mu.Unlock()
|
ac.mu.Unlock()
|
||||||
|
|
||||||
channelz.Infof(logger, ac.channelzID, "Subchannel picks a new address %q to connect", addr.Addr)
|
channelz.Infof(logger, ac.channelz, "Subchannel picks a new address %q to connect", addr.Addr)
|
||||||
|
|
||||||
err := ac.createTransport(ctx, addr, copts, connectDeadline)
|
err := ac.createTransport(ctx, addr, copts, connectDeadline)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -1388,7 +1376,7 @@ func (ac *addrConn) createTransport(ctx context.Context, addr resolver.Address,
|
|||||||
|
|
||||||
connectCtx, cancel := context.WithDeadline(ctx, connectDeadline)
|
connectCtx, cancel := context.WithDeadline(ctx, connectDeadline)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
copts.ChannelzParentID = ac.channelzID
|
copts.ChannelzParent = ac.channelz
|
||||||
|
|
||||||
newTr, err := transport.NewClientTransport(connectCtx, ac.cc.ctx, addr, copts, onClose)
|
newTr, err := transport.NewClientTransport(connectCtx, ac.cc.ctx, addr, copts, onClose)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1397,7 +1385,7 @@ func (ac *addrConn) createTransport(ctx context.Context, addr resolver.Address,
|
|||||||
}
|
}
|
||||||
// newTr is either nil, or closed.
|
// newTr is either nil, or closed.
|
||||||
hcancel()
|
hcancel()
|
||||||
channelz.Warningf(logger, ac.channelzID, "grpc: addrConn.createTransport failed to connect to %s. Err: %v", addr, err)
|
channelz.Warningf(logger, ac.channelz, "grpc: addrConn.createTransport failed to connect to %s. Err: %v", addr, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1469,7 +1457,7 @@ func (ac *addrConn) startHealthCheck(ctx context.Context) {
|
|||||||
// The health package is not imported to set health check function.
|
// The health package is not imported to set health check function.
|
||||||
//
|
//
|
||||||
// TODO: add a link to the health check doc in the error message.
|
// TODO: add a link to the health check doc in the error message.
|
||||||
channelz.Error(logger, ac.channelzID, "Health check is requested but health check function is not set.")
|
channelz.Error(logger, ac.channelz, "Health check is requested but health check function is not set.")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1499,9 +1487,9 @@ func (ac *addrConn) startHealthCheck(ctx context.Context) {
|
|||||||
err := ac.cc.dopts.healthCheckFunc(ctx, newStream, setConnectivityState, healthCheckConfig.ServiceName)
|
err := ac.cc.dopts.healthCheckFunc(ctx, newStream, setConnectivityState, healthCheckConfig.ServiceName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if status.Code(err) == codes.Unimplemented {
|
if status.Code(err) == codes.Unimplemented {
|
||||||
channelz.Error(logger, ac.channelzID, "Subchannel health check is unimplemented at server side, thus health check is disabled")
|
channelz.Error(logger, ac.channelz, "Subchannel health check is unimplemented at server side, thus health check is disabled")
|
||||||
} else {
|
} else {
|
||||||
channelz.Errorf(logger, ac.channelzID, "Health checking failed: %v", err)
|
channelz.Errorf(logger, ac.channelz, "Health checking failed: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -1566,18 +1554,18 @@ func (ac *addrConn) tearDown(err error) {
|
|||||||
ac.cancel()
|
ac.cancel()
|
||||||
ac.curAddr = resolver.Address{}
|
ac.curAddr = resolver.Address{}
|
||||||
|
|
||||||
channelz.AddTraceEvent(logger, ac.channelzID, 0, &channelz.TraceEventDesc{
|
channelz.AddTraceEvent(logger, ac.channelz, 0, &channelz.TraceEvent{
|
||||||
Desc: "Subchannel deleted",
|
Desc: "Subchannel deleted",
|
||||||
Severity: channelz.CtInfo,
|
Severity: channelz.CtInfo,
|
||||||
Parent: &channelz.TraceEventDesc{
|
Parent: &channelz.TraceEvent{
|
||||||
Desc: fmt.Sprintf("Subchannel(id:%d) deleted", ac.channelzID.Int()),
|
Desc: fmt.Sprintf("Subchannel(id:%d) deleted", ac.channelz.ID),
|
||||||
Severity: channelz.CtInfo,
|
Severity: channelz.CtInfo,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
// TraceEvent needs to be called before RemoveEntry, as TraceEvent may add
|
// TraceEvent needs to be called before RemoveEntry, as TraceEvent may add
|
||||||
// trace reference to the entity being deleted, and thus prevent it from
|
// trace reference to the entity being deleted, and thus prevent it from
|
||||||
// being deleted right away.
|
// being deleted right away.
|
||||||
channelz.RemoveEntry(ac.channelzID)
|
channelz.RemoveEntry(ac.channelz.ID)
|
||||||
ac.mu.Unlock()
|
ac.mu.Unlock()
|
||||||
|
|
||||||
// We have to release the lock before the call to GracefulClose/Close here
|
// We have to release the lock before the call to GracefulClose/Close here
|
||||||
@ -1604,39 +1592,6 @@ func (ac *addrConn) tearDown(err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ac *addrConn) getState() connectivity.State {
|
|
||||||
ac.mu.Lock()
|
|
||||||
defer ac.mu.Unlock()
|
|
||||||
return ac.state
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ac *addrConn) ChannelzMetric() *channelz.ChannelInternalMetric {
|
|
||||||
ac.mu.Lock()
|
|
||||||
addr := ac.curAddr.Addr
|
|
||||||
ac.mu.Unlock()
|
|
||||||
return &channelz.ChannelInternalMetric{
|
|
||||||
State: ac.getState(),
|
|
||||||
Target: addr,
|
|
||||||
CallsStarted: atomic.LoadInt64(&ac.czData.callsStarted),
|
|
||||||
CallsSucceeded: atomic.LoadInt64(&ac.czData.callsSucceeded),
|
|
||||||
CallsFailed: atomic.LoadInt64(&ac.czData.callsFailed),
|
|
||||||
LastCallStartedTimestamp: time.Unix(0, atomic.LoadInt64(&ac.czData.lastCallStartedTime)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ac *addrConn) incrCallsStarted() {
|
|
||||||
atomic.AddInt64(&ac.czData.callsStarted, 1)
|
|
||||||
atomic.StoreInt64(&ac.czData.lastCallStartedTime, time.Now().UnixNano())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ac *addrConn) incrCallsSucceeded() {
|
|
||||||
atomic.AddInt64(&ac.czData.callsSucceeded, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ac *addrConn) incrCallsFailed() {
|
|
||||||
atomic.AddInt64(&ac.czData.callsFailed, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
type retryThrottler struct {
|
type retryThrottler struct {
|
||||||
max float64
|
max float64
|
||||||
thresh float64
|
thresh float64
|
||||||
@ -1674,12 +1629,17 @@ func (rt *retryThrottler) successfulRPC() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type channelzChannel struct {
|
func (ac *addrConn) incrCallsStarted() {
|
||||||
cc *ClientConn
|
ac.channelz.ChannelMetrics.CallsStarted.Add(1)
|
||||||
|
ac.channelz.ChannelMetrics.LastCallStartedTimestamp.Store(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *channelzChannel) ChannelzMetric() *channelz.ChannelInternalMetric {
|
func (ac *addrConn) incrCallsSucceeded() {
|
||||||
return c.cc.channelzMetric()
|
ac.channelz.ChannelMetrics.CallsSucceeded.Add(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ac *addrConn) incrCallsFailed() {
|
||||||
|
ac.channelz.ChannelMetrics.CallsFailed.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrClientConnTimeout indicates that the ClientConn cannot establish the
|
// ErrClientConnTimeout indicates that the ClientConn cannot establish the
|
||||||
@ -1721,14 +1681,14 @@ func (cc *ClientConn) connectionError() error {
|
|||||||
//
|
//
|
||||||
// Doesn't grab cc.mu as this method is expected to be called only at Dial time.
|
// Doesn't grab cc.mu as this method is expected to be called only at Dial time.
|
||||||
func (cc *ClientConn) parseTargetAndFindResolver() error {
|
func (cc *ClientConn) parseTargetAndFindResolver() error {
|
||||||
channelz.Infof(logger, cc.channelzID, "original dial target is: %q", cc.target)
|
channelz.Infof(logger, cc.channelz, "original dial target is: %q", cc.target)
|
||||||
|
|
||||||
var rb resolver.Builder
|
var rb resolver.Builder
|
||||||
parsedTarget, err := parseTarget(cc.target)
|
parsedTarget, err := parseTarget(cc.target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
channelz.Infof(logger, cc.channelzID, "dial target %q parse failed: %v", cc.target, err)
|
channelz.Infof(logger, cc.channelz, "dial target %q parse failed: %v", cc.target, err)
|
||||||
} else {
|
} else {
|
||||||
channelz.Infof(logger, cc.channelzID, "parsed dial target is: %#v", parsedTarget)
|
channelz.Infof(logger, cc.channelz, "parsed dial target is: %#v", parsedTarget)
|
||||||
rb = cc.getResolver(parsedTarget.URL.Scheme)
|
rb = cc.getResolver(parsedTarget.URL.Scheme)
|
||||||
if rb != nil {
|
if rb != nil {
|
||||||
cc.parsedTarget = parsedTarget
|
cc.parsedTarget = parsedTarget
|
||||||
@ -1740,17 +1700,22 @@ func (cc *ClientConn) parseTargetAndFindResolver() error {
|
|||||||
// We are here because the user's dial target did not contain a scheme or
|
// We are here because the user's dial target did not contain a scheme or
|
||||||
// specified an unregistered scheme. We should fallback to the default
|
// specified an unregistered scheme. We should fallback to the default
|
||||||
// scheme, except when a custom dialer is specified in which case, we should
|
// scheme, except when a custom dialer is specified in which case, we should
|
||||||
// always use passthrough scheme.
|
// always use passthrough scheme. For either case, we need to respect any overridden
|
||||||
defScheme := resolver.GetDefaultScheme()
|
// global defaults set by the user.
|
||||||
channelz.Infof(logger, cc.channelzID, "fallback to scheme %q", defScheme)
|
defScheme := cc.dopts.defaultScheme
|
||||||
|
if internal.UserSetDefaultScheme {
|
||||||
|
defScheme = resolver.GetDefaultScheme()
|
||||||
|
}
|
||||||
|
|
||||||
|
channelz.Infof(logger, cc.channelz, "fallback to scheme %q", defScheme)
|
||||||
canonicalTarget := defScheme + ":///" + cc.target
|
canonicalTarget := defScheme + ":///" + cc.target
|
||||||
|
|
||||||
parsedTarget, err = parseTarget(canonicalTarget)
|
parsedTarget, err = parseTarget(canonicalTarget)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
channelz.Infof(logger, cc.channelzID, "dial target %q parse failed: %v", canonicalTarget, err)
|
channelz.Infof(logger, cc.channelz, "dial target %q parse failed: %v", canonicalTarget, err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
channelz.Infof(logger, cc.channelzID, "parsed dial target is: %+v", parsedTarget)
|
channelz.Infof(logger, cc.channelz, "parsed dial target is: %+v", parsedTarget)
|
||||||
rb = cc.getResolver(parsedTarget.URL.Scheme)
|
rb = cc.getResolver(parsedTarget.URL.Scheme)
|
||||||
if rb == nil {
|
if rb == nil {
|
||||||
return fmt.Errorf("could not get resolver for default scheme: %q", parsedTarget.URL.Scheme)
|
return fmt.Errorf("could not get resolver for default scheme: %q", parsedTarget.URL.Scheme)
|
||||||
@ -1790,7 +1755,7 @@ func encodeAuthority(authority string) string {
|
|||||||
return false
|
return false
|
||||||
case '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=': // Subdelim characters
|
case '!', '$', '&', '\'', '(', ')', '*', '+', ',', ';', '=': // Subdelim characters
|
||||||
return false
|
return false
|
||||||
case ':', '[', ']', '@': // Authority related delimeters
|
case ':', '[', ']', '@': // Authority related delimiters
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
// Everything else must be escaped.
|
// Everything else must be escaped.
|
||||||
@ -1873,6 +1838,6 @@ func (cc *ClientConn) determineAuthority() error {
|
|||||||
} else {
|
} else {
|
||||||
cc.authority = encodeAuthority(endpoint)
|
cc.authority = encodeAuthority(endpoint)
|
||||||
}
|
}
|
||||||
channelz.Infof(logger, cc.channelzID, "Channel authority set to %q", cc.authority)
|
channelz.Infof(logger, cc.channelz, "Channel authority set to %q", cc.authority)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
17
vendor/google.golang.org/grpc/codegen.sh
generated
vendored
17
vendor/google.golang.org/grpc/codegen.sh
generated
vendored
@ -1,17 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# This script serves as an example to demonstrate how to generate the gRPC-Go
|
|
||||||
# interface and the related messages from .proto file.
|
|
||||||
#
|
|
||||||
# It assumes the installation of i) Google proto buffer compiler at
|
|
||||||
# https://github.com/google/protobuf (after v2.6.1) and ii) the Go codegen
|
|
||||||
# plugin at https://github.com/golang/protobuf (after 2015-02-20). If you have
|
|
||||||
# not, please install them first.
|
|
||||||
#
|
|
||||||
# We recommend running this script at $GOPATH/src.
|
|
||||||
#
|
|
||||||
# If this is not what you need, feel free to make your own scripts. Again, this
|
|
||||||
# script is for demonstration purpose.
|
|
||||||
#
|
|
||||||
proto=$1
|
|
||||||
protoc --go_out=plugins=grpc:. $proto
|
|
2
vendor/google.golang.org/grpc/codes/codes.go
generated
vendored
2
vendor/google.golang.org/grpc/codes/codes.go
generated
vendored
@ -235,7 +235,7 @@ func (c *Code) UnmarshalJSON(b []byte) error {
|
|||||||
|
|
||||||
if ci, err := strconv.ParseUint(string(b), 10, 32); err == nil {
|
if ci, err := strconv.ParseUint(string(b), 10, 32); err == nil {
|
||||||
if ci >= _maxCode {
|
if ci >= _maxCode {
|
||||||
return fmt.Errorf("invalid code: %q", ci)
|
return fmt.Errorf("invalid code: %d", ci)
|
||||||
}
|
}
|
||||||
|
|
||||||
*c = Code(ci)
|
*c = Code(ci)
|
||||||
|
4
vendor/google.golang.org/grpc/credentials/credentials.go
generated
vendored
4
vendor/google.golang.org/grpc/credentials/credentials.go
generated
vendored
@ -28,9 +28,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/grpc/attributes"
|
"google.golang.org/grpc/attributes"
|
||||||
icredentials "google.golang.org/grpc/internal/credentials"
|
icredentials "google.golang.org/grpc/internal/credentials"
|
||||||
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
// PerRPCCredentials defines the common interface for the credentials which need to
|
// PerRPCCredentials defines the common interface for the credentials which need to
|
||||||
@ -237,7 +237,7 @@ func ClientHandshakeInfoFromContext(ctx context.Context) ClientHandshakeInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CheckSecurityLevel checks if a connection's security level is greater than or equal to the specified one.
|
// CheckSecurityLevel checks if a connection's security level is greater than or equal to the specified one.
|
||||||
// It returns success if 1) the condition is satisified or 2) AuthInfo struct does not implement GetCommonAuthInfo() method
|
// It returns success if 1) the condition is satisfied or 2) AuthInfo struct does not implement GetCommonAuthInfo() method
|
||||||
// or 3) CommonAuthInfo.SecurityLevel has an invalid zero value. For 2) and 3), it is for the purpose of backward-compatibility.
|
// or 3) CommonAuthInfo.SecurityLevel has an invalid zero value. For 2) and 3), it is for the purpose of backward-compatibility.
|
||||||
//
|
//
|
||||||
// This API is experimental.
|
// This API is experimental.
|
||||||
|
56
vendor/google.golang.org/grpc/dialoptions.go
generated
vendored
56
vendor/google.golang.org/grpc/dialoptions.go
generated
vendored
@ -68,7 +68,7 @@ type dialOptions struct {
|
|||||||
binaryLogger binarylog.Logger
|
binaryLogger binarylog.Logger
|
||||||
copts transport.ConnectOptions
|
copts transport.ConnectOptions
|
||||||
callOptions []CallOption
|
callOptions []CallOption
|
||||||
channelzParentID *channelz.Identifier
|
channelzParent channelz.Identifier
|
||||||
disableServiceConfig bool
|
disableServiceConfig bool
|
||||||
disableRetry bool
|
disableRetry bool
|
||||||
disableHealthCheck bool
|
disableHealthCheck bool
|
||||||
@ -79,6 +79,7 @@ type dialOptions struct {
|
|||||||
resolvers []resolver.Builder
|
resolvers []resolver.Builder
|
||||||
idleTimeout time.Duration
|
idleTimeout time.Duration
|
||||||
recvBufferPool SharedBufferPool
|
recvBufferPool SharedBufferPool
|
||||||
|
defaultScheme string
|
||||||
}
|
}
|
||||||
|
|
||||||
// DialOption configures how we set up the connection.
|
// DialOption configures how we set up the connection.
|
||||||
@ -154,9 +155,7 @@ func WithSharedWriteBuffer(val bool) DialOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WithWriteBufferSize determines how much data can be batched before doing a
|
// WithWriteBufferSize determines how much data can be batched before doing a
|
||||||
// write on the wire. The corresponding memory allocation for this buffer will
|
// write on the wire. The default value for this buffer is 32KB.
|
||||||
// be twice the size to keep syscalls low. The default value for this buffer is
|
|
||||||
// 32KB.
|
|
||||||
//
|
//
|
||||||
// Zero or negative values will disable the write buffer such that each write
|
// Zero or negative values will disable the write buffer such that each write
|
||||||
// will be on underlying connection. Note: A Send call may not directly
|
// will be on underlying connection. Note: A Send call may not directly
|
||||||
@ -301,6 +300,9 @@ func withBackoff(bs internalbackoff.Strategy) DialOption {
|
|||||||
//
|
//
|
||||||
// Use of this feature is not recommended. For more information, please see:
|
// Use of this feature is not recommended. For more information, please see:
|
||||||
// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md
|
// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md
|
||||||
|
//
|
||||||
|
// Deprecated: this DialOption is not supported by NewClient.
|
||||||
|
// Will be supported throughout 1.x.
|
||||||
func WithBlock() DialOption {
|
func WithBlock() DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
o.block = true
|
o.block = true
|
||||||
@ -315,10 +317,8 @@ func WithBlock() DialOption {
|
|||||||
// Use of this feature is not recommended. For more information, please see:
|
// Use of this feature is not recommended. For more information, please see:
|
||||||
// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md
|
// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md
|
||||||
//
|
//
|
||||||
// # Experimental
|
// Deprecated: this DialOption is not supported by NewClient.
|
||||||
//
|
// Will be supported throughout 1.x.
|
||||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
|
||||||
// later release.
|
|
||||||
func WithReturnConnectionError() DialOption {
|
func WithReturnConnectionError() DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
o.block = true
|
o.block = true
|
||||||
@ -388,8 +388,8 @@ func WithCredentialsBundle(b credentials.Bundle) DialOption {
|
|||||||
// WithTimeout returns a DialOption that configures a timeout for dialing a
|
// WithTimeout returns a DialOption that configures a timeout for dialing a
|
||||||
// ClientConn initially. This is valid if and only if WithBlock() is present.
|
// ClientConn initially. This is valid if and only if WithBlock() is present.
|
||||||
//
|
//
|
||||||
// Deprecated: use DialContext instead of Dial and context.WithTimeout
|
// Deprecated: this DialOption is not supported by NewClient.
|
||||||
// instead. Will be supported throughout 1.x.
|
// Will be supported throughout 1.x.
|
||||||
func WithTimeout(d time.Duration) DialOption {
|
func WithTimeout(d time.Duration) DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
o.timeout = d
|
o.timeout = d
|
||||||
@ -471,9 +471,8 @@ func withBinaryLogger(bl binarylog.Logger) DialOption {
|
|||||||
// Use of this feature is not recommended. For more information, please see:
|
// Use of this feature is not recommended. For more information, please see:
|
||||||
// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md
|
// https://github.com/grpc/grpc-go/blob/master/Documentation/anti-patterns.md
|
||||||
//
|
//
|
||||||
// # Experimental
|
// Deprecated: this DialOption is not supported by NewClient.
|
||||||
//
|
// This API may be changed or removed in a
|
||||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
|
||||||
// later release.
|
// later release.
|
||||||
func FailOnNonTempDialError(f bool) DialOption {
|
func FailOnNonTempDialError(f bool) DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
@ -555,9 +554,9 @@ func WithAuthority(a string) DialOption {
|
|||||||
//
|
//
|
||||||
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
// Notice: This API is EXPERIMENTAL and may be changed or removed in a
|
||||||
// later release.
|
// later release.
|
||||||
func WithChannelzParentID(id *channelz.Identifier) DialOption {
|
func WithChannelzParentID(c channelz.Identifier) DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
o.channelzParentID = id
|
o.channelzParent = c
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -602,12 +601,22 @@ func WithDisableRetry() DialOption {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MaxHeaderListSizeDialOption is a DialOption that specifies the maximum
|
||||||
|
// (uncompressed) size of header list that the client is prepared to accept.
|
||||||
|
type MaxHeaderListSizeDialOption struct {
|
||||||
|
MaxHeaderListSize uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o MaxHeaderListSizeDialOption) apply(do *dialOptions) {
|
||||||
|
do.copts.MaxHeaderListSize = &o.MaxHeaderListSize
|
||||||
|
}
|
||||||
|
|
||||||
// WithMaxHeaderListSize returns a DialOption that specifies the maximum
|
// WithMaxHeaderListSize returns a DialOption that specifies the maximum
|
||||||
// (uncompressed) size of header list that the client is prepared to accept.
|
// (uncompressed) size of header list that the client is prepared to accept.
|
||||||
func WithMaxHeaderListSize(s uint32) DialOption {
|
func WithMaxHeaderListSize(s uint32) DialOption {
|
||||||
return newFuncDialOption(func(o *dialOptions) {
|
return MaxHeaderListSizeDialOption{
|
||||||
o.copts.MaxHeaderListSize = &s
|
MaxHeaderListSize: s,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithDisableHealthCheck disables the LB channel health checking for all
|
// WithDisableHealthCheck disables the LB channel health checking for all
|
||||||
@ -645,10 +654,11 @@ func defaultDialOptions() dialOptions {
|
|||||||
healthCheckFunc: internal.HealthCheckFunc,
|
healthCheckFunc: internal.HealthCheckFunc,
|
||||||
idleTimeout: 30 * time.Minute,
|
idleTimeout: 30 * time.Minute,
|
||||||
recvBufferPool: nopBufferPool{},
|
recvBufferPool: nopBufferPool{},
|
||||||
|
defaultScheme: "dns",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// withGetMinConnectDeadline specifies the function that clientconn uses to
|
// withMinConnectDeadline specifies the function that clientconn uses to
|
||||||
// get minConnectDeadline. This can be used to make connection attempts happen
|
// get minConnectDeadline. This can be used to make connection attempts happen
|
||||||
// faster/slower.
|
// faster/slower.
|
||||||
//
|
//
|
||||||
@ -659,6 +669,14 @@ func withMinConnectDeadline(f func() time.Duration) DialOption {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// withDefaultScheme is used to allow Dial to use "passthrough" as the default
|
||||||
|
// name resolver, while NewClient uses "dns" otherwise.
|
||||||
|
func withDefaultScheme(s string) DialOption {
|
||||||
|
return newFuncDialOption(func(o *dialOptions) {
|
||||||
|
o.defaultScheme = s
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// WithResolvers allows a list of resolver implementations to be registered
|
// WithResolvers allows a list of resolver implementations to be registered
|
||||||
// locally with the ClientConn without needing to be globally registered via
|
// locally with the ClientConn without needing to be globally registered via
|
||||||
// resolver.Register. They will be matched against the scheme used for the
|
// resolver.Register. They will be matched against the scheme used for the
|
||||||
|
82
vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go
generated
vendored
Normal file
82
vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/config.go
generated
vendored
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package gracefulswitch
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/balancer"
|
||||||
|
"google.golang.org/grpc/serviceconfig"
|
||||||
|
)
|
||||||
|
|
||||||
|
type lbConfig struct {
|
||||||
|
serviceconfig.LoadBalancingConfig
|
||||||
|
|
||||||
|
childBuilder balancer.Builder
|
||||||
|
childConfig serviceconfig.LoadBalancingConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
func ChildName(l serviceconfig.LoadBalancingConfig) string {
|
||||||
|
return l.(*lbConfig).childBuilder.Name()
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseConfig parses a child config list and returns a LB config for the
|
||||||
|
// gracefulswitch Balancer.
|
||||||
|
//
|
||||||
|
// cfg is expected to be a json.RawMessage containing a JSON array of LB policy
|
||||||
|
// names + configs as the format of the "loadBalancingConfig" field in
|
||||||
|
// ServiceConfig. It returns a type that should be passed to
|
||||||
|
// UpdateClientConnState in the BalancerConfig field.
|
||||||
|
func ParseConfig(cfg json.RawMessage) (serviceconfig.LoadBalancingConfig, error) {
|
||||||
|
var lbCfg []map[string]json.RawMessage
|
||||||
|
if err := json.Unmarshal(cfg, &lbCfg); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
for i, e := range lbCfg {
|
||||||
|
if len(e) != 1 {
|
||||||
|
return nil, fmt.Errorf("expected a JSON struct with one entry; received entry %v at index %d", e, i)
|
||||||
|
}
|
||||||
|
|
||||||
|
var name string
|
||||||
|
var jsonCfg json.RawMessage
|
||||||
|
for name, jsonCfg = range e {
|
||||||
|
}
|
||||||
|
|
||||||
|
builder := balancer.Get(name)
|
||||||
|
if builder == nil {
|
||||||
|
// Skip unregistered balancer names.
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
parser, ok := builder.(balancer.ConfigParser)
|
||||||
|
if !ok {
|
||||||
|
// This is a valid child with no config.
|
||||||
|
return &lbConfig{childBuilder: builder}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg, err := parser.ParseConfig(jsonCfg)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("error parsing config for policy %q: %v", name, err)
|
||||||
|
}
|
||||||
|
return &lbConfig{childBuilder: builder, childConfig: cfg}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, fmt.Errorf("no supported policies found in config: %v", string(cfg))
|
||||||
|
}
|
44
vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go
generated
vendored
44
vendor/google.golang.org/grpc/internal/balancer/gracefulswitch/gracefulswitch.go
generated
vendored
@ -94,14 +94,23 @@ func (gsb *Balancer) balancerCurrentOrPending(bw *balancerWrapper) bool {
|
|||||||
// process is not complete when this method returns. This method must be called
|
// process is not complete when this method returns. This method must be called
|
||||||
// synchronously alongside the rest of the balancer.Balancer methods this
|
// synchronously alongside the rest of the balancer.Balancer methods this
|
||||||
// Graceful Switch Balancer implements.
|
// Graceful Switch Balancer implements.
|
||||||
|
//
|
||||||
|
// Deprecated: use ParseConfig and pass a parsed config to UpdateClientConnState
|
||||||
|
// to cause the Balancer to automatically change to the new child when necessary.
|
||||||
func (gsb *Balancer) SwitchTo(builder balancer.Builder) error {
|
func (gsb *Balancer) SwitchTo(builder balancer.Builder) error {
|
||||||
|
_, err := gsb.switchTo(builder)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (gsb *Balancer) switchTo(builder balancer.Builder) (*balancerWrapper, error) {
|
||||||
gsb.mu.Lock()
|
gsb.mu.Lock()
|
||||||
if gsb.closed {
|
if gsb.closed {
|
||||||
gsb.mu.Unlock()
|
gsb.mu.Unlock()
|
||||||
return errBalancerClosed
|
return nil, errBalancerClosed
|
||||||
}
|
}
|
||||||
bw := &balancerWrapper{
|
bw := &balancerWrapper{
|
||||||
gsb: gsb,
|
builder: builder,
|
||||||
|
gsb: gsb,
|
||||||
lastState: balancer.State{
|
lastState: balancer.State{
|
||||||
ConnectivityState: connectivity.Connecting,
|
ConnectivityState: connectivity.Connecting,
|
||||||
Picker: base.NewErrPicker(balancer.ErrNoSubConnAvailable),
|
Picker: base.NewErrPicker(balancer.ErrNoSubConnAvailable),
|
||||||
@ -129,7 +138,7 @@ func (gsb *Balancer) SwitchTo(builder balancer.Builder) error {
|
|||||||
gsb.balancerCurrent = nil
|
gsb.balancerCurrent = nil
|
||||||
}
|
}
|
||||||
gsb.mu.Unlock()
|
gsb.mu.Unlock()
|
||||||
return balancer.ErrBadResolverState
|
return nil, balancer.ErrBadResolverState
|
||||||
}
|
}
|
||||||
|
|
||||||
// This write doesn't need to take gsb.mu because this field never gets read
|
// This write doesn't need to take gsb.mu because this field never gets read
|
||||||
@ -138,7 +147,7 @@ func (gsb *Balancer) SwitchTo(builder balancer.Builder) error {
|
|||||||
// bw.Balancer field will never be forwarded to until this SwitchTo()
|
// bw.Balancer field will never be forwarded to until this SwitchTo()
|
||||||
// function returns.
|
// function returns.
|
||||||
bw.Balancer = newBalancer
|
bw.Balancer = newBalancer
|
||||||
return nil
|
return bw, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns nil if the graceful switch balancer is closed.
|
// Returns nil if the graceful switch balancer is closed.
|
||||||
@ -152,12 +161,32 @@ func (gsb *Balancer) latestBalancer() *balancerWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateClientConnState forwards the update to the latest balancer created.
|
// UpdateClientConnState forwards the update to the latest balancer created.
|
||||||
|
//
|
||||||
|
// If the state's BalancerConfig is the config returned by a call to
|
||||||
|
// gracefulswitch.ParseConfig, then this function will automatically SwitchTo
|
||||||
|
// the balancer indicated by the config before forwarding its config to it, if
|
||||||
|
// necessary.
|
||||||
func (gsb *Balancer) UpdateClientConnState(state balancer.ClientConnState) error {
|
func (gsb *Balancer) UpdateClientConnState(state balancer.ClientConnState) error {
|
||||||
// The resolver data is only relevant to the most recent LB Policy.
|
// The resolver data is only relevant to the most recent LB Policy.
|
||||||
balToUpdate := gsb.latestBalancer()
|
balToUpdate := gsb.latestBalancer()
|
||||||
|
gsbCfg, ok := state.BalancerConfig.(*lbConfig)
|
||||||
|
if ok {
|
||||||
|
// Switch to the child in the config unless it is already active.
|
||||||
|
if balToUpdate == nil || gsbCfg.childBuilder.Name() != balToUpdate.builder.Name() {
|
||||||
|
var err error
|
||||||
|
balToUpdate, err = gsb.switchTo(gsbCfg.childBuilder)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("could not switch to new child balancer: %w", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Unwrap the child balancer's config.
|
||||||
|
state.BalancerConfig = gsbCfg.childConfig
|
||||||
|
}
|
||||||
|
|
||||||
if balToUpdate == nil {
|
if balToUpdate == nil {
|
||||||
return errBalancerClosed
|
return errBalancerClosed
|
||||||
}
|
}
|
||||||
|
|
||||||
// Perform this call without gsb.mu to prevent deadlocks if the child calls
|
// Perform this call without gsb.mu to prevent deadlocks if the child calls
|
||||||
// back into the channel. The latest balancer can never be closed during a
|
// back into the channel. The latest balancer can never be closed during a
|
||||||
// call from the channel, even without gsb.mu held.
|
// call from the channel, even without gsb.mu held.
|
||||||
@ -169,6 +198,10 @@ func (gsb *Balancer) ResolverError(err error) {
|
|||||||
// The resolver data is only relevant to the most recent LB Policy.
|
// The resolver data is only relevant to the most recent LB Policy.
|
||||||
balToUpdate := gsb.latestBalancer()
|
balToUpdate := gsb.latestBalancer()
|
||||||
if balToUpdate == nil {
|
if balToUpdate == nil {
|
||||||
|
gsb.cc.UpdateState(balancer.State{
|
||||||
|
ConnectivityState: connectivity.TransientFailure,
|
||||||
|
Picker: base.NewErrPicker(err),
|
||||||
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Perform this call without gsb.mu to prevent deadlocks if the child calls
|
// Perform this call without gsb.mu to prevent deadlocks if the child calls
|
||||||
@ -261,7 +294,8 @@ func (gsb *Balancer) Close() {
|
|||||||
// graceful switch logic.
|
// graceful switch logic.
|
||||||
type balancerWrapper struct {
|
type balancerWrapper struct {
|
||||||
balancer.Balancer
|
balancer.Balancer
|
||||||
gsb *Balancer
|
gsb *Balancer
|
||||||
|
builder balancer.Builder
|
||||||
|
|
||||||
lastState balancer.State
|
lastState balancer.State
|
||||||
subconns map[balancer.SubConn]bool // subconns created by this balancer
|
subconns map[balancer.SubConn]bool // subconns created by this balancer
|
||||||
|
6
vendor/google.golang.org/grpc/internal/binarylog/method_logger.go
generated
vendored
6
vendor/google.golang.org/grpc/internal/binarylog/method_logger.go
generated
vendored
@ -65,7 +65,7 @@ type TruncatingMethodLogger struct {
|
|||||||
callID uint64
|
callID uint64
|
||||||
idWithinCallGen *callIDGenerator
|
idWithinCallGen *callIDGenerator
|
||||||
|
|
||||||
sink Sink // TODO(blog): make this plugable.
|
sink Sink // TODO(blog): make this pluggable.
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTruncatingMethodLogger returns a new truncating method logger.
|
// NewTruncatingMethodLogger returns a new truncating method logger.
|
||||||
@ -80,7 +80,7 @@ func NewTruncatingMethodLogger(h, m uint64) *TruncatingMethodLogger {
|
|||||||
callID: idGen.next(),
|
callID: idGen.next(),
|
||||||
idWithinCallGen: &callIDGenerator{},
|
idWithinCallGen: &callIDGenerator{},
|
||||||
|
|
||||||
sink: DefaultSink, // TODO(blog): make it plugable.
|
sink: DefaultSink, // TODO(blog): make it pluggable.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ func metadataKeyOmit(key string) bool {
|
|||||||
switch key {
|
switch key {
|
||||||
case "lb-token", ":path", ":authority", "content-encoding", "content-type", "user-agent", "te":
|
case "lb-token", ":path", ":authority", "content-encoding", "content-type", "user-agent", "te":
|
||||||
return true
|
return true
|
||||||
case "grpc-trace-bin": // grpc-trace-bin is special because it's visiable to users.
|
case "grpc-trace-bin": // grpc-trace-bin is special because it's visible to users.
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return strings.HasPrefix(key, "grpc-")
|
return strings.HasPrefix(key, "grpc-")
|
||||||
|
255
vendor/google.golang.org/grpc/internal/channelz/channel.go
generated
vendored
Normal file
255
vendor/google.golang.org/grpc/internal/channelz/channel.go
generated
vendored
Normal file
@ -0,0 +1,255 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package channelz
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/connectivity"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Channel represents a channel within channelz, which includes metrics and
|
||||||
|
// internal channelz data, such as channelz id, child list, etc.
|
||||||
|
type Channel struct {
|
||||||
|
Entity
|
||||||
|
// ID is the channelz id of this channel.
|
||||||
|
ID int64
|
||||||
|
// RefName is the human readable reference string of this channel.
|
||||||
|
RefName string
|
||||||
|
|
||||||
|
closeCalled bool
|
||||||
|
nestedChans map[int64]string
|
||||||
|
subChans map[int64]string
|
||||||
|
Parent *Channel
|
||||||
|
trace *ChannelTrace
|
||||||
|
// traceRefCount is the number of trace events that reference this channel.
|
||||||
|
// Non-zero traceRefCount means the trace of this channel cannot be deleted.
|
||||||
|
traceRefCount int32
|
||||||
|
|
||||||
|
ChannelMetrics ChannelMetrics
|
||||||
|
}
|
||||||
|
|
||||||
|
// Implemented to make Channel implement the Identifier interface used for
|
||||||
|
// nesting.
|
||||||
|
func (c *Channel) channelzIdentifier() {}
|
||||||
|
|
||||||
|
func (c *Channel) String() string {
|
||||||
|
if c.Parent == nil {
|
||||||
|
return fmt.Sprintf("Channel #%d", c.ID)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%s Channel #%d", c.Parent, c.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) id() int64 {
|
||||||
|
return c.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) SubChans() map[int64]string {
|
||||||
|
db.mu.RLock()
|
||||||
|
defer db.mu.RUnlock()
|
||||||
|
return copyMap(c.subChans)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) NestedChans() map[int64]string {
|
||||||
|
db.mu.RLock()
|
||||||
|
defer db.mu.RUnlock()
|
||||||
|
return copyMap(c.nestedChans)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) Trace() *ChannelTrace {
|
||||||
|
db.mu.RLock()
|
||||||
|
defer db.mu.RUnlock()
|
||||||
|
return c.trace.copy()
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChannelMetrics struct {
|
||||||
|
// The current connectivity state of the channel.
|
||||||
|
State atomic.Pointer[connectivity.State]
|
||||||
|
// The target this channel originally tried to connect to. May be absent
|
||||||
|
Target atomic.Pointer[string]
|
||||||
|
// The number of calls started on the channel.
|
||||||
|
CallsStarted atomic.Int64
|
||||||
|
// The number of calls that have completed with an OK status.
|
||||||
|
CallsSucceeded atomic.Int64
|
||||||
|
// The number of calls that have a completed with a non-OK status.
|
||||||
|
CallsFailed atomic.Int64
|
||||||
|
// The last time a call was started on the channel.
|
||||||
|
LastCallStartedTimestamp atomic.Int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// CopyFrom copies the metrics in o to c. For testing only.
|
||||||
|
func (c *ChannelMetrics) CopyFrom(o *ChannelMetrics) {
|
||||||
|
c.State.Store(o.State.Load())
|
||||||
|
c.Target.Store(o.Target.Load())
|
||||||
|
c.CallsStarted.Store(o.CallsStarted.Load())
|
||||||
|
c.CallsSucceeded.Store(o.CallsSucceeded.Load())
|
||||||
|
c.CallsFailed.Store(o.CallsFailed.Load())
|
||||||
|
c.LastCallStartedTimestamp.Store(o.LastCallStartedTimestamp.Load())
|
||||||
|
}
|
||||||
|
|
||||||
|
// Equal returns true iff the metrics of c are the same as the metrics of o.
|
||||||
|
// For testing only.
|
||||||
|
func (c *ChannelMetrics) Equal(o any) bool {
|
||||||
|
oc, ok := o.(*ChannelMetrics)
|
||||||
|
if !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (c.State.Load() == nil) != (oc.State.Load() == nil) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if c.State.Load() != nil && *c.State.Load() != *oc.State.Load() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (c.Target.Load() == nil) != (oc.Target.Load() == nil) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if c.Target.Load() != nil && *c.Target.Load() != *oc.Target.Load() {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return c.CallsStarted.Load() == oc.CallsStarted.Load() &&
|
||||||
|
c.CallsFailed.Load() == oc.CallsFailed.Load() &&
|
||||||
|
c.CallsSucceeded.Load() == oc.CallsSucceeded.Load() &&
|
||||||
|
c.LastCallStartedTimestamp.Load() == oc.LastCallStartedTimestamp.Load()
|
||||||
|
}
|
||||||
|
|
||||||
|
func strFromPointer(s *string) string {
|
||||||
|
if s == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
return *s
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ChannelMetrics) String() string {
|
||||||
|
return fmt.Sprintf("State: %v, Target: %s, CallsStarted: %v, CallsSucceeded: %v, CallsFailed: %v, LastCallStartedTimestamp: %v",
|
||||||
|
c.State.Load(), strFromPointer(c.Target.Load()), c.CallsStarted.Load(), c.CallsSucceeded.Load(), c.CallsFailed.Load(), c.LastCallStartedTimestamp.Load(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewChannelMetricForTesting(state connectivity.State, target string, started, succeeded, failed, timestamp int64) *ChannelMetrics {
|
||||||
|
c := &ChannelMetrics{}
|
||||||
|
c.State.Store(&state)
|
||||||
|
c.Target.Store(&target)
|
||||||
|
c.CallsStarted.Store(started)
|
||||||
|
c.CallsSucceeded.Store(succeeded)
|
||||||
|
c.CallsFailed.Store(failed)
|
||||||
|
c.LastCallStartedTimestamp.Store(timestamp)
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) addChild(id int64, e entry) {
|
||||||
|
switch v := e.(type) {
|
||||||
|
case *SubChannel:
|
||||||
|
c.subChans[id] = v.RefName
|
||||||
|
case *Channel:
|
||||||
|
c.nestedChans[id] = v.RefName
|
||||||
|
default:
|
||||||
|
logger.Errorf("cannot add a child (id = %d) of type %T to a channel", id, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) deleteChild(id int64) {
|
||||||
|
delete(c.subChans, id)
|
||||||
|
delete(c.nestedChans, id)
|
||||||
|
c.deleteSelfIfReady()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) triggerDelete() {
|
||||||
|
c.closeCalled = true
|
||||||
|
c.deleteSelfIfReady()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) getParentID() int64 {
|
||||||
|
if c.Parent == nil {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
return c.Parent.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteSelfFromTree tries to delete the channel from the channelz entry relation tree, which means
|
||||||
|
// deleting the channel reference from its parent's child list.
|
||||||
|
//
|
||||||
|
// In order for a channel to be deleted from the tree, it must meet the criteria that, removal of the
|
||||||
|
// corresponding grpc object has been invoked, and the channel does not have any children left.
|
||||||
|
//
|
||||||
|
// The returned boolean value indicates whether the channel has been successfully deleted from tree.
|
||||||
|
func (c *Channel) deleteSelfFromTree() (deleted bool) {
|
||||||
|
if !c.closeCalled || len(c.subChans)+len(c.nestedChans) != 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
// not top channel
|
||||||
|
if c.Parent != nil {
|
||||||
|
c.Parent.deleteChild(c.ID)
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteSelfFromMap checks whether it is valid to delete the channel from the map, which means
|
||||||
|
// deleting the channel from channelz's tracking entirely. Users can no longer use id to query the
|
||||||
|
// channel, and its memory will be garbage collected.
|
||||||
|
//
|
||||||
|
// The trace reference count of the channel must be 0 in order to be deleted from the map. This is
|
||||||
|
// specified in the channel tracing gRFC that as long as some other trace has reference to an entity,
|
||||||
|
// the trace of the referenced entity must not be deleted. In order to release the resource allocated
|
||||||
|
// by grpc, the reference to the grpc object is reset to a dummy object.
|
||||||
|
//
|
||||||
|
// deleteSelfFromMap must be called after deleteSelfFromTree returns true.
|
||||||
|
//
|
||||||
|
// It returns a bool to indicate whether the channel can be safely deleted from map.
|
||||||
|
func (c *Channel) deleteSelfFromMap() (delete bool) {
|
||||||
|
return c.getTraceRefCount() == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteSelfIfReady tries to delete the channel itself from the channelz database.
|
||||||
|
// The delete process includes two steps:
|
||||||
|
// 1. delete the channel from the entry relation tree, i.e. delete the channel reference from its
|
||||||
|
// parent's child list.
|
||||||
|
// 2. delete the channel from the map, i.e. delete the channel entirely from channelz. Lookup by id
|
||||||
|
// will return entry not found error.
|
||||||
|
func (c *Channel) deleteSelfIfReady() {
|
||||||
|
if !c.deleteSelfFromTree() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !c.deleteSelfFromMap() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
db.deleteEntry(c.ID)
|
||||||
|
c.trace.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) getChannelTrace() *ChannelTrace {
|
||||||
|
return c.trace
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) incrTraceRefCount() {
|
||||||
|
atomic.AddInt32(&c.traceRefCount, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) decrTraceRefCount() {
|
||||||
|
atomic.AddInt32(&c.traceRefCount, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) getTraceRefCount() int {
|
||||||
|
i := atomic.LoadInt32(&c.traceRefCount)
|
||||||
|
return int(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Channel) getRefName() string {
|
||||||
|
return c.RefName
|
||||||
|
}
|
402
vendor/google.golang.org/grpc/internal/channelz/channelmap.go
generated
vendored
Normal file
402
vendor/google.golang.org/grpc/internal/channelz/channelmap.go
generated
vendored
Normal file
@ -0,0 +1,402 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2018 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package channelz
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// entry represents a node in the channelz database.
|
||||||
|
type entry interface {
|
||||||
|
// addChild adds a child e, whose channelz id is id to child list
|
||||||
|
addChild(id int64, e entry)
|
||||||
|
// deleteChild deletes a child with channelz id to be id from child list
|
||||||
|
deleteChild(id int64)
|
||||||
|
// triggerDelete tries to delete self from channelz database. However, if
|
||||||
|
// child list is not empty, then deletion from the database is on hold until
|
||||||
|
// the last child is deleted from database.
|
||||||
|
triggerDelete()
|
||||||
|
// deleteSelfIfReady check whether triggerDelete() has been called before,
|
||||||
|
// and whether child list is now empty. If both conditions are met, then
|
||||||
|
// delete self from database.
|
||||||
|
deleteSelfIfReady()
|
||||||
|
// getParentID returns parent ID of the entry. 0 value parent ID means no parent.
|
||||||
|
getParentID() int64
|
||||||
|
Entity
|
||||||
|
}
|
||||||
|
|
||||||
|
// channelMap is the storage data structure for channelz.
|
||||||
|
//
|
||||||
|
// Methods of channelMap can be divided in two two categories with respect to
|
||||||
|
// locking.
|
||||||
|
//
|
||||||
|
// 1. Methods acquire the global lock.
|
||||||
|
// 2. Methods that can only be called when global lock is held.
|
||||||
|
//
|
||||||
|
// A second type of method need always to be called inside a first type of method.
|
||||||
|
type channelMap struct {
|
||||||
|
mu sync.RWMutex
|
||||||
|
topLevelChannels map[int64]struct{}
|
||||||
|
channels map[int64]*Channel
|
||||||
|
subChannels map[int64]*SubChannel
|
||||||
|
sockets map[int64]*Socket
|
||||||
|
servers map[int64]*Server
|
||||||
|
}
|
||||||
|
|
||||||
|
func newChannelMap() *channelMap {
|
||||||
|
return &channelMap{
|
||||||
|
topLevelChannels: make(map[int64]struct{}),
|
||||||
|
channels: make(map[int64]*Channel),
|
||||||
|
subChannels: make(map[int64]*SubChannel),
|
||||||
|
sockets: make(map[int64]*Socket),
|
||||||
|
servers: make(map[int64]*Server),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) addServer(id int64, s *Server) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
s.cm = c
|
||||||
|
c.servers[id] = s
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) addChannel(id int64, cn *Channel, isTopChannel bool, pid int64) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
cn.trace.cm = c
|
||||||
|
c.channels[id] = cn
|
||||||
|
if isTopChannel {
|
||||||
|
c.topLevelChannels[id] = struct{}{}
|
||||||
|
} else if p := c.channels[pid]; p != nil {
|
||||||
|
p.addChild(id, cn)
|
||||||
|
} else {
|
||||||
|
logger.Infof("channel %d references invalid parent ID %d", id, pid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) addSubChannel(id int64, sc *SubChannel, pid int64) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
sc.trace.cm = c
|
||||||
|
c.subChannels[id] = sc
|
||||||
|
if p := c.channels[pid]; p != nil {
|
||||||
|
p.addChild(id, sc)
|
||||||
|
} else {
|
||||||
|
logger.Infof("subchannel %d references invalid parent ID %d", id, pid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) addSocket(s *Socket) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
s.cm = c
|
||||||
|
c.sockets[s.ID] = s
|
||||||
|
if s.Parent == nil {
|
||||||
|
logger.Infof("normal socket %d has no parent", s.ID)
|
||||||
|
}
|
||||||
|
s.Parent.(entry).addChild(s.ID, s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// removeEntry triggers the removal of an entry, which may not indeed delete the
|
||||||
|
// entry, if it has to wait on the deletion of its children and until no other
|
||||||
|
// entity's channel trace references it. It may lead to a chain of entry
|
||||||
|
// deletion. For example, deleting the last socket of a gracefully shutting down
|
||||||
|
// server will lead to the server being also deleted.
|
||||||
|
func (c *channelMap) removeEntry(id int64) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
c.findEntry(id).triggerDelete()
|
||||||
|
}
|
||||||
|
|
||||||
|
// tracedChannel represents tracing operations which are present on both
|
||||||
|
// channels and subChannels.
|
||||||
|
type tracedChannel interface {
|
||||||
|
getChannelTrace() *ChannelTrace
|
||||||
|
incrTraceRefCount()
|
||||||
|
decrTraceRefCount()
|
||||||
|
getRefName() string
|
||||||
|
}
|
||||||
|
|
||||||
|
// c.mu must be held by the caller
|
||||||
|
func (c *channelMap) decrTraceRefCount(id int64) {
|
||||||
|
e := c.findEntry(id)
|
||||||
|
if v, ok := e.(tracedChannel); ok {
|
||||||
|
v.decrTraceRefCount()
|
||||||
|
e.deleteSelfIfReady()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// c.mu must be held by the caller.
|
||||||
|
func (c *channelMap) findEntry(id int64) entry {
|
||||||
|
if v, ok := c.channels[id]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
if v, ok := c.subChannels[id]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
if v, ok := c.servers[id]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
if v, ok := c.sockets[id]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return &dummyEntry{idNotFound: id}
|
||||||
|
}
|
||||||
|
|
||||||
|
// c.mu must be held by the caller
|
||||||
|
//
|
||||||
|
// deleteEntry deletes an entry from the channelMap. Before calling this method,
|
||||||
|
// caller must check this entry is ready to be deleted, i.e removeEntry() has
|
||||||
|
// been called on it, and no children still exist.
|
||||||
|
func (c *channelMap) deleteEntry(id int64) entry {
|
||||||
|
if v, ok := c.sockets[id]; ok {
|
||||||
|
delete(c.sockets, id)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
if v, ok := c.subChannels[id]; ok {
|
||||||
|
delete(c.subChannels, id)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
if v, ok := c.channels[id]; ok {
|
||||||
|
delete(c.channels, id)
|
||||||
|
delete(c.topLevelChannels, id)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
if v, ok := c.servers[id]; ok {
|
||||||
|
delete(c.servers, id)
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
return &dummyEntry{idNotFound: id}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) traceEvent(id int64, desc *TraceEvent) {
|
||||||
|
c.mu.Lock()
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
child := c.findEntry(id)
|
||||||
|
childTC, ok := child.(tracedChannel)
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
childTC.getChannelTrace().append(&traceEvent{Desc: desc.Desc, Severity: desc.Severity, Timestamp: time.Now()})
|
||||||
|
if desc.Parent != nil {
|
||||||
|
parent := c.findEntry(child.getParentID())
|
||||||
|
var chanType RefChannelType
|
||||||
|
switch child.(type) {
|
||||||
|
case *Channel:
|
||||||
|
chanType = RefChannel
|
||||||
|
case *SubChannel:
|
||||||
|
chanType = RefSubChannel
|
||||||
|
}
|
||||||
|
if parentTC, ok := parent.(tracedChannel); ok {
|
||||||
|
parentTC.getChannelTrace().append(&traceEvent{
|
||||||
|
Desc: desc.Parent.Desc,
|
||||||
|
Severity: desc.Parent.Severity,
|
||||||
|
Timestamp: time.Now(),
|
||||||
|
RefID: id,
|
||||||
|
RefName: childTC.getRefName(),
|
||||||
|
RefType: chanType,
|
||||||
|
})
|
||||||
|
childTC.incrTraceRefCount()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type int64Slice []int64
|
||||||
|
|
||||||
|
func (s int64Slice) Len() int { return len(s) }
|
||||||
|
func (s int64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
func (s int64Slice) Less(i, j int) bool { return s[i] < s[j] }
|
||||||
|
|
||||||
|
func copyMap(m map[int64]string) map[int64]string {
|
||||||
|
n := make(map[int64]string)
|
||||||
|
for k, v := range m {
|
||||||
|
n[k] = v
|
||||||
|
}
|
||||||
|
return n
|
||||||
|
}
|
||||||
|
|
||||||
|
func min(a, b int) int {
|
||||||
|
if a < b {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) getTopChannels(id int64, maxResults int) ([]*Channel, bool) {
|
||||||
|
if maxResults <= 0 {
|
||||||
|
maxResults = EntriesPerPage
|
||||||
|
}
|
||||||
|
c.mu.RLock()
|
||||||
|
defer c.mu.RUnlock()
|
||||||
|
l := int64(len(c.topLevelChannels))
|
||||||
|
ids := make([]int64, 0, l)
|
||||||
|
|
||||||
|
for k := range c.topLevelChannels {
|
||||||
|
ids = append(ids, k)
|
||||||
|
}
|
||||||
|
sort.Sort(int64Slice(ids))
|
||||||
|
idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= id })
|
||||||
|
end := true
|
||||||
|
var t []*Channel
|
||||||
|
for _, v := range ids[idx:] {
|
||||||
|
if len(t) == maxResults {
|
||||||
|
end = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if cn, ok := c.channels[v]; ok {
|
||||||
|
t = append(t, cn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return t, end
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) getServers(id int64, maxResults int) ([]*Server, bool) {
|
||||||
|
if maxResults <= 0 {
|
||||||
|
maxResults = EntriesPerPage
|
||||||
|
}
|
||||||
|
c.mu.RLock()
|
||||||
|
defer c.mu.RUnlock()
|
||||||
|
ids := make([]int64, 0, len(c.servers))
|
||||||
|
for k := range c.servers {
|
||||||
|
ids = append(ids, k)
|
||||||
|
}
|
||||||
|
sort.Sort(int64Slice(ids))
|
||||||
|
idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= id })
|
||||||
|
end := true
|
||||||
|
var s []*Server
|
||||||
|
for _, v := range ids[idx:] {
|
||||||
|
if len(s) == maxResults {
|
||||||
|
end = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if svr, ok := c.servers[v]; ok {
|
||||||
|
s = append(s, svr)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return s, end
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) getServerSockets(id int64, startID int64, maxResults int) ([]*Socket, bool) {
|
||||||
|
if maxResults <= 0 {
|
||||||
|
maxResults = EntriesPerPage
|
||||||
|
}
|
||||||
|
c.mu.RLock()
|
||||||
|
defer c.mu.RUnlock()
|
||||||
|
svr, ok := c.servers[id]
|
||||||
|
if !ok {
|
||||||
|
// server with id doesn't exist.
|
||||||
|
return nil, true
|
||||||
|
}
|
||||||
|
svrskts := svr.sockets
|
||||||
|
ids := make([]int64, 0, len(svrskts))
|
||||||
|
sks := make([]*Socket, 0, min(len(svrskts), maxResults))
|
||||||
|
for k := range svrskts {
|
||||||
|
ids = append(ids, k)
|
||||||
|
}
|
||||||
|
sort.Sort(int64Slice(ids))
|
||||||
|
idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= startID })
|
||||||
|
end := true
|
||||||
|
for _, v := range ids[idx:] {
|
||||||
|
if len(sks) == maxResults {
|
||||||
|
end = false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if ns, ok := c.sockets[v]; ok {
|
||||||
|
sks = append(sks, ns)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sks, end
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) getChannel(id int64) *Channel {
|
||||||
|
c.mu.RLock()
|
||||||
|
defer c.mu.RUnlock()
|
||||||
|
return c.channels[id]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) getSubChannel(id int64) *SubChannel {
|
||||||
|
c.mu.RLock()
|
||||||
|
defer c.mu.RUnlock()
|
||||||
|
return c.subChannels[id]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) getSocket(id int64) *Socket {
|
||||||
|
c.mu.RLock()
|
||||||
|
defer c.mu.RUnlock()
|
||||||
|
return c.sockets[id]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *channelMap) getServer(id int64) *Server {
|
||||||
|
c.mu.RLock()
|
||||||
|
defer c.mu.RUnlock()
|
||||||
|
return c.servers[id]
|
||||||
|
}
|
||||||
|
|
||||||
|
type dummyEntry struct {
|
||||||
|
// dummyEntry is a fake entry to handle entry not found case.
|
||||||
|
idNotFound int64
|
||||||
|
Entity
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dummyEntry) String() string {
|
||||||
|
return fmt.Sprintf("non-existent entity #%d", d.idNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dummyEntry) ID() int64 { return d.idNotFound }
|
||||||
|
|
||||||
|
func (d *dummyEntry) addChild(id int64, e entry) {
|
||||||
|
// Note: It is possible for a normal program to reach here under race
|
||||||
|
// condition. For example, there could be a race between ClientConn.Close()
|
||||||
|
// info being propagated to addrConn and http2Client. ClientConn.Close()
|
||||||
|
// cancel the context and result in http2Client to error. The error info is
|
||||||
|
// then caught by transport monitor and before addrConn.tearDown() is called
|
||||||
|
// in side ClientConn.Close(). Therefore, the addrConn will create a new
|
||||||
|
// transport. And when registering the new transport in channelz, its parent
|
||||||
|
// addrConn could have already been torn down and deleted from channelz
|
||||||
|
// tracking, and thus reach the code here.
|
||||||
|
logger.Infof("attempt to add child of type %T with id %d to a parent (id=%d) that doesn't currently exist", e, id, d.idNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dummyEntry) deleteChild(id int64) {
|
||||||
|
// It is possible for a normal program to reach here under race condition.
|
||||||
|
// Refer to the example described in addChild().
|
||||||
|
logger.Infof("attempt to delete child with id %d from a parent (id=%d) that doesn't currently exist", id, d.idNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *dummyEntry) triggerDelete() {
|
||||||
|
logger.Warningf("attempt to delete an entry (id=%d) that doesn't currently exist", d.idNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*dummyEntry) deleteSelfIfReady() {
|
||||||
|
// code should not reach here. deleteSelfIfReady is always called on an existing entry.
|
||||||
|
}
|
||||||
|
|
||||||
|
func (*dummyEntry) getParentID() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// Entity is implemented by all channelz types.
|
||||||
|
type Entity interface {
|
||||||
|
isEntity()
|
||||||
|
fmt.Stringer
|
||||||
|
id() int64
|
||||||
|
}
|
697
vendor/google.golang.org/grpc/internal/channelz/funcs.go
generated
vendored
697
vendor/google.golang.org/grpc/internal/channelz/funcs.go
generated
vendored
@ -16,47 +16,32 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Package channelz defines APIs for enabling channelz service, entry
|
// Package channelz defines internal APIs for enabling channelz service, entry
|
||||||
// registration/deletion, and accessing channelz data. It also defines channelz
|
// registration/deletion, and accessing channelz data. It also defines channelz
|
||||||
// metric struct formats.
|
// metric struct formats.
|
||||||
//
|
|
||||||
// All APIs in this package are experimental.
|
|
||||||
package channelz
|
package channelz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
|
||||||
"sort"
|
|
||||||
"sync"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc/grpclog"
|
|
||||||
"google.golang.org/grpc/internal"
|
"google.golang.org/grpc/internal"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
defaultMaxTraceEntry int32 = 30
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// IDGen is the global channelz entity ID generator. It should not be used
|
// IDGen is the global channelz entity ID generator. It should not be used
|
||||||
// outside this package except by tests.
|
// outside this package except by tests.
|
||||||
IDGen IDGenerator
|
IDGen IDGenerator
|
||||||
|
|
||||||
db dbWrapper
|
db *channelMap = newChannelMap()
|
||||||
// EntryPerPage defines the number of channelz entries to be shown on a web page.
|
// EntriesPerPage defines the number of channelz entries to be shown on a web page.
|
||||||
EntryPerPage = int64(50)
|
EntriesPerPage = 50
|
||||||
curState int32
|
curState int32
|
||||||
maxTraceEntry = defaultMaxTraceEntry
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// TurnOn turns on channelz data collection.
|
// TurnOn turns on channelz data collection.
|
||||||
func TurnOn() {
|
func TurnOn() {
|
||||||
if !IsOn() {
|
atomic.StoreInt32(&curState, 1)
|
||||||
db.set(newChannelMap())
|
|
||||||
IDGen.Reset()
|
|
||||||
atomic.StoreInt32(&curState, 1)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -70,49 +55,15 @@ func IsOn() bool {
|
|||||||
return atomic.LoadInt32(&curState) == 1
|
return atomic.LoadInt32(&curState) == 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetMaxTraceEntry sets maximum number of trace entry per entity (i.e. channel/subchannel).
|
|
||||||
// Setting it to 0 will disable channel tracing.
|
|
||||||
func SetMaxTraceEntry(i int32) {
|
|
||||||
atomic.StoreInt32(&maxTraceEntry, i)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ResetMaxTraceEntryToDefault resets the maximum number of trace entry per entity to default.
|
|
||||||
func ResetMaxTraceEntryToDefault() {
|
|
||||||
atomic.StoreInt32(&maxTraceEntry, defaultMaxTraceEntry)
|
|
||||||
}
|
|
||||||
|
|
||||||
func getMaxTraceEntry() int {
|
|
||||||
i := atomic.LoadInt32(&maxTraceEntry)
|
|
||||||
return int(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
// dbWarpper wraps around a reference to internal channelz data storage, and
|
|
||||||
// provide synchronized functionality to set and get the reference.
|
|
||||||
type dbWrapper struct {
|
|
||||||
mu sync.RWMutex
|
|
||||||
DB *channelMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *dbWrapper) set(db *channelMap) {
|
|
||||||
d.mu.Lock()
|
|
||||||
d.DB = db
|
|
||||||
d.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *dbWrapper) get() *channelMap {
|
|
||||||
d.mu.RLock()
|
|
||||||
defer d.mu.RUnlock()
|
|
||||||
return d.DB
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetTopChannels returns a slice of top channel's ChannelMetric, along with a
|
// GetTopChannels returns a slice of top channel's ChannelMetric, along with a
|
||||||
// boolean indicating whether there's more top channels to be queried for.
|
// boolean indicating whether there's more top channels to be queried for.
|
||||||
//
|
//
|
||||||
// The arg id specifies that only top channel with id at or above it will be included
|
// The arg id specifies that only top channel with id at or above it will be
|
||||||
// in the result. The returned slice is up to a length of the arg maxResults or
|
// included in the result. The returned slice is up to a length of the arg
|
||||||
// EntryPerPage if maxResults is zero, and is sorted in ascending id order.
|
// maxResults or EntriesPerPage if maxResults is zero, and is sorted in ascending
|
||||||
func GetTopChannels(id int64, maxResults int64) ([]*ChannelMetric, bool) {
|
// id order.
|
||||||
return db.get().GetTopChannels(id, maxResults)
|
func GetTopChannels(id int64, maxResults int) ([]*Channel, bool) {
|
||||||
|
return db.getTopChannels(id, maxResults)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetServers returns a slice of server's ServerMetric, along with a
|
// GetServers returns a slice of server's ServerMetric, along with a
|
||||||
@ -120,73 +71,69 @@ func GetTopChannels(id int64, maxResults int64) ([]*ChannelMetric, bool) {
|
|||||||
//
|
//
|
||||||
// The arg id specifies that only server with id at or above it will be included
|
// The arg id specifies that only server with id at or above it will be included
|
||||||
// in the result. The returned slice is up to a length of the arg maxResults or
|
// in the result. The returned slice is up to a length of the arg maxResults or
|
||||||
// EntryPerPage if maxResults is zero, and is sorted in ascending id order.
|
// EntriesPerPage if maxResults is zero, and is sorted in ascending id order.
|
||||||
func GetServers(id int64, maxResults int64) ([]*ServerMetric, bool) {
|
func GetServers(id int64, maxResults int) ([]*Server, bool) {
|
||||||
return db.get().GetServers(id, maxResults)
|
return db.getServers(id, maxResults)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetServerSockets returns a slice of server's (identified by id) normal socket's
|
// GetServerSockets returns a slice of server's (identified by id) normal socket's
|
||||||
// SocketMetric, along with a boolean indicating whether there's more sockets to
|
// SocketMetrics, along with a boolean indicating whether there's more sockets to
|
||||||
// be queried for.
|
// be queried for.
|
||||||
//
|
//
|
||||||
// The arg startID specifies that only sockets with id at or above it will be
|
// The arg startID specifies that only sockets with id at or above it will be
|
||||||
// included in the result. The returned slice is up to a length of the arg maxResults
|
// included in the result. The returned slice is up to a length of the arg maxResults
|
||||||
// or EntryPerPage if maxResults is zero, and is sorted in ascending id order.
|
// or EntriesPerPage if maxResults is zero, and is sorted in ascending id order.
|
||||||
func GetServerSockets(id int64, startID int64, maxResults int64) ([]*SocketMetric, bool) {
|
func GetServerSockets(id int64, startID int64, maxResults int) ([]*Socket, bool) {
|
||||||
return db.get().GetServerSockets(id, startID, maxResults)
|
return db.getServerSockets(id, startID, maxResults)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetChannel returns the ChannelMetric for the channel (identified by id).
|
// GetChannel returns the Channel for the channel (identified by id).
|
||||||
func GetChannel(id int64) *ChannelMetric {
|
func GetChannel(id int64) *Channel {
|
||||||
return db.get().GetChannel(id)
|
return db.getChannel(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSubChannel returns the SubChannelMetric for the subchannel (identified by id).
|
// GetSubChannel returns the SubChannel for the subchannel (identified by id).
|
||||||
func GetSubChannel(id int64) *SubChannelMetric {
|
func GetSubChannel(id int64) *SubChannel {
|
||||||
return db.get().GetSubChannel(id)
|
return db.getSubChannel(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetSocket returns the SocketInternalMetric for the socket (identified by id).
|
// GetSocket returns the Socket for the socket (identified by id).
|
||||||
func GetSocket(id int64) *SocketMetric {
|
func GetSocket(id int64) *Socket {
|
||||||
return db.get().GetSocket(id)
|
return db.getSocket(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetServer returns the ServerMetric for the server (identified by id).
|
// GetServer returns the ServerMetric for the server (identified by id).
|
||||||
func GetServer(id int64) *ServerMetric {
|
func GetServer(id int64) *Server {
|
||||||
return db.get().GetServer(id)
|
return db.getServer(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterChannel registers the given channel c in the channelz database with
|
// RegisterChannel registers the given channel c in the channelz database with
|
||||||
// ref as its reference name, and adds it to the child list of its parent
|
// target as its target and reference name, and adds it to the child list of its
|
||||||
// (identified by pid). pid == nil means no parent.
|
// parent. parent == nil means no parent.
|
||||||
//
|
//
|
||||||
// Returns a unique channelz identifier assigned to this channel.
|
// Returns a unique channelz identifier assigned to this channel.
|
||||||
//
|
//
|
||||||
// If channelz is not turned ON, the channelz database is not mutated.
|
// If channelz is not turned ON, the channelz database is not mutated.
|
||||||
func RegisterChannel(c Channel, pid *Identifier, ref string) *Identifier {
|
func RegisterChannel(parent *Channel, target string) *Channel {
|
||||||
id := IDGen.genID()
|
id := IDGen.genID()
|
||||||
var parent int64
|
|
||||||
isTopChannel := true
|
|
||||||
if pid != nil {
|
|
||||||
isTopChannel = false
|
|
||||||
parent = pid.Int()
|
|
||||||
}
|
|
||||||
|
|
||||||
if !IsOn() {
|
if !IsOn() {
|
||||||
return newIdentifer(RefChannel, id, pid)
|
return &Channel{ID: id}
|
||||||
}
|
}
|
||||||
|
|
||||||
cn := &channel{
|
isTopChannel := parent == nil
|
||||||
refName: ref,
|
|
||||||
c: c,
|
cn := &Channel{
|
||||||
subChans: make(map[int64]string),
|
ID: id,
|
||||||
|
RefName: target,
|
||||||
nestedChans: make(map[int64]string),
|
nestedChans: make(map[int64]string),
|
||||||
id: id,
|
subChans: make(map[int64]string),
|
||||||
pid: parent,
|
Parent: parent,
|
||||||
trace: &channelTrace{createdTime: time.Now(), events: make([]*TraceEvent, 0, getMaxTraceEntry())},
|
trace: &ChannelTrace{CreationTime: time.Now(), Events: make([]*traceEvent, 0, getMaxTraceEntry())},
|
||||||
}
|
}
|
||||||
db.get().addChannel(id, cn, isTopChannel, parent)
|
cn.ChannelMetrics.Target.Store(&target)
|
||||||
return newIdentifer(RefChannel, id, pid)
|
db.addChannel(id, cn, isTopChannel, cn.getParentID())
|
||||||
|
return cn
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterSubChannel registers the given subChannel c in the channelz database
|
// RegisterSubChannel registers the given subChannel c in the channelz database
|
||||||
@ -196,555 +143,67 @@ func RegisterChannel(c Channel, pid *Identifier, ref string) *Identifier {
|
|||||||
// Returns a unique channelz identifier assigned to this subChannel.
|
// Returns a unique channelz identifier assigned to this subChannel.
|
||||||
//
|
//
|
||||||
// If channelz is not turned ON, the channelz database is not mutated.
|
// If channelz is not turned ON, the channelz database is not mutated.
|
||||||
func RegisterSubChannel(c Channel, pid *Identifier, ref string) (*Identifier, error) {
|
func RegisterSubChannel(parent *Channel, ref string) *SubChannel {
|
||||||
if pid == nil {
|
|
||||||
return nil, errors.New("a SubChannel's parent id cannot be nil")
|
|
||||||
}
|
|
||||||
id := IDGen.genID()
|
id := IDGen.genID()
|
||||||
if !IsOn() {
|
sc := &SubChannel{
|
||||||
return newIdentifer(RefSubChannel, id, pid), nil
|
ID: id,
|
||||||
|
RefName: ref,
|
||||||
|
parent: parent,
|
||||||
}
|
}
|
||||||
|
|
||||||
sc := &subChannel{
|
if !IsOn() {
|
||||||
refName: ref,
|
return sc
|
||||||
c: c,
|
|
||||||
sockets: make(map[int64]string),
|
|
||||||
id: id,
|
|
||||||
pid: pid.Int(),
|
|
||||||
trace: &channelTrace{createdTime: time.Now(), events: make([]*TraceEvent, 0, getMaxTraceEntry())},
|
|
||||||
}
|
}
|
||||||
db.get().addSubChannel(id, sc, pid.Int())
|
|
||||||
return newIdentifer(RefSubChannel, id, pid), nil
|
sc.sockets = make(map[int64]string)
|
||||||
|
sc.trace = &ChannelTrace{CreationTime: time.Now(), Events: make([]*traceEvent, 0, getMaxTraceEntry())}
|
||||||
|
db.addSubChannel(id, sc, parent.ID)
|
||||||
|
return sc
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterServer registers the given server s in channelz database. It returns
|
// RegisterServer registers the given server s in channelz database. It returns
|
||||||
// the unique channelz tracking id assigned to this server.
|
// the unique channelz tracking id assigned to this server.
|
||||||
//
|
//
|
||||||
// If channelz is not turned ON, the channelz database is not mutated.
|
// If channelz is not turned ON, the channelz database is not mutated.
|
||||||
func RegisterServer(s Server, ref string) *Identifier {
|
func RegisterServer(ref string) *Server {
|
||||||
id := IDGen.genID()
|
id := IDGen.genID()
|
||||||
if !IsOn() {
|
if !IsOn() {
|
||||||
return newIdentifer(RefServer, id, nil)
|
return &Server{ID: id}
|
||||||
}
|
}
|
||||||
|
|
||||||
svr := &server{
|
svr := &Server{
|
||||||
refName: ref,
|
RefName: ref,
|
||||||
s: s,
|
|
||||||
sockets: make(map[int64]string),
|
sockets: make(map[int64]string),
|
||||||
listenSockets: make(map[int64]string),
|
listenSockets: make(map[int64]string),
|
||||||
id: id,
|
ID: id,
|
||||||
}
|
}
|
||||||
db.get().addServer(id, svr)
|
db.addServer(id, svr)
|
||||||
return newIdentifer(RefServer, id, nil)
|
return svr
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterListenSocket registers the given listen socket s in channelz database
|
// RegisterSocket registers the given normal socket s in channelz database
|
||||||
// with ref as its reference name, and add it to the child list of its parent
|
|
||||||
// (identified by pid). It returns the unique channelz tracking id assigned to
|
|
||||||
// this listen socket.
|
|
||||||
//
|
|
||||||
// If channelz is not turned ON, the channelz database is not mutated.
|
|
||||||
func RegisterListenSocket(s Socket, pid *Identifier, ref string) (*Identifier, error) {
|
|
||||||
if pid == nil {
|
|
||||||
return nil, errors.New("a ListenSocket's parent id cannot be 0")
|
|
||||||
}
|
|
||||||
id := IDGen.genID()
|
|
||||||
if !IsOn() {
|
|
||||||
return newIdentifer(RefListenSocket, id, pid), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ls := &listenSocket{refName: ref, s: s, id: id, pid: pid.Int()}
|
|
||||||
db.get().addListenSocket(id, ls, pid.Int())
|
|
||||||
return newIdentifer(RefListenSocket, id, pid), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterNormalSocket registers the given normal socket s in channelz database
|
|
||||||
// with ref as its reference name, and adds it to the child list of its parent
|
// with ref as its reference name, and adds it to the child list of its parent
|
||||||
// (identified by pid). It returns the unique channelz tracking id assigned to
|
// (identified by skt.Parent, which must be set). It returns the unique channelz
|
||||||
// this normal socket.
|
// tracking id assigned to this normal socket.
|
||||||
//
|
//
|
||||||
// If channelz is not turned ON, the channelz database is not mutated.
|
// If channelz is not turned ON, the channelz database is not mutated.
|
||||||
func RegisterNormalSocket(s Socket, pid *Identifier, ref string) (*Identifier, error) {
|
func RegisterSocket(skt *Socket) *Socket {
|
||||||
if pid == nil {
|
skt.ID = IDGen.genID()
|
||||||
return nil, errors.New("a NormalSocket's parent id cannot be 0")
|
if IsOn() {
|
||||||
|
db.addSocket(skt)
|
||||||
}
|
}
|
||||||
id := IDGen.genID()
|
return skt
|
||||||
if !IsOn() {
|
|
||||||
return newIdentifer(RefNormalSocket, id, pid), nil
|
|
||||||
}
|
|
||||||
|
|
||||||
ns := &normalSocket{refName: ref, s: s, id: id, pid: pid.Int()}
|
|
||||||
db.get().addNormalSocket(id, ns, pid.Int())
|
|
||||||
return newIdentifer(RefNormalSocket, id, pid), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RemoveEntry removes an entry with unique channelz tracking id to be id from
|
// RemoveEntry removes an entry with unique channelz tracking id to be id from
|
||||||
// channelz database.
|
// channelz database.
|
||||||
//
|
//
|
||||||
// If channelz is not turned ON, this function is a no-op.
|
// If channelz is not turned ON, this function is a no-op.
|
||||||
func RemoveEntry(id *Identifier) {
|
func RemoveEntry(id int64) {
|
||||||
if !IsOn() {
|
if !IsOn() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
db.get().removeEntry(id.Int())
|
db.removeEntry(id)
|
||||||
}
|
|
||||||
|
|
||||||
// TraceEventDesc is what the caller of AddTraceEvent should provide to describe
|
|
||||||
// the event to be added to the channel trace.
|
|
||||||
//
|
|
||||||
// The Parent field is optional. It is used for an event that will be recorded
|
|
||||||
// in the entity's parent trace.
|
|
||||||
type TraceEventDesc struct {
|
|
||||||
Desc string
|
|
||||||
Severity Severity
|
|
||||||
Parent *TraceEventDesc
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddTraceEvent adds trace related to the entity with specified id, using the
|
|
||||||
// provided TraceEventDesc.
|
|
||||||
//
|
|
||||||
// If channelz is not turned ON, this will simply log the event descriptions.
|
|
||||||
func AddTraceEvent(l grpclog.DepthLoggerV2, id *Identifier, depth int, desc *TraceEventDesc) {
|
|
||||||
// Log only the trace description associated with the bottom most entity.
|
|
||||||
switch desc.Severity {
|
|
||||||
case CtUnknown, CtInfo:
|
|
||||||
l.InfoDepth(depth+1, withParens(id)+desc.Desc)
|
|
||||||
case CtWarning:
|
|
||||||
l.WarningDepth(depth+1, withParens(id)+desc.Desc)
|
|
||||||
case CtError:
|
|
||||||
l.ErrorDepth(depth+1, withParens(id)+desc.Desc)
|
|
||||||
}
|
|
||||||
|
|
||||||
if getMaxTraceEntry() == 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if IsOn() {
|
|
||||||
db.get().traceEvent(id.Int(), desc)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// channelMap is the storage data structure for channelz.
|
|
||||||
// Methods of channelMap can be divided in two two categories with respect to locking.
|
|
||||||
// 1. Methods acquire the global lock.
|
|
||||||
// 2. Methods that can only be called when global lock is held.
|
|
||||||
// A second type of method need always to be called inside a first type of method.
|
|
||||||
type channelMap struct {
|
|
||||||
mu sync.RWMutex
|
|
||||||
topLevelChannels map[int64]struct{}
|
|
||||||
servers map[int64]*server
|
|
||||||
channels map[int64]*channel
|
|
||||||
subChannels map[int64]*subChannel
|
|
||||||
listenSockets map[int64]*listenSocket
|
|
||||||
normalSockets map[int64]*normalSocket
|
|
||||||
}
|
|
||||||
|
|
||||||
func newChannelMap() *channelMap {
|
|
||||||
return &channelMap{
|
|
||||||
topLevelChannels: make(map[int64]struct{}),
|
|
||||||
channels: make(map[int64]*channel),
|
|
||||||
listenSockets: make(map[int64]*listenSocket),
|
|
||||||
normalSockets: make(map[int64]*normalSocket),
|
|
||||||
servers: make(map[int64]*server),
|
|
||||||
subChannels: make(map[int64]*subChannel),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) addServer(id int64, s *server) {
|
|
||||||
c.mu.Lock()
|
|
||||||
s.cm = c
|
|
||||||
c.servers[id] = s
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) addChannel(id int64, cn *channel, isTopChannel bool, pid int64) {
|
|
||||||
c.mu.Lock()
|
|
||||||
cn.cm = c
|
|
||||||
cn.trace.cm = c
|
|
||||||
c.channels[id] = cn
|
|
||||||
if isTopChannel {
|
|
||||||
c.topLevelChannels[id] = struct{}{}
|
|
||||||
} else {
|
|
||||||
c.findEntry(pid).addChild(id, cn)
|
|
||||||
}
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) addSubChannel(id int64, sc *subChannel, pid int64) {
|
|
||||||
c.mu.Lock()
|
|
||||||
sc.cm = c
|
|
||||||
sc.trace.cm = c
|
|
||||||
c.subChannels[id] = sc
|
|
||||||
c.findEntry(pid).addChild(id, sc)
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) addListenSocket(id int64, ls *listenSocket, pid int64) {
|
|
||||||
c.mu.Lock()
|
|
||||||
ls.cm = c
|
|
||||||
c.listenSockets[id] = ls
|
|
||||||
c.findEntry(pid).addChild(id, ls)
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) addNormalSocket(id int64, ns *normalSocket, pid int64) {
|
|
||||||
c.mu.Lock()
|
|
||||||
ns.cm = c
|
|
||||||
c.normalSockets[id] = ns
|
|
||||||
c.findEntry(pid).addChild(id, ns)
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// removeEntry triggers the removal of an entry, which may not indeed delete the entry, if it has to
|
|
||||||
// wait on the deletion of its children and until no other entity's channel trace references it.
|
|
||||||
// It may lead to a chain of entry deletion. For example, deleting the last socket of a gracefully
|
|
||||||
// shutting down server will lead to the server being also deleted.
|
|
||||||
func (c *channelMap) removeEntry(id int64) {
|
|
||||||
c.mu.Lock()
|
|
||||||
c.findEntry(id).triggerDelete()
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// c.mu must be held by the caller
|
|
||||||
func (c *channelMap) decrTraceRefCount(id int64) {
|
|
||||||
e := c.findEntry(id)
|
|
||||||
if v, ok := e.(tracedChannel); ok {
|
|
||||||
v.decrTraceRefCount()
|
|
||||||
e.deleteSelfIfReady()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// c.mu must be held by the caller.
|
|
||||||
func (c *channelMap) findEntry(id int64) entry {
|
|
||||||
var v entry
|
|
||||||
var ok bool
|
|
||||||
if v, ok = c.channels[id]; ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
if v, ok = c.subChannels[id]; ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
if v, ok = c.servers[id]; ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
if v, ok = c.listenSockets[id]; ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
if v, ok = c.normalSockets[id]; ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
return &dummyEntry{idNotFound: id}
|
|
||||||
}
|
|
||||||
|
|
||||||
// c.mu must be held by the caller
|
|
||||||
// deleteEntry simply deletes an entry from the channelMap. Before calling this
|
|
||||||
// method, caller must check this entry is ready to be deleted, i.e removeEntry()
|
|
||||||
// has been called on it, and no children still exist.
|
|
||||||
// Conditionals are ordered by the expected frequency of deletion of each entity
|
|
||||||
// type, in order to optimize performance.
|
|
||||||
func (c *channelMap) deleteEntry(id int64) {
|
|
||||||
var ok bool
|
|
||||||
if _, ok = c.normalSockets[id]; ok {
|
|
||||||
delete(c.normalSockets, id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if _, ok = c.subChannels[id]; ok {
|
|
||||||
delete(c.subChannels, id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if _, ok = c.channels[id]; ok {
|
|
||||||
delete(c.channels, id)
|
|
||||||
delete(c.topLevelChannels, id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if _, ok = c.listenSockets[id]; ok {
|
|
||||||
delete(c.listenSockets, id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if _, ok = c.servers[id]; ok {
|
|
||||||
delete(c.servers, id)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) traceEvent(id int64, desc *TraceEventDesc) {
|
|
||||||
c.mu.Lock()
|
|
||||||
child := c.findEntry(id)
|
|
||||||
childTC, ok := child.(tracedChannel)
|
|
||||||
if !ok {
|
|
||||||
c.mu.Unlock()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
childTC.getChannelTrace().append(&TraceEvent{Desc: desc.Desc, Severity: desc.Severity, Timestamp: time.Now()})
|
|
||||||
if desc.Parent != nil {
|
|
||||||
parent := c.findEntry(child.getParentID())
|
|
||||||
var chanType RefChannelType
|
|
||||||
switch child.(type) {
|
|
||||||
case *channel:
|
|
||||||
chanType = RefChannel
|
|
||||||
case *subChannel:
|
|
||||||
chanType = RefSubChannel
|
|
||||||
}
|
|
||||||
if parentTC, ok := parent.(tracedChannel); ok {
|
|
||||||
parentTC.getChannelTrace().append(&TraceEvent{
|
|
||||||
Desc: desc.Parent.Desc,
|
|
||||||
Severity: desc.Parent.Severity,
|
|
||||||
Timestamp: time.Now(),
|
|
||||||
RefID: id,
|
|
||||||
RefName: childTC.getRefName(),
|
|
||||||
RefType: chanType,
|
|
||||||
})
|
|
||||||
childTC.incrTraceRefCount()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
type int64Slice []int64
|
|
||||||
|
|
||||||
func (s int64Slice) Len() int { return len(s) }
|
|
||||||
func (s int64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
|
||||||
func (s int64Slice) Less(i, j int) bool { return s[i] < s[j] }
|
|
||||||
|
|
||||||
func copyMap(m map[int64]string) map[int64]string {
|
|
||||||
n := make(map[int64]string)
|
|
||||||
for k, v := range m {
|
|
||||||
n[k] = v
|
|
||||||
}
|
|
||||||
return n
|
|
||||||
}
|
|
||||||
|
|
||||||
func min(a, b int64) int64 {
|
|
||||||
if a < b {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) GetTopChannels(id int64, maxResults int64) ([]*ChannelMetric, bool) {
|
|
||||||
if maxResults <= 0 {
|
|
||||||
maxResults = EntryPerPage
|
|
||||||
}
|
|
||||||
c.mu.RLock()
|
|
||||||
l := int64(len(c.topLevelChannels))
|
|
||||||
ids := make([]int64, 0, l)
|
|
||||||
cns := make([]*channel, 0, min(l, maxResults))
|
|
||||||
|
|
||||||
for k := range c.topLevelChannels {
|
|
||||||
ids = append(ids, k)
|
|
||||||
}
|
|
||||||
sort.Sort(int64Slice(ids))
|
|
||||||
idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= id })
|
|
||||||
count := int64(0)
|
|
||||||
var end bool
|
|
||||||
var t []*ChannelMetric
|
|
||||||
for i, v := range ids[idx:] {
|
|
||||||
if count == maxResults {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if cn, ok := c.channels[v]; ok {
|
|
||||||
cns = append(cns, cn)
|
|
||||||
t = append(t, &ChannelMetric{
|
|
||||||
NestedChans: copyMap(cn.nestedChans),
|
|
||||||
SubChans: copyMap(cn.subChans),
|
|
||||||
})
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
if i == len(ids[idx:])-1 {
|
|
||||||
end = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.mu.RUnlock()
|
|
||||||
if count == 0 {
|
|
||||||
end = true
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, cn := range cns {
|
|
||||||
t[i].ChannelData = cn.c.ChannelzMetric()
|
|
||||||
t[i].ID = cn.id
|
|
||||||
t[i].RefName = cn.refName
|
|
||||||
t[i].Trace = cn.trace.dumpData()
|
|
||||||
}
|
|
||||||
return t, end
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) GetServers(id, maxResults int64) ([]*ServerMetric, bool) {
|
|
||||||
if maxResults <= 0 {
|
|
||||||
maxResults = EntryPerPage
|
|
||||||
}
|
|
||||||
c.mu.RLock()
|
|
||||||
l := int64(len(c.servers))
|
|
||||||
ids := make([]int64, 0, l)
|
|
||||||
ss := make([]*server, 0, min(l, maxResults))
|
|
||||||
for k := range c.servers {
|
|
||||||
ids = append(ids, k)
|
|
||||||
}
|
|
||||||
sort.Sort(int64Slice(ids))
|
|
||||||
idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= id })
|
|
||||||
count := int64(0)
|
|
||||||
var end bool
|
|
||||||
var s []*ServerMetric
|
|
||||||
for i, v := range ids[idx:] {
|
|
||||||
if count == maxResults {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if svr, ok := c.servers[v]; ok {
|
|
||||||
ss = append(ss, svr)
|
|
||||||
s = append(s, &ServerMetric{
|
|
||||||
ListenSockets: copyMap(svr.listenSockets),
|
|
||||||
})
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
if i == len(ids[idx:])-1 {
|
|
||||||
end = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.mu.RUnlock()
|
|
||||||
if count == 0 {
|
|
||||||
end = true
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, svr := range ss {
|
|
||||||
s[i].ServerData = svr.s.ChannelzMetric()
|
|
||||||
s[i].ID = svr.id
|
|
||||||
s[i].RefName = svr.refName
|
|
||||||
}
|
|
||||||
return s, end
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) GetServerSockets(id int64, startID int64, maxResults int64) ([]*SocketMetric, bool) {
|
|
||||||
if maxResults <= 0 {
|
|
||||||
maxResults = EntryPerPage
|
|
||||||
}
|
|
||||||
var svr *server
|
|
||||||
var ok bool
|
|
||||||
c.mu.RLock()
|
|
||||||
if svr, ok = c.servers[id]; !ok {
|
|
||||||
// server with id doesn't exist.
|
|
||||||
c.mu.RUnlock()
|
|
||||||
return nil, true
|
|
||||||
}
|
|
||||||
svrskts := svr.sockets
|
|
||||||
l := int64(len(svrskts))
|
|
||||||
ids := make([]int64, 0, l)
|
|
||||||
sks := make([]*normalSocket, 0, min(l, maxResults))
|
|
||||||
for k := range svrskts {
|
|
||||||
ids = append(ids, k)
|
|
||||||
}
|
|
||||||
sort.Sort(int64Slice(ids))
|
|
||||||
idx := sort.Search(len(ids), func(i int) bool { return ids[i] >= startID })
|
|
||||||
count := int64(0)
|
|
||||||
var end bool
|
|
||||||
for i, v := range ids[idx:] {
|
|
||||||
if count == maxResults {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if ns, ok := c.normalSockets[v]; ok {
|
|
||||||
sks = append(sks, ns)
|
|
||||||
count++
|
|
||||||
}
|
|
||||||
if i == len(ids[idx:])-1 {
|
|
||||||
end = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.mu.RUnlock()
|
|
||||||
if count == 0 {
|
|
||||||
end = true
|
|
||||||
}
|
|
||||||
s := make([]*SocketMetric, 0, len(sks))
|
|
||||||
for _, ns := range sks {
|
|
||||||
sm := &SocketMetric{}
|
|
||||||
sm.SocketData = ns.s.ChannelzMetric()
|
|
||||||
sm.ID = ns.id
|
|
||||||
sm.RefName = ns.refName
|
|
||||||
s = append(s, sm)
|
|
||||||
}
|
|
||||||
return s, end
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) GetChannel(id int64) *ChannelMetric {
|
|
||||||
cm := &ChannelMetric{}
|
|
||||||
var cn *channel
|
|
||||||
var ok bool
|
|
||||||
c.mu.RLock()
|
|
||||||
if cn, ok = c.channels[id]; !ok {
|
|
||||||
// channel with id doesn't exist.
|
|
||||||
c.mu.RUnlock()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
cm.NestedChans = copyMap(cn.nestedChans)
|
|
||||||
cm.SubChans = copyMap(cn.subChans)
|
|
||||||
// cn.c can be set to &dummyChannel{} when deleteSelfFromMap is called. Save a copy of cn.c when
|
|
||||||
// holding the lock to prevent potential data race.
|
|
||||||
chanCopy := cn.c
|
|
||||||
c.mu.RUnlock()
|
|
||||||
cm.ChannelData = chanCopy.ChannelzMetric()
|
|
||||||
cm.ID = cn.id
|
|
||||||
cm.RefName = cn.refName
|
|
||||||
cm.Trace = cn.trace.dumpData()
|
|
||||||
return cm
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) GetSubChannel(id int64) *SubChannelMetric {
|
|
||||||
cm := &SubChannelMetric{}
|
|
||||||
var sc *subChannel
|
|
||||||
var ok bool
|
|
||||||
c.mu.RLock()
|
|
||||||
if sc, ok = c.subChannels[id]; !ok {
|
|
||||||
// subchannel with id doesn't exist.
|
|
||||||
c.mu.RUnlock()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
cm.Sockets = copyMap(sc.sockets)
|
|
||||||
// sc.c can be set to &dummyChannel{} when deleteSelfFromMap is called. Save a copy of sc.c when
|
|
||||||
// holding the lock to prevent potential data race.
|
|
||||||
chanCopy := sc.c
|
|
||||||
c.mu.RUnlock()
|
|
||||||
cm.ChannelData = chanCopy.ChannelzMetric()
|
|
||||||
cm.ID = sc.id
|
|
||||||
cm.RefName = sc.refName
|
|
||||||
cm.Trace = sc.trace.dumpData()
|
|
||||||
return cm
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) GetSocket(id int64) *SocketMetric {
|
|
||||||
sm := &SocketMetric{}
|
|
||||||
c.mu.RLock()
|
|
||||||
if ls, ok := c.listenSockets[id]; ok {
|
|
||||||
c.mu.RUnlock()
|
|
||||||
sm.SocketData = ls.s.ChannelzMetric()
|
|
||||||
sm.ID = ls.id
|
|
||||||
sm.RefName = ls.refName
|
|
||||||
return sm
|
|
||||||
}
|
|
||||||
if ns, ok := c.normalSockets[id]; ok {
|
|
||||||
c.mu.RUnlock()
|
|
||||||
sm.SocketData = ns.s.ChannelzMetric()
|
|
||||||
sm.ID = ns.id
|
|
||||||
sm.RefName = ns.refName
|
|
||||||
return sm
|
|
||||||
}
|
|
||||||
c.mu.RUnlock()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelMap) GetServer(id int64) *ServerMetric {
|
|
||||||
sm := &ServerMetric{}
|
|
||||||
var svr *server
|
|
||||||
var ok bool
|
|
||||||
c.mu.RLock()
|
|
||||||
if svr, ok = c.servers[id]; !ok {
|
|
||||||
c.mu.RUnlock()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
sm.ListenSockets = copyMap(svr.listenSockets)
|
|
||||||
c.mu.RUnlock()
|
|
||||||
sm.ID = svr.id
|
|
||||||
sm.RefName = svr.refName
|
|
||||||
sm.ServerData = svr.s.ChannelzMetric()
|
|
||||||
return sm
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDGenerator is an incrementing atomic that tracks IDs for channelz entities.
|
// IDGenerator is an incrementing atomic that tracks IDs for channelz entities.
|
||||||
@ -761,3 +220,11 @@ func (i *IDGenerator) Reset() {
|
|||||||
func (i *IDGenerator) genID() int64 {
|
func (i *IDGenerator) genID() int64 {
|
||||||
return atomic.AddInt64(&i.id, 1)
|
return atomic.AddInt64(&i.id, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Identifier is an opaque channelz identifier used to expose channelz symbols
|
||||||
|
// outside of grpc. Currently only implemented by Channel since no other
|
||||||
|
// types require exposure outside grpc.
|
||||||
|
type Identifier interface {
|
||||||
|
Entity
|
||||||
|
channelzIdentifier()
|
||||||
|
}
|
||||||
|
75
vendor/google.golang.org/grpc/internal/channelz/id.go
generated
vendored
75
vendor/google.golang.org/grpc/internal/channelz/id.go
generated
vendored
@ -1,75 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2022 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package channelz
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// Identifier is an opaque identifier which uniquely identifies an entity in the
|
|
||||||
// channelz database.
|
|
||||||
type Identifier struct {
|
|
||||||
typ RefChannelType
|
|
||||||
id int64
|
|
||||||
str string
|
|
||||||
pid *Identifier
|
|
||||||
}
|
|
||||||
|
|
||||||
// Type returns the entity type corresponding to id.
|
|
||||||
func (id *Identifier) Type() RefChannelType {
|
|
||||||
return id.typ
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int returns the integer identifier corresponding to id.
|
|
||||||
func (id *Identifier) Int() int64 {
|
|
||||||
return id.id
|
|
||||||
}
|
|
||||||
|
|
||||||
// String returns a string representation of the entity corresponding to id.
|
|
||||||
//
|
|
||||||
// This includes some information about the parent as well. Examples:
|
|
||||||
// Top-level channel: [Channel #channel-number]
|
|
||||||
// Nested channel: [Channel #parent-channel-number Channel #channel-number]
|
|
||||||
// Sub channel: [Channel #parent-channel SubChannel #subchannel-number]
|
|
||||||
func (id *Identifier) String() string {
|
|
||||||
return id.str
|
|
||||||
}
|
|
||||||
|
|
||||||
// Equal returns true if other is the same as id.
|
|
||||||
func (id *Identifier) Equal(other *Identifier) bool {
|
|
||||||
if (id != nil) != (other != nil) {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
if id == nil && other == nil {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return id.typ == other.typ && id.id == other.id && id.pid == other.pid
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewIdentifierForTesting returns a new opaque identifier to be used only for
|
|
||||||
// testing purposes.
|
|
||||||
func NewIdentifierForTesting(typ RefChannelType, id int64, pid *Identifier) *Identifier {
|
|
||||||
return newIdentifer(typ, id, pid)
|
|
||||||
}
|
|
||||||
|
|
||||||
func newIdentifer(typ RefChannelType, id int64, pid *Identifier) *Identifier {
|
|
||||||
str := fmt.Sprintf("%s #%d", typ, id)
|
|
||||||
if pid != nil {
|
|
||||||
str = fmt.Sprintf("%s %s", pid, str)
|
|
||||||
}
|
|
||||||
return &Identifier{typ: typ, id: id, str: str, pid: pid}
|
|
||||||
}
|
|
28
vendor/google.golang.org/grpc/internal/channelz/logging.go
generated
vendored
28
vendor/google.golang.org/grpc/internal/channelz/logging.go
generated
vendored
@ -26,53 +26,49 @@ import (
|
|||||||
|
|
||||||
var logger = grpclog.Component("channelz")
|
var logger = grpclog.Component("channelz")
|
||||||
|
|
||||||
func withParens(id *Identifier) string {
|
|
||||||
return "[" + id.String() + "] "
|
|
||||||
}
|
|
||||||
|
|
||||||
// Info logs and adds a trace event if channelz is on.
|
// Info logs and adds a trace event if channelz is on.
|
||||||
func Info(l grpclog.DepthLoggerV2, id *Identifier, args ...any) {
|
func Info(l grpclog.DepthLoggerV2, e Entity, args ...any) {
|
||||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
AddTraceEvent(l, e, 1, &TraceEvent{
|
||||||
Desc: fmt.Sprint(args...),
|
Desc: fmt.Sprint(args...),
|
||||||
Severity: CtInfo,
|
Severity: CtInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Infof logs and adds a trace event if channelz is on.
|
// Infof logs and adds a trace event if channelz is on.
|
||||||
func Infof(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...any) {
|
func Infof(l grpclog.DepthLoggerV2, e Entity, format string, args ...any) {
|
||||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
AddTraceEvent(l, e, 1, &TraceEvent{
|
||||||
Desc: fmt.Sprintf(format, args...),
|
Desc: fmt.Sprintf(format, args...),
|
||||||
Severity: CtInfo,
|
Severity: CtInfo,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warning logs and adds a trace event if channelz is on.
|
// Warning logs and adds a trace event if channelz is on.
|
||||||
func Warning(l grpclog.DepthLoggerV2, id *Identifier, args ...any) {
|
func Warning(l grpclog.DepthLoggerV2, e Entity, args ...any) {
|
||||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
AddTraceEvent(l, e, 1, &TraceEvent{
|
||||||
Desc: fmt.Sprint(args...),
|
Desc: fmt.Sprint(args...),
|
||||||
Severity: CtWarning,
|
Severity: CtWarning,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warningf logs and adds a trace event if channelz is on.
|
// Warningf logs and adds a trace event if channelz is on.
|
||||||
func Warningf(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...any) {
|
func Warningf(l grpclog.DepthLoggerV2, e Entity, format string, args ...any) {
|
||||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
AddTraceEvent(l, e, 1, &TraceEvent{
|
||||||
Desc: fmt.Sprintf(format, args...),
|
Desc: fmt.Sprintf(format, args...),
|
||||||
Severity: CtWarning,
|
Severity: CtWarning,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Error logs and adds a trace event if channelz is on.
|
// Error logs and adds a trace event if channelz is on.
|
||||||
func Error(l grpclog.DepthLoggerV2, id *Identifier, args ...any) {
|
func Error(l grpclog.DepthLoggerV2, e Entity, args ...any) {
|
||||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
AddTraceEvent(l, e, 1, &TraceEvent{
|
||||||
Desc: fmt.Sprint(args...),
|
Desc: fmt.Sprint(args...),
|
||||||
Severity: CtError,
|
Severity: CtError,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Errorf logs and adds a trace event if channelz is on.
|
// Errorf logs and adds a trace event if channelz is on.
|
||||||
func Errorf(l grpclog.DepthLoggerV2, id *Identifier, format string, args ...any) {
|
func Errorf(l grpclog.DepthLoggerV2, e Entity, format string, args ...any) {
|
||||||
AddTraceEvent(l, id, 1, &TraceEventDesc{
|
AddTraceEvent(l, e, 1, &TraceEvent{
|
||||||
Desc: fmt.Sprintf(format, args...),
|
Desc: fmt.Sprintf(format, args...),
|
||||||
Severity: CtError,
|
Severity: CtError,
|
||||||
})
|
})
|
||||||
|
119
vendor/google.golang.org/grpc/internal/channelz/server.go
generated
vendored
Normal file
119
vendor/google.golang.org/grpc/internal/channelz/server.go
generated
vendored
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package channelz
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sync/atomic"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Server is the channelz representation of a server.
|
||||||
|
type Server struct {
|
||||||
|
Entity
|
||||||
|
ID int64
|
||||||
|
RefName string
|
||||||
|
|
||||||
|
ServerMetrics ServerMetrics
|
||||||
|
|
||||||
|
closeCalled bool
|
||||||
|
sockets map[int64]string
|
||||||
|
listenSockets map[int64]string
|
||||||
|
cm *channelMap
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerMetrics defines a struct containing metrics for servers.
|
||||||
|
type ServerMetrics struct {
|
||||||
|
// The number of incoming calls started on the server.
|
||||||
|
CallsStarted atomic.Int64
|
||||||
|
// The number of incoming calls that have completed with an OK status.
|
||||||
|
CallsSucceeded atomic.Int64
|
||||||
|
// The number of incoming calls that have a completed with a non-OK status.
|
||||||
|
CallsFailed atomic.Int64
|
||||||
|
// The last time a call was started on the server.
|
||||||
|
LastCallStartedTimestamp atomic.Int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewServerMetricsForTesting returns an initialized ServerMetrics.
|
||||||
|
func NewServerMetricsForTesting(started, succeeded, failed, timestamp int64) *ServerMetrics {
|
||||||
|
sm := &ServerMetrics{}
|
||||||
|
sm.CallsStarted.Store(started)
|
||||||
|
sm.CallsSucceeded.Store(succeeded)
|
||||||
|
sm.CallsFailed.Store(failed)
|
||||||
|
sm.LastCallStartedTimestamp.Store(timestamp)
|
||||||
|
return sm
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sm *ServerMetrics) CopyFrom(o *ServerMetrics) {
|
||||||
|
sm.CallsStarted.Store(o.CallsStarted.Load())
|
||||||
|
sm.CallsSucceeded.Store(o.CallsSucceeded.Load())
|
||||||
|
sm.CallsFailed.Store(o.CallsFailed.Load())
|
||||||
|
sm.LastCallStartedTimestamp.Store(o.LastCallStartedTimestamp.Load())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListenSockets returns the listening sockets for s.
|
||||||
|
func (s *Server) ListenSockets() map[int64]string {
|
||||||
|
db.mu.RLock()
|
||||||
|
defer db.mu.RUnlock()
|
||||||
|
return copyMap(s.listenSockets)
|
||||||
|
}
|
||||||
|
|
||||||
|
// String returns a printable description of s.
|
||||||
|
func (s *Server) String() string {
|
||||||
|
return fmt.Sprintf("Server #%d", s.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) id() int64 {
|
||||||
|
return s.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) addChild(id int64, e entry) {
|
||||||
|
switch v := e.(type) {
|
||||||
|
case *Socket:
|
||||||
|
switch v.SocketType {
|
||||||
|
case SocketTypeNormal:
|
||||||
|
s.sockets[id] = v.RefName
|
||||||
|
case SocketTypeListen:
|
||||||
|
s.listenSockets[id] = v.RefName
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
logger.Errorf("cannot add a child (id = %d) of type %T to a server", id, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) deleteChild(id int64) {
|
||||||
|
delete(s.sockets, id)
|
||||||
|
delete(s.listenSockets, id)
|
||||||
|
s.deleteSelfIfReady()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) triggerDelete() {
|
||||||
|
s.closeCalled = true
|
||||||
|
s.deleteSelfIfReady()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) deleteSelfIfReady() {
|
||||||
|
if !s.closeCalled || len(s.sockets)+len(s.listenSockets) != 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
s.cm.deleteEntry(s.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Server) getParentID() int64 {
|
||||||
|
return 0
|
||||||
|
}
|
130
vendor/google.golang.org/grpc/internal/channelz/socket.go
generated
vendored
Normal file
130
vendor/google.golang.org/grpc/internal/channelz/socket.go
generated
vendored
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package channelz
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/credentials"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SocketMetrics defines the struct that the implementor of Socket interface
|
||||||
|
// should return from ChannelzMetric().
|
||||||
|
type SocketMetrics struct {
|
||||||
|
// The number of streams that have been started.
|
||||||
|
StreamsStarted atomic.Int64
|
||||||
|
// The number of streams that have ended successfully:
|
||||||
|
// On client side, receiving frame with eos bit set.
|
||||||
|
// On server side, sending frame with eos bit set.
|
||||||
|
StreamsSucceeded atomic.Int64
|
||||||
|
// The number of streams that have ended unsuccessfully:
|
||||||
|
// On client side, termination without receiving frame with eos bit set.
|
||||||
|
// On server side, termination without sending frame with eos bit set.
|
||||||
|
StreamsFailed atomic.Int64
|
||||||
|
// The number of messages successfully sent on this socket.
|
||||||
|
MessagesSent atomic.Int64
|
||||||
|
MessagesReceived atomic.Int64
|
||||||
|
// The number of keep alives sent. This is typically implemented with HTTP/2
|
||||||
|
// ping messages.
|
||||||
|
KeepAlivesSent atomic.Int64
|
||||||
|
// The last time a stream was created by this endpoint. Usually unset for
|
||||||
|
// servers.
|
||||||
|
LastLocalStreamCreatedTimestamp atomic.Int64
|
||||||
|
// The last time a stream was created by the remote endpoint. Usually unset
|
||||||
|
// for clients.
|
||||||
|
LastRemoteStreamCreatedTimestamp atomic.Int64
|
||||||
|
// The last time a message was sent by this endpoint.
|
||||||
|
LastMessageSentTimestamp atomic.Int64
|
||||||
|
// The last time a message was received by this endpoint.
|
||||||
|
LastMessageReceivedTimestamp atomic.Int64
|
||||||
|
}
|
||||||
|
|
||||||
|
// EphemeralSocketMetrics are metrics that change rapidly and are tracked
|
||||||
|
// outside of channelz.
|
||||||
|
type EphemeralSocketMetrics struct {
|
||||||
|
// The amount of window, granted to the local endpoint by the remote endpoint.
|
||||||
|
// This may be slightly out of date due to network latency. This does NOT
|
||||||
|
// include stream level or TCP level flow control info.
|
||||||
|
LocalFlowControlWindow int64
|
||||||
|
// The amount of window, granted to the remote endpoint by the local endpoint.
|
||||||
|
// This may be slightly out of date due to network latency. This does NOT
|
||||||
|
// include stream level or TCP level flow control info.
|
||||||
|
RemoteFlowControlWindow int64
|
||||||
|
}
|
||||||
|
|
||||||
|
type SocketType string
|
||||||
|
|
||||||
|
const (
|
||||||
|
SocketTypeNormal = "NormalSocket"
|
||||||
|
SocketTypeListen = "ListenSocket"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Socket struct {
|
||||||
|
Entity
|
||||||
|
SocketType SocketType
|
||||||
|
ID int64
|
||||||
|
Parent Entity
|
||||||
|
cm *channelMap
|
||||||
|
SocketMetrics SocketMetrics
|
||||||
|
EphemeralMetrics func() *EphemeralSocketMetrics
|
||||||
|
|
||||||
|
RefName string
|
||||||
|
// The locally bound address. Immutable.
|
||||||
|
LocalAddr net.Addr
|
||||||
|
// The remote bound address. May be absent. Immutable.
|
||||||
|
RemoteAddr net.Addr
|
||||||
|
// Optional, represents the name of the remote endpoint, if different than
|
||||||
|
// the original target name. Immutable.
|
||||||
|
RemoteName string
|
||||||
|
// Immutable.
|
||||||
|
SocketOptions *SocketOptionData
|
||||||
|
// Immutable.
|
||||||
|
Security credentials.ChannelzSecurityValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *Socket) String() string {
|
||||||
|
return fmt.Sprintf("%s %s #%d", ls.Parent, ls.SocketType, ls.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *Socket) id() int64 {
|
||||||
|
return ls.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *Socket) addChild(id int64, e entry) {
|
||||||
|
logger.Errorf("cannot add a child (id = %d) of type %T to a listen socket", id, e)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *Socket) deleteChild(id int64) {
|
||||||
|
logger.Errorf("cannot delete a child (id = %d) from a listen socket", id)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *Socket) triggerDelete() {
|
||||||
|
ls.cm.deleteEntry(ls.ID)
|
||||||
|
ls.Parent.(entry).deleteChild(ls.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *Socket) deleteSelfIfReady() {
|
||||||
|
logger.Errorf("cannot call deleteSelfIfReady on a listen socket")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (ls *Socket) getParentID() int64 {
|
||||||
|
return ls.Parent.id()
|
||||||
|
}
|
151
vendor/google.golang.org/grpc/internal/channelz/subchannel.go
generated
vendored
Normal file
151
vendor/google.golang.org/grpc/internal/channelz/subchannel.go
generated
vendored
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package channelz
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sync/atomic"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SubChannel is the channelz representation of a subchannel.
|
||||||
|
type SubChannel struct {
|
||||||
|
Entity
|
||||||
|
// ID is the channelz id of this subchannel.
|
||||||
|
ID int64
|
||||||
|
// RefName is the human readable reference string of this subchannel.
|
||||||
|
RefName string
|
||||||
|
closeCalled bool
|
||||||
|
sockets map[int64]string
|
||||||
|
parent *Channel
|
||||||
|
trace *ChannelTrace
|
||||||
|
traceRefCount int32
|
||||||
|
|
||||||
|
ChannelMetrics ChannelMetrics
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) String() string {
|
||||||
|
return fmt.Sprintf("%s SubChannel #%d", sc.parent, sc.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) id() int64 {
|
||||||
|
return sc.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) Sockets() map[int64]string {
|
||||||
|
db.mu.RLock()
|
||||||
|
defer db.mu.RUnlock()
|
||||||
|
return copyMap(sc.sockets)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) Trace() *ChannelTrace {
|
||||||
|
db.mu.RLock()
|
||||||
|
defer db.mu.RUnlock()
|
||||||
|
return sc.trace.copy()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) addChild(id int64, e entry) {
|
||||||
|
if v, ok := e.(*Socket); ok && v.SocketType == SocketTypeNormal {
|
||||||
|
sc.sockets[id] = v.RefName
|
||||||
|
} else {
|
||||||
|
logger.Errorf("cannot add a child (id = %d) of type %T to a subChannel", id, e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) deleteChild(id int64) {
|
||||||
|
delete(sc.sockets, id)
|
||||||
|
sc.deleteSelfIfReady()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) triggerDelete() {
|
||||||
|
sc.closeCalled = true
|
||||||
|
sc.deleteSelfIfReady()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) getParentID() int64 {
|
||||||
|
return sc.parent.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteSelfFromTree tries to delete the subchannel from the channelz entry relation tree, which
|
||||||
|
// means deleting the subchannel reference from its parent's child list.
|
||||||
|
//
|
||||||
|
// In order for a subchannel to be deleted from the tree, it must meet the criteria that, removal of
|
||||||
|
// the corresponding grpc object has been invoked, and the subchannel does not have any children left.
|
||||||
|
//
|
||||||
|
// The returned boolean value indicates whether the channel has been successfully deleted from tree.
|
||||||
|
func (sc *SubChannel) deleteSelfFromTree() (deleted bool) {
|
||||||
|
if !sc.closeCalled || len(sc.sockets) != 0 {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
sc.parent.deleteChild(sc.ID)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteSelfFromMap checks whether it is valid to delete the subchannel from the map, which means
|
||||||
|
// deleting the subchannel from channelz's tracking entirely. Users can no longer use id to query
|
||||||
|
// the subchannel, and its memory will be garbage collected.
|
||||||
|
//
|
||||||
|
// The trace reference count of the subchannel must be 0 in order to be deleted from the map. This is
|
||||||
|
// specified in the channel tracing gRFC that as long as some other trace has reference to an entity,
|
||||||
|
// the trace of the referenced entity must not be deleted. In order to release the resource allocated
|
||||||
|
// by grpc, the reference to the grpc object is reset to a dummy object.
|
||||||
|
//
|
||||||
|
// deleteSelfFromMap must be called after deleteSelfFromTree returns true.
|
||||||
|
//
|
||||||
|
// It returns a bool to indicate whether the channel can be safely deleted from map.
|
||||||
|
func (sc *SubChannel) deleteSelfFromMap() (delete bool) {
|
||||||
|
return sc.getTraceRefCount() == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// deleteSelfIfReady tries to delete the subchannel itself from the channelz database.
|
||||||
|
// The delete process includes two steps:
|
||||||
|
// 1. delete the subchannel from the entry relation tree, i.e. delete the subchannel reference from
|
||||||
|
// its parent's child list.
|
||||||
|
// 2. delete the subchannel from the map, i.e. delete the subchannel entirely from channelz. Lookup
|
||||||
|
// by id will return entry not found error.
|
||||||
|
func (sc *SubChannel) deleteSelfIfReady() {
|
||||||
|
if !sc.deleteSelfFromTree() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !sc.deleteSelfFromMap() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
db.deleteEntry(sc.ID)
|
||||||
|
sc.trace.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) getChannelTrace() *ChannelTrace {
|
||||||
|
return sc.trace
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) incrTraceRefCount() {
|
||||||
|
atomic.AddInt32(&sc.traceRefCount, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) decrTraceRefCount() {
|
||||||
|
atomic.AddInt32(&sc.traceRefCount, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) getTraceRefCount() int {
|
||||||
|
i := atomic.LoadInt32(&sc.traceRefCount)
|
||||||
|
return int(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (sc *SubChannel) getRefName() string {
|
||||||
|
return sc.RefName
|
||||||
|
}
|
@ -49,3 +49,17 @@ func (s *SocketOptionData) Getsockopt(fd uintptr) {
|
|||||||
s.TCPInfo = v
|
s.TCPInfo = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetSocketOption gets the socket option info of the conn.
|
||||||
|
func GetSocketOption(socket any) *SocketOptionData {
|
||||||
|
c, ok := socket.(syscall.Conn)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
data := &SocketOptionData{}
|
||||||
|
if rawConn, err := c.SyscallConn(); err == nil {
|
||||||
|
rawConn.Control(data.Getsockopt)
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
@ -1,5 +1,4 @@
|
|||||||
//go:build !linux
|
//go:build !linux
|
||||||
// +build !linux
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
@ -41,3 +40,8 @@ func (s *SocketOptionData) Getsockopt(fd uintptr) {
|
|||||||
logger.Warning("Channelz: socket options are not supported on non-linux environments")
|
logger.Warning("Channelz: socket options are not supported on non-linux environments")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetSocketOption gets the socket option info of the conn.
|
||||||
|
func GetSocketOption(c any) *SocketOptionData {
|
||||||
|
return nil
|
||||||
|
}
|
204
vendor/google.golang.org/grpc/internal/channelz/trace.go
generated
vendored
Normal file
204
vendor/google.golang.org/grpc/internal/channelz/trace.go
generated
vendored
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2018 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package channelz
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"sync"
|
||||||
|
"sync/atomic"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/grpclog"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
defaultMaxTraceEntry int32 = 30
|
||||||
|
)
|
||||||
|
|
||||||
|
var maxTraceEntry = defaultMaxTraceEntry
|
||||||
|
|
||||||
|
// SetMaxTraceEntry sets maximum number of trace entries per entity (i.e.
|
||||||
|
// channel/subchannel). Setting it to 0 will disable channel tracing.
|
||||||
|
func SetMaxTraceEntry(i int32) {
|
||||||
|
atomic.StoreInt32(&maxTraceEntry, i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResetMaxTraceEntryToDefault resets the maximum number of trace entries per
|
||||||
|
// entity to default.
|
||||||
|
func ResetMaxTraceEntryToDefault() {
|
||||||
|
atomic.StoreInt32(&maxTraceEntry, defaultMaxTraceEntry)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMaxTraceEntry() int {
|
||||||
|
i := atomic.LoadInt32(&maxTraceEntry)
|
||||||
|
return int(i)
|
||||||
|
}
|
||||||
|
|
||||||
|
// traceEvent is an internal representation of a single trace event
|
||||||
|
type traceEvent struct {
|
||||||
|
// Desc is a simple description of the trace event.
|
||||||
|
Desc string
|
||||||
|
// Severity states the severity of this trace event.
|
||||||
|
Severity Severity
|
||||||
|
// Timestamp is the event time.
|
||||||
|
Timestamp time.Time
|
||||||
|
// RefID is the id of the entity that gets referenced in the event. RefID is 0 if no other entity is
|
||||||
|
// involved in this event.
|
||||||
|
// e.g. SubChannel (id: 4[]) Created. --> RefID = 4, RefName = "" (inside [])
|
||||||
|
RefID int64
|
||||||
|
// RefName is the reference name for the entity that gets referenced in the event.
|
||||||
|
RefName string
|
||||||
|
// RefType indicates the referenced entity type, i.e Channel or SubChannel.
|
||||||
|
RefType RefChannelType
|
||||||
|
}
|
||||||
|
|
||||||
|
// TraceEvent is what the caller of AddTraceEvent should provide to describe the
|
||||||
|
// event to be added to the channel trace.
|
||||||
|
//
|
||||||
|
// The Parent field is optional. It is used for an event that will be recorded
|
||||||
|
// in the entity's parent trace.
|
||||||
|
type TraceEvent struct {
|
||||||
|
Desc string
|
||||||
|
Severity Severity
|
||||||
|
Parent *TraceEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
type ChannelTrace struct {
|
||||||
|
cm *channelMap
|
||||||
|
clearCalled bool
|
||||||
|
CreationTime time.Time
|
||||||
|
EventNum int64
|
||||||
|
mu sync.Mutex
|
||||||
|
Events []*traceEvent
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ChannelTrace) copy() *ChannelTrace {
|
||||||
|
return &ChannelTrace{
|
||||||
|
CreationTime: c.CreationTime,
|
||||||
|
EventNum: c.EventNum,
|
||||||
|
Events: append(([]*traceEvent)(nil), c.Events...),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ChannelTrace) append(e *traceEvent) {
|
||||||
|
c.mu.Lock()
|
||||||
|
if len(c.Events) == getMaxTraceEntry() {
|
||||||
|
del := c.Events[0]
|
||||||
|
c.Events = c.Events[1:]
|
||||||
|
if del.RefID != 0 {
|
||||||
|
// start recursive cleanup in a goroutine to not block the call originated from grpc.
|
||||||
|
go func() {
|
||||||
|
// need to acquire c.cm.mu lock to call the unlocked attemptCleanup func.
|
||||||
|
c.cm.mu.Lock()
|
||||||
|
c.cm.decrTraceRefCount(del.RefID)
|
||||||
|
c.cm.mu.Unlock()
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
e.Timestamp = time.Now()
|
||||||
|
c.Events = append(c.Events, e)
|
||||||
|
c.EventNum++
|
||||||
|
c.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *ChannelTrace) clear() {
|
||||||
|
if c.clearCalled {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.clearCalled = true
|
||||||
|
c.mu.Lock()
|
||||||
|
for _, e := range c.Events {
|
||||||
|
if e.RefID != 0 {
|
||||||
|
// caller should have already held the c.cm.mu lock.
|
||||||
|
c.cm.decrTraceRefCount(e.RefID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.mu.Unlock()
|
||||||
|
}
|
||||||
|
|
||||||
|
// Severity is the severity level of a trace event.
|
||||||
|
// The canonical enumeration of all valid values is here:
|
||||||
|
// https://github.com/grpc/grpc-proto/blob/9b13d199cc0d4703c7ea26c9c330ba695866eb23/grpc/channelz/v1/channelz.proto#L126.
|
||||||
|
type Severity int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// CtUnknown indicates unknown severity of a trace event.
|
||||||
|
CtUnknown Severity = iota
|
||||||
|
// CtInfo indicates info level severity of a trace event.
|
||||||
|
CtInfo
|
||||||
|
// CtWarning indicates warning level severity of a trace event.
|
||||||
|
CtWarning
|
||||||
|
// CtError indicates error level severity of a trace event.
|
||||||
|
CtError
|
||||||
|
)
|
||||||
|
|
||||||
|
// RefChannelType is the type of the entity being referenced in a trace event.
|
||||||
|
type RefChannelType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
// RefUnknown indicates an unknown entity type, the zero value for this type.
|
||||||
|
RefUnknown RefChannelType = iota
|
||||||
|
// RefChannel indicates the referenced entity is a Channel.
|
||||||
|
RefChannel
|
||||||
|
// RefSubChannel indicates the referenced entity is a SubChannel.
|
||||||
|
RefSubChannel
|
||||||
|
// RefServer indicates the referenced entity is a Server.
|
||||||
|
RefServer
|
||||||
|
// RefListenSocket indicates the referenced entity is a ListenSocket.
|
||||||
|
RefListenSocket
|
||||||
|
// RefNormalSocket indicates the referenced entity is a NormalSocket.
|
||||||
|
RefNormalSocket
|
||||||
|
)
|
||||||
|
|
||||||
|
var refChannelTypeToString = map[RefChannelType]string{
|
||||||
|
RefUnknown: "Unknown",
|
||||||
|
RefChannel: "Channel",
|
||||||
|
RefSubChannel: "SubChannel",
|
||||||
|
RefServer: "Server",
|
||||||
|
RefListenSocket: "ListenSocket",
|
||||||
|
RefNormalSocket: "NormalSocket",
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r RefChannelType) String() string {
|
||||||
|
return refChannelTypeToString[r]
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddTraceEvent adds trace related to the entity with specified id, using the
|
||||||
|
// provided TraceEventDesc.
|
||||||
|
//
|
||||||
|
// If channelz is not turned ON, this will simply log the event descriptions.
|
||||||
|
func AddTraceEvent(l grpclog.DepthLoggerV2, e Entity, depth int, desc *TraceEvent) {
|
||||||
|
// Log only the trace description associated with the bottom most entity.
|
||||||
|
d := fmt.Sprintf("[%s]%s", e, desc.Desc)
|
||||||
|
switch desc.Severity {
|
||||||
|
case CtUnknown, CtInfo:
|
||||||
|
l.InfoDepth(depth+1, d)
|
||||||
|
case CtWarning:
|
||||||
|
l.WarningDepth(depth+1, d)
|
||||||
|
case CtError:
|
||||||
|
l.ErrorDepth(depth+1, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
if getMaxTraceEntry() == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if IsOn() {
|
||||||
|
db.traceEvent(e.id(), desc)
|
||||||
|
}
|
||||||
|
}
|
727
vendor/google.golang.org/grpc/internal/channelz/types.go
generated
vendored
727
vendor/google.golang.org/grpc/internal/channelz/types.go
generated
vendored
@ -1,727 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2018 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package channelz
|
|
||||||
|
|
||||||
import (
|
|
||||||
"net"
|
|
||||||
"sync"
|
|
||||||
"sync/atomic"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"google.golang.org/grpc/connectivity"
|
|
||||||
"google.golang.org/grpc/credentials"
|
|
||||||
)
|
|
||||||
|
|
||||||
// entry represents a node in the channelz database.
|
|
||||||
type entry interface {
|
|
||||||
// addChild adds a child e, whose channelz id is id to child list
|
|
||||||
addChild(id int64, e entry)
|
|
||||||
// deleteChild deletes a child with channelz id to be id from child list
|
|
||||||
deleteChild(id int64)
|
|
||||||
// triggerDelete tries to delete self from channelz database. However, if child
|
|
||||||
// list is not empty, then deletion from the database is on hold until the last
|
|
||||||
// child is deleted from database.
|
|
||||||
triggerDelete()
|
|
||||||
// deleteSelfIfReady check whether triggerDelete() has been called before, and whether child
|
|
||||||
// list is now empty. If both conditions are met, then delete self from database.
|
|
||||||
deleteSelfIfReady()
|
|
||||||
// getParentID returns parent ID of the entry. 0 value parent ID means no parent.
|
|
||||||
getParentID() int64
|
|
||||||
}
|
|
||||||
|
|
||||||
// dummyEntry is a fake entry to handle entry not found case.
|
|
||||||
type dummyEntry struct {
|
|
||||||
idNotFound int64
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *dummyEntry) addChild(id int64, e entry) {
|
|
||||||
// Note: It is possible for a normal program to reach here under race condition.
|
|
||||||
// For example, there could be a race between ClientConn.Close() info being propagated
|
|
||||||
// to addrConn and http2Client. ClientConn.Close() cancel the context and result
|
|
||||||
// in http2Client to error. The error info is then caught by transport monitor
|
|
||||||
// and before addrConn.tearDown() is called in side ClientConn.Close(). Therefore,
|
|
||||||
// the addrConn will create a new transport. And when registering the new transport in
|
|
||||||
// channelz, its parent addrConn could have already been torn down and deleted
|
|
||||||
// from channelz tracking, and thus reach the code here.
|
|
||||||
logger.Infof("attempt to add child of type %T with id %d to a parent (id=%d) that doesn't currently exist", e, id, d.idNotFound)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *dummyEntry) deleteChild(id int64) {
|
|
||||||
// It is possible for a normal program to reach here under race condition.
|
|
||||||
// Refer to the example described in addChild().
|
|
||||||
logger.Infof("attempt to delete child with id %d from a parent (id=%d) that doesn't currently exist", id, d.idNotFound)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (d *dummyEntry) triggerDelete() {
|
|
||||||
logger.Warningf("attempt to delete an entry (id=%d) that doesn't currently exist", d.idNotFound)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*dummyEntry) deleteSelfIfReady() {
|
|
||||||
// code should not reach here. deleteSelfIfReady is always called on an existing entry.
|
|
||||||
}
|
|
||||||
|
|
||||||
func (*dummyEntry) getParentID() int64 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChannelMetric defines the info channelz provides for a specific Channel, which
|
|
||||||
// includes ChannelInternalMetric and channelz-specific data, such as channelz id,
|
|
||||||
// child list, etc.
|
|
||||||
type ChannelMetric struct {
|
|
||||||
// ID is the channelz id of this channel.
|
|
||||||
ID int64
|
|
||||||
// RefName is the human readable reference string of this channel.
|
|
||||||
RefName string
|
|
||||||
// ChannelData contains channel internal metric reported by the channel through
|
|
||||||
// ChannelzMetric().
|
|
||||||
ChannelData *ChannelInternalMetric
|
|
||||||
// NestedChans tracks the nested channel type children of this channel in the format of
|
|
||||||
// a map from nested channel channelz id to corresponding reference string.
|
|
||||||
NestedChans map[int64]string
|
|
||||||
// SubChans tracks the subchannel type children of this channel in the format of a
|
|
||||||
// map from subchannel channelz id to corresponding reference string.
|
|
||||||
SubChans map[int64]string
|
|
||||||
// Sockets tracks the socket type children of this channel in the format of a map
|
|
||||||
// from socket channelz id to corresponding reference string.
|
|
||||||
// Note current grpc implementation doesn't allow channel having sockets directly,
|
|
||||||
// therefore, this is field is unused.
|
|
||||||
Sockets map[int64]string
|
|
||||||
// Trace contains the most recent traced events.
|
|
||||||
Trace *ChannelTrace
|
|
||||||
}
|
|
||||||
|
|
||||||
// SubChannelMetric defines the info channelz provides for a specific SubChannel,
|
|
||||||
// which includes ChannelInternalMetric and channelz-specific data, such as
|
|
||||||
// channelz id, child list, etc.
|
|
||||||
type SubChannelMetric struct {
|
|
||||||
// ID is the channelz id of this subchannel.
|
|
||||||
ID int64
|
|
||||||
// RefName is the human readable reference string of this subchannel.
|
|
||||||
RefName string
|
|
||||||
// ChannelData contains subchannel internal metric reported by the subchannel
|
|
||||||
// through ChannelzMetric().
|
|
||||||
ChannelData *ChannelInternalMetric
|
|
||||||
// NestedChans tracks the nested channel type children of this subchannel in the format of
|
|
||||||
// a map from nested channel channelz id to corresponding reference string.
|
|
||||||
// Note current grpc implementation doesn't allow subchannel to have nested channels
|
|
||||||
// as children, therefore, this field is unused.
|
|
||||||
NestedChans map[int64]string
|
|
||||||
// SubChans tracks the subchannel type children of this subchannel in the format of a
|
|
||||||
// map from subchannel channelz id to corresponding reference string.
|
|
||||||
// Note current grpc implementation doesn't allow subchannel to have subchannels
|
|
||||||
// as children, therefore, this field is unused.
|
|
||||||
SubChans map[int64]string
|
|
||||||
// Sockets tracks the socket type children of this subchannel in the format of a map
|
|
||||||
// from socket channelz id to corresponding reference string.
|
|
||||||
Sockets map[int64]string
|
|
||||||
// Trace contains the most recent traced events.
|
|
||||||
Trace *ChannelTrace
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChannelInternalMetric defines the struct that the implementor of Channel interface
|
|
||||||
// should return from ChannelzMetric().
|
|
||||||
type ChannelInternalMetric struct {
|
|
||||||
// current connectivity state of the channel.
|
|
||||||
State connectivity.State
|
|
||||||
// The target this channel originally tried to connect to. May be absent
|
|
||||||
Target string
|
|
||||||
// The number of calls started on the channel.
|
|
||||||
CallsStarted int64
|
|
||||||
// The number of calls that have completed with an OK status.
|
|
||||||
CallsSucceeded int64
|
|
||||||
// The number of calls that have a completed with a non-OK status.
|
|
||||||
CallsFailed int64
|
|
||||||
// The last time a call was started on the channel.
|
|
||||||
LastCallStartedTimestamp time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
// ChannelTrace stores traced events on a channel/subchannel and related info.
|
|
||||||
type ChannelTrace struct {
|
|
||||||
// EventNum is the number of events that ever got traced (i.e. including those that have been deleted)
|
|
||||||
EventNum int64
|
|
||||||
// CreationTime is the creation time of the trace.
|
|
||||||
CreationTime time.Time
|
|
||||||
// Events stores the most recent trace events (up to $maxTraceEntry, newer event will overwrite the
|
|
||||||
// oldest one)
|
|
||||||
Events []*TraceEvent
|
|
||||||
}
|
|
||||||
|
|
||||||
// TraceEvent represent a single trace event
|
|
||||||
type TraceEvent struct {
|
|
||||||
// Desc is a simple description of the trace event.
|
|
||||||
Desc string
|
|
||||||
// Severity states the severity of this trace event.
|
|
||||||
Severity Severity
|
|
||||||
// Timestamp is the event time.
|
|
||||||
Timestamp time.Time
|
|
||||||
// RefID is the id of the entity that gets referenced in the event. RefID is 0 if no other entity is
|
|
||||||
// involved in this event.
|
|
||||||
// e.g. SubChannel (id: 4[]) Created. --> RefID = 4, RefName = "" (inside [])
|
|
||||||
RefID int64
|
|
||||||
// RefName is the reference name for the entity that gets referenced in the event.
|
|
||||||
RefName string
|
|
||||||
// RefType indicates the referenced entity type, i.e Channel or SubChannel.
|
|
||||||
RefType RefChannelType
|
|
||||||
}
|
|
||||||
|
|
||||||
// Channel is the interface that should be satisfied in order to be tracked by
|
|
||||||
// channelz as Channel or SubChannel.
|
|
||||||
type Channel interface {
|
|
||||||
ChannelzMetric() *ChannelInternalMetric
|
|
||||||
}
|
|
||||||
|
|
||||||
type dummyChannel struct{}
|
|
||||||
|
|
||||||
func (d *dummyChannel) ChannelzMetric() *ChannelInternalMetric {
|
|
||||||
return &ChannelInternalMetric{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type channel struct {
|
|
||||||
refName string
|
|
||||||
c Channel
|
|
||||||
closeCalled bool
|
|
||||||
nestedChans map[int64]string
|
|
||||||
subChans map[int64]string
|
|
||||||
id int64
|
|
||||||
pid int64
|
|
||||||
cm *channelMap
|
|
||||||
trace *channelTrace
|
|
||||||
// traceRefCount is the number of trace events that reference this channel.
|
|
||||||
// Non-zero traceRefCount means the trace of this channel cannot be deleted.
|
|
||||||
traceRefCount int32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) addChild(id int64, e entry) {
|
|
||||||
switch v := e.(type) {
|
|
||||||
case *subChannel:
|
|
||||||
c.subChans[id] = v.refName
|
|
||||||
case *channel:
|
|
||||||
c.nestedChans[id] = v.refName
|
|
||||||
default:
|
|
||||||
logger.Errorf("cannot add a child (id = %d) of type %T to a channel", id, e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) deleteChild(id int64) {
|
|
||||||
delete(c.subChans, id)
|
|
||||||
delete(c.nestedChans, id)
|
|
||||||
c.deleteSelfIfReady()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) triggerDelete() {
|
|
||||||
c.closeCalled = true
|
|
||||||
c.deleteSelfIfReady()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) getParentID() int64 {
|
|
||||||
return c.pid
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteSelfFromTree tries to delete the channel from the channelz entry relation tree, which means
|
|
||||||
// deleting the channel reference from its parent's child list.
|
|
||||||
//
|
|
||||||
// In order for a channel to be deleted from the tree, it must meet the criteria that, removal of the
|
|
||||||
// corresponding grpc object has been invoked, and the channel does not have any children left.
|
|
||||||
//
|
|
||||||
// The returned boolean value indicates whether the channel has been successfully deleted from tree.
|
|
||||||
func (c *channel) deleteSelfFromTree() (deleted bool) {
|
|
||||||
if !c.closeCalled || len(c.subChans)+len(c.nestedChans) != 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
// not top channel
|
|
||||||
if c.pid != 0 {
|
|
||||||
c.cm.findEntry(c.pid).deleteChild(c.id)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteSelfFromMap checks whether it is valid to delete the channel from the map, which means
|
|
||||||
// deleting the channel from channelz's tracking entirely. Users can no longer use id to query the
|
|
||||||
// channel, and its memory will be garbage collected.
|
|
||||||
//
|
|
||||||
// The trace reference count of the channel must be 0 in order to be deleted from the map. This is
|
|
||||||
// specified in the channel tracing gRFC that as long as some other trace has reference to an entity,
|
|
||||||
// the trace of the referenced entity must not be deleted. In order to release the resource allocated
|
|
||||||
// by grpc, the reference to the grpc object is reset to a dummy object.
|
|
||||||
//
|
|
||||||
// deleteSelfFromMap must be called after deleteSelfFromTree returns true.
|
|
||||||
//
|
|
||||||
// It returns a bool to indicate whether the channel can be safely deleted from map.
|
|
||||||
func (c *channel) deleteSelfFromMap() (delete bool) {
|
|
||||||
if c.getTraceRefCount() != 0 {
|
|
||||||
c.c = &dummyChannel{}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteSelfIfReady tries to delete the channel itself from the channelz database.
|
|
||||||
// The delete process includes two steps:
|
|
||||||
// 1. delete the channel from the entry relation tree, i.e. delete the channel reference from its
|
|
||||||
// parent's child list.
|
|
||||||
// 2. delete the channel from the map, i.e. delete the channel entirely from channelz. Lookup by id
|
|
||||||
// will return entry not found error.
|
|
||||||
func (c *channel) deleteSelfIfReady() {
|
|
||||||
if !c.deleteSelfFromTree() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !c.deleteSelfFromMap() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.cm.deleteEntry(c.id)
|
|
||||||
c.trace.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) getChannelTrace() *channelTrace {
|
|
||||||
return c.trace
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) incrTraceRefCount() {
|
|
||||||
atomic.AddInt32(&c.traceRefCount, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) decrTraceRefCount() {
|
|
||||||
atomic.AddInt32(&c.traceRefCount, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) getTraceRefCount() int {
|
|
||||||
i := atomic.LoadInt32(&c.traceRefCount)
|
|
||||||
return int(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channel) getRefName() string {
|
|
||||||
return c.refName
|
|
||||||
}
|
|
||||||
|
|
||||||
type subChannel struct {
|
|
||||||
refName string
|
|
||||||
c Channel
|
|
||||||
closeCalled bool
|
|
||||||
sockets map[int64]string
|
|
||||||
id int64
|
|
||||||
pid int64
|
|
||||||
cm *channelMap
|
|
||||||
trace *channelTrace
|
|
||||||
traceRefCount int32
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) addChild(id int64, e entry) {
|
|
||||||
if v, ok := e.(*normalSocket); ok {
|
|
||||||
sc.sockets[id] = v.refName
|
|
||||||
} else {
|
|
||||||
logger.Errorf("cannot add a child (id = %d) of type %T to a subChannel", id, e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) deleteChild(id int64) {
|
|
||||||
delete(sc.sockets, id)
|
|
||||||
sc.deleteSelfIfReady()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) triggerDelete() {
|
|
||||||
sc.closeCalled = true
|
|
||||||
sc.deleteSelfIfReady()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) getParentID() int64 {
|
|
||||||
return sc.pid
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteSelfFromTree tries to delete the subchannel from the channelz entry relation tree, which
|
|
||||||
// means deleting the subchannel reference from its parent's child list.
|
|
||||||
//
|
|
||||||
// In order for a subchannel to be deleted from the tree, it must meet the criteria that, removal of
|
|
||||||
// the corresponding grpc object has been invoked, and the subchannel does not have any children left.
|
|
||||||
//
|
|
||||||
// The returned boolean value indicates whether the channel has been successfully deleted from tree.
|
|
||||||
func (sc *subChannel) deleteSelfFromTree() (deleted bool) {
|
|
||||||
if !sc.closeCalled || len(sc.sockets) != 0 {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
sc.cm.findEntry(sc.pid).deleteChild(sc.id)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteSelfFromMap checks whether it is valid to delete the subchannel from the map, which means
|
|
||||||
// deleting the subchannel from channelz's tracking entirely. Users can no longer use id to query
|
|
||||||
// the subchannel, and its memory will be garbage collected.
|
|
||||||
//
|
|
||||||
// The trace reference count of the subchannel must be 0 in order to be deleted from the map. This is
|
|
||||||
// specified in the channel tracing gRFC that as long as some other trace has reference to an entity,
|
|
||||||
// the trace of the referenced entity must not be deleted. In order to release the resource allocated
|
|
||||||
// by grpc, the reference to the grpc object is reset to a dummy object.
|
|
||||||
//
|
|
||||||
// deleteSelfFromMap must be called after deleteSelfFromTree returns true.
|
|
||||||
//
|
|
||||||
// It returns a bool to indicate whether the channel can be safely deleted from map.
|
|
||||||
func (sc *subChannel) deleteSelfFromMap() (delete bool) {
|
|
||||||
if sc.getTraceRefCount() != 0 {
|
|
||||||
// free the grpc struct (i.e. addrConn)
|
|
||||||
sc.c = &dummyChannel{}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// deleteSelfIfReady tries to delete the subchannel itself from the channelz database.
|
|
||||||
// The delete process includes two steps:
|
|
||||||
// 1. delete the subchannel from the entry relation tree, i.e. delete the subchannel reference from
|
|
||||||
// its parent's child list.
|
|
||||||
// 2. delete the subchannel from the map, i.e. delete the subchannel entirely from channelz. Lookup
|
|
||||||
// by id will return entry not found error.
|
|
||||||
func (sc *subChannel) deleteSelfIfReady() {
|
|
||||||
if !sc.deleteSelfFromTree() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if !sc.deleteSelfFromMap() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
sc.cm.deleteEntry(sc.id)
|
|
||||||
sc.trace.clear()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) getChannelTrace() *channelTrace {
|
|
||||||
return sc.trace
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) incrTraceRefCount() {
|
|
||||||
atomic.AddInt32(&sc.traceRefCount, 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) decrTraceRefCount() {
|
|
||||||
atomic.AddInt32(&sc.traceRefCount, -1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) getTraceRefCount() int {
|
|
||||||
i := atomic.LoadInt32(&sc.traceRefCount)
|
|
||||||
return int(i)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sc *subChannel) getRefName() string {
|
|
||||||
return sc.refName
|
|
||||||
}
|
|
||||||
|
|
||||||
// SocketMetric defines the info channelz provides for a specific Socket, which
|
|
||||||
// includes SocketInternalMetric and channelz-specific data, such as channelz id, etc.
|
|
||||||
type SocketMetric struct {
|
|
||||||
// ID is the channelz id of this socket.
|
|
||||||
ID int64
|
|
||||||
// RefName is the human readable reference string of this socket.
|
|
||||||
RefName string
|
|
||||||
// SocketData contains socket internal metric reported by the socket through
|
|
||||||
// ChannelzMetric().
|
|
||||||
SocketData *SocketInternalMetric
|
|
||||||
}
|
|
||||||
|
|
||||||
// SocketInternalMetric defines the struct that the implementor of Socket interface
|
|
||||||
// should return from ChannelzMetric().
|
|
||||||
type SocketInternalMetric struct {
|
|
||||||
// The number of streams that have been started.
|
|
||||||
StreamsStarted int64
|
|
||||||
// The number of streams that have ended successfully:
|
|
||||||
// On client side, receiving frame with eos bit set.
|
|
||||||
// On server side, sending frame with eos bit set.
|
|
||||||
StreamsSucceeded int64
|
|
||||||
// The number of streams that have ended unsuccessfully:
|
|
||||||
// On client side, termination without receiving frame with eos bit set.
|
|
||||||
// On server side, termination without sending frame with eos bit set.
|
|
||||||
StreamsFailed int64
|
|
||||||
// The number of messages successfully sent on this socket.
|
|
||||||
MessagesSent int64
|
|
||||||
MessagesReceived int64
|
|
||||||
// The number of keep alives sent. This is typically implemented with HTTP/2
|
|
||||||
// ping messages.
|
|
||||||
KeepAlivesSent int64
|
|
||||||
// The last time a stream was created by this endpoint. Usually unset for
|
|
||||||
// servers.
|
|
||||||
LastLocalStreamCreatedTimestamp time.Time
|
|
||||||
// The last time a stream was created by the remote endpoint. Usually unset
|
|
||||||
// for clients.
|
|
||||||
LastRemoteStreamCreatedTimestamp time.Time
|
|
||||||
// The last time a message was sent by this endpoint.
|
|
||||||
LastMessageSentTimestamp time.Time
|
|
||||||
// The last time a message was received by this endpoint.
|
|
||||||
LastMessageReceivedTimestamp time.Time
|
|
||||||
// The amount of window, granted to the local endpoint by the remote endpoint.
|
|
||||||
// This may be slightly out of date due to network latency. This does NOT
|
|
||||||
// include stream level or TCP level flow control info.
|
|
||||||
LocalFlowControlWindow int64
|
|
||||||
// The amount of window, granted to the remote endpoint by the local endpoint.
|
|
||||||
// This may be slightly out of date due to network latency. This does NOT
|
|
||||||
// include stream level or TCP level flow control info.
|
|
||||||
RemoteFlowControlWindow int64
|
|
||||||
// The locally bound address.
|
|
||||||
LocalAddr net.Addr
|
|
||||||
// The remote bound address. May be absent.
|
|
||||||
RemoteAddr net.Addr
|
|
||||||
// Optional, represents the name of the remote endpoint, if different than
|
|
||||||
// the original target name.
|
|
||||||
RemoteName string
|
|
||||||
SocketOptions *SocketOptionData
|
|
||||||
Security credentials.ChannelzSecurityValue
|
|
||||||
}
|
|
||||||
|
|
||||||
// Socket is the interface that should be satisfied in order to be tracked by
|
|
||||||
// channelz as Socket.
|
|
||||||
type Socket interface {
|
|
||||||
ChannelzMetric() *SocketInternalMetric
|
|
||||||
}
|
|
||||||
|
|
||||||
type listenSocket struct {
|
|
||||||
refName string
|
|
||||||
s Socket
|
|
||||||
id int64
|
|
||||||
pid int64
|
|
||||||
cm *channelMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ls *listenSocket) addChild(id int64, e entry) {
|
|
||||||
logger.Errorf("cannot add a child (id = %d) of type %T to a listen socket", id, e)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ls *listenSocket) deleteChild(id int64) {
|
|
||||||
logger.Errorf("cannot delete a child (id = %d) from a listen socket", id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ls *listenSocket) triggerDelete() {
|
|
||||||
ls.cm.deleteEntry(ls.id)
|
|
||||||
ls.cm.findEntry(ls.pid).deleteChild(ls.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ls *listenSocket) deleteSelfIfReady() {
|
|
||||||
logger.Errorf("cannot call deleteSelfIfReady on a listen socket")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ls *listenSocket) getParentID() int64 {
|
|
||||||
return ls.pid
|
|
||||||
}
|
|
||||||
|
|
||||||
type normalSocket struct {
|
|
||||||
refName string
|
|
||||||
s Socket
|
|
||||||
id int64
|
|
||||||
pid int64
|
|
||||||
cm *channelMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ns *normalSocket) addChild(id int64, e entry) {
|
|
||||||
logger.Errorf("cannot add a child (id = %d) of type %T to a normal socket", id, e)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ns *normalSocket) deleteChild(id int64) {
|
|
||||||
logger.Errorf("cannot delete a child (id = %d) from a normal socket", id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ns *normalSocket) triggerDelete() {
|
|
||||||
ns.cm.deleteEntry(ns.id)
|
|
||||||
ns.cm.findEntry(ns.pid).deleteChild(ns.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ns *normalSocket) deleteSelfIfReady() {
|
|
||||||
logger.Errorf("cannot call deleteSelfIfReady on a normal socket")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ns *normalSocket) getParentID() int64 {
|
|
||||||
return ns.pid
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServerMetric defines the info channelz provides for a specific Server, which
|
|
||||||
// includes ServerInternalMetric and channelz-specific data, such as channelz id,
|
|
||||||
// child list, etc.
|
|
||||||
type ServerMetric struct {
|
|
||||||
// ID is the channelz id of this server.
|
|
||||||
ID int64
|
|
||||||
// RefName is the human readable reference string of this server.
|
|
||||||
RefName string
|
|
||||||
// ServerData contains server internal metric reported by the server through
|
|
||||||
// ChannelzMetric().
|
|
||||||
ServerData *ServerInternalMetric
|
|
||||||
// ListenSockets tracks the listener socket type children of this server in the
|
|
||||||
// format of a map from socket channelz id to corresponding reference string.
|
|
||||||
ListenSockets map[int64]string
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServerInternalMetric defines the struct that the implementor of Server interface
|
|
||||||
// should return from ChannelzMetric().
|
|
||||||
type ServerInternalMetric struct {
|
|
||||||
// The number of incoming calls started on the server.
|
|
||||||
CallsStarted int64
|
|
||||||
// The number of incoming calls that have completed with an OK status.
|
|
||||||
CallsSucceeded int64
|
|
||||||
// The number of incoming calls that have a completed with a non-OK status.
|
|
||||||
CallsFailed int64
|
|
||||||
// The last time a call was started on the server.
|
|
||||||
LastCallStartedTimestamp time.Time
|
|
||||||
}
|
|
||||||
|
|
||||||
// Server is the interface to be satisfied in order to be tracked by channelz as
|
|
||||||
// Server.
|
|
||||||
type Server interface {
|
|
||||||
ChannelzMetric() *ServerInternalMetric
|
|
||||||
}
|
|
||||||
|
|
||||||
type server struct {
|
|
||||||
refName string
|
|
||||||
s Server
|
|
||||||
closeCalled bool
|
|
||||||
sockets map[int64]string
|
|
||||||
listenSockets map[int64]string
|
|
||||||
id int64
|
|
||||||
cm *channelMap
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) addChild(id int64, e entry) {
|
|
||||||
switch v := e.(type) {
|
|
||||||
case *normalSocket:
|
|
||||||
s.sockets[id] = v.refName
|
|
||||||
case *listenSocket:
|
|
||||||
s.listenSockets[id] = v.refName
|
|
||||||
default:
|
|
||||||
logger.Errorf("cannot add a child (id = %d) of type %T to a server", id, e)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) deleteChild(id int64) {
|
|
||||||
delete(s.sockets, id)
|
|
||||||
delete(s.listenSockets, id)
|
|
||||||
s.deleteSelfIfReady()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) triggerDelete() {
|
|
||||||
s.closeCalled = true
|
|
||||||
s.deleteSelfIfReady()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) deleteSelfIfReady() {
|
|
||||||
if !s.closeCalled || len(s.sockets)+len(s.listenSockets) != 0 {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
s.cm.deleteEntry(s.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *server) getParentID() int64 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
type tracedChannel interface {
|
|
||||||
getChannelTrace() *channelTrace
|
|
||||||
incrTraceRefCount()
|
|
||||||
decrTraceRefCount()
|
|
||||||
getRefName() string
|
|
||||||
}
|
|
||||||
|
|
||||||
type channelTrace struct {
|
|
||||||
cm *channelMap
|
|
||||||
clearCalled bool
|
|
||||||
createdTime time.Time
|
|
||||||
eventCount int64
|
|
||||||
mu sync.Mutex
|
|
||||||
events []*TraceEvent
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelTrace) append(e *TraceEvent) {
|
|
||||||
c.mu.Lock()
|
|
||||||
if len(c.events) == getMaxTraceEntry() {
|
|
||||||
del := c.events[0]
|
|
||||||
c.events = c.events[1:]
|
|
||||||
if del.RefID != 0 {
|
|
||||||
// start recursive cleanup in a goroutine to not block the call originated from grpc.
|
|
||||||
go func() {
|
|
||||||
// need to acquire c.cm.mu lock to call the unlocked attemptCleanup func.
|
|
||||||
c.cm.mu.Lock()
|
|
||||||
c.cm.decrTraceRefCount(del.RefID)
|
|
||||||
c.cm.mu.Unlock()
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
e.Timestamp = time.Now()
|
|
||||||
c.events = append(c.events, e)
|
|
||||||
c.eventCount++
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelTrace) clear() {
|
|
||||||
if c.clearCalled {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.clearCalled = true
|
|
||||||
c.mu.Lock()
|
|
||||||
for _, e := range c.events {
|
|
||||||
if e.RefID != 0 {
|
|
||||||
// caller should have already held the c.cm.mu lock.
|
|
||||||
c.cm.decrTraceRefCount(e.RefID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.mu.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Severity is the severity level of a trace event.
|
|
||||||
// The canonical enumeration of all valid values is here:
|
|
||||||
// https://github.com/grpc/grpc-proto/blob/9b13d199cc0d4703c7ea26c9c330ba695866eb23/grpc/channelz/v1/channelz.proto#L126.
|
|
||||||
type Severity int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// CtUnknown indicates unknown severity of a trace event.
|
|
||||||
CtUnknown Severity = iota
|
|
||||||
// CtInfo indicates info level severity of a trace event.
|
|
||||||
CtInfo
|
|
||||||
// CtWarning indicates warning level severity of a trace event.
|
|
||||||
CtWarning
|
|
||||||
// CtError indicates error level severity of a trace event.
|
|
||||||
CtError
|
|
||||||
)
|
|
||||||
|
|
||||||
// RefChannelType is the type of the entity being referenced in a trace event.
|
|
||||||
type RefChannelType int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// RefUnknown indicates an unknown entity type, the zero value for this type.
|
|
||||||
RefUnknown RefChannelType = iota
|
|
||||||
// RefChannel indicates the referenced entity is a Channel.
|
|
||||||
RefChannel
|
|
||||||
// RefSubChannel indicates the referenced entity is a SubChannel.
|
|
||||||
RefSubChannel
|
|
||||||
// RefServer indicates the referenced entity is a Server.
|
|
||||||
RefServer
|
|
||||||
// RefListenSocket indicates the referenced entity is a ListenSocket.
|
|
||||||
RefListenSocket
|
|
||||||
// RefNormalSocket indicates the referenced entity is a NormalSocket.
|
|
||||||
RefNormalSocket
|
|
||||||
)
|
|
||||||
|
|
||||||
var refChannelTypeToString = map[RefChannelType]string{
|
|
||||||
RefUnknown: "Unknown",
|
|
||||||
RefChannel: "Channel",
|
|
||||||
RefSubChannel: "SubChannel",
|
|
||||||
RefServer: "Server",
|
|
||||||
RefListenSocket: "ListenSocket",
|
|
||||||
RefNormalSocket: "NormalSocket",
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r RefChannelType) String() string {
|
|
||||||
return refChannelTypeToString[r]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelTrace) dumpData() *ChannelTrace {
|
|
||||||
c.mu.Lock()
|
|
||||||
ct := &ChannelTrace{EventNum: c.eventCount, CreationTime: c.createdTime}
|
|
||||||
ct.Events = c.events[:len(c.events)]
|
|
||||||
c.mu.Unlock()
|
|
||||||
return ct
|
|
||||||
}
|
|
37
vendor/google.golang.org/grpc/internal/channelz/util_linux.go
generated
vendored
37
vendor/google.golang.org/grpc/internal/channelz/util_linux.go
generated
vendored
@ -1,37 +0,0 @@
|
|||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2018 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package channelz
|
|
||||||
|
|
||||||
import (
|
|
||||||
"syscall"
|
|
||||||
)
|
|
||||||
|
|
||||||
// GetSocketOption gets the socket option info of the conn.
|
|
||||||
func GetSocketOption(socket any) *SocketOptionData {
|
|
||||||
c, ok := socket.(syscall.Conn)
|
|
||||||
if !ok {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
data := &SocketOptionData{}
|
|
||||||
if rawConn, err := c.SyscallConn(); err == nil {
|
|
||||||
rawConn.Control(data.Getsockopt)
|
|
||||||
return data
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
27
vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go
generated
vendored
27
vendor/google.golang.org/grpc/internal/channelz/util_nonlinux.go
generated
vendored
@ -1,27 +0,0 @@
|
|||||||
//go:build !linux
|
|
||||||
// +build !linux
|
|
||||||
|
|
||||||
/*
|
|
||||||
*
|
|
||||||
* Copyright 2018 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
package channelz
|
|
||||||
|
|
||||||
// GetSocketOption gets the socket option info of the conn.
|
|
||||||
func GetSocketOption(c any) *SocketOptionData {
|
|
||||||
return nil
|
|
||||||
}
|
|
3
vendor/google.golang.org/grpc/internal/envconfig/envconfig.go
generated
vendored
3
vendor/google.golang.org/grpc/internal/envconfig/envconfig.go
generated
vendored
@ -28,9 +28,6 @@ import (
|
|||||||
var (
|
var (
|
||||||
// TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false").
|
// TXTErrIgnore is set if TXT errors should be ignored ("GRPC_GO_IGNORE_TXT_ERRORS" is not "false").
|
||||||
TXTErrIgnore = boolFromEnv("GRPC_GO_IGNORE_TXT_ERRORS", true)
|
TXTErrIgnore = boolFromEnv("GRPC_GO_IGNORE_TXT_ERRORS", true)
|
||||||
// AdvertiseCompressors is set if registered compressor should be advertised
|
|
||||||
// ("GRPC_GO_ADVERTISE_COMPRESSORS" is not "false").
|
|
||||||
AdvertiseCompressors = boolFromEnv("GRPC_GO_ADVERTISE_COMPRESSORS", true)
|
|
||||||
// RingHashCap indicates the maximum ring size which defaults to 4096
|
// RingHashCap indicates the maximum ring size which defaults to 4096
|
||||||
// entries but may be overridden by setting the environment variable
|
// entries but may be overridden by setting the environment variable
|
||||||
// "GRPC_RING_HASH_CAP". This does not override the default bounds
|
// "GRPC_RING_HASH_CAP". This does not override the default bounds
|
||||||
|
5
vendor/google.golang.org/grpc/internal/grpcutil/compressor.go
generated
vendored
5
vendor/google.golang.org/grpc/internal/grpcutil/compressor.go
generated
vendored
@ -20,8 +20,6 @@ package grpcutil
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"google.golang.org/grpc/internal/envconfig"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// RegisteredCompressorNames holds names of the registered compressors.
|
// RegisteredCompressorNames holds names of the registered compressors.
|
||||||
@ -40,8 +38,5 @@ func IsCompressorNameRegistered(name string) bool {
|
|||||||
// RegisteredCompressors returns a string of registered compressor names
|
// RegisteredCompressors returns a string of registered compressor names
|
||||||
// separated by comma.
|
// separated by comma.
|
||||||
func RegisteredCompressors() string {
|
func RegisteredCompressors() string {
|
||||||
if !envconfig.AdvertiseCompressors {
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
return strings.Join(RegisteredCompressorNames, ",")
|
return strings.Join(RegisteredCompressorNames, ",")
|
||||||
}
|
}
|
||||||
|
8
vendor/google.golang.org/grpc/internal/internal.go
generated
vendored
8
vendor/google.golang.org/grpc/internal/internal.go
generated
vendored
@ -190,12 +190,16 @@ var (
|
|||||||
// function makes events more predictable than relying on timer events.
|
// function makes events more predictable than relying on timer events.
|
||||||
TriggerXDSResourceNameNotFoundForTesting any // func(func(xdsresource.Type, string), string, string) error
|
TriggerXDSResourceNameNotFoundForTesting any // func(func(xdsresource.Type, string), string, string) error
|
||||||
|
|
||||||
// TriggerXDSResourceNotFoundClient invokes the testing xDS Client singleton
|
// TriggerXDSResourceNameNotFoundClient invokes the testing xDS Client
|
||||||
// to invoke resource not found for a resource type name and resource name.
|
// singleton to invoke resource not found for a resource type name and
|
||||||
|
// resource name.
|
||||||
TriggerXDSResourceNameNotFoundClient any // func(string, string) error
|
TriggerXDSResourceNameNotFoundClient any // func(string, string) error
|
||||||
|
|
||||||
// FromOutgoingContextRaw returns the un-merged, intermediary contents of metadata.rawMD.
|
// FromOutgoingContextRaw returns the un-merged, intermediary contents of metadata.rawMD.
|
||||||
FromOutgoingContextRaw any // func(context.Context) (metadata.MD, [][]string, bool)
|
FromOutgoingContextRaw any // func(context.Context) (metadata.MD, [][]string, bool)
|
||||||
|
|
||||||
|
// UserSetDefaultScheme is set to true if the user has overridden the default resolver scheme.
|
||||||
|
UserSetDefaultScheme bool = false
|
||||||
)
|
)
|
||||||
|
|
||||||
// HealthChecker defines the signature of the client-side LB channel health checking function.
|
// HealthChecker defines the signature of the client-side LB channel health checking function.
|
||||||
|
34
vendor/google.golang.org/grpc/internal/pretty/pretty.go
generated
vendored
34
vendor/google.golang.org/grpc/internal/pretty/pretty.go
generated
vendored
@ -24,9 +24,8 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
protov1 "github.com/golang/protobuf/proto"
|
|
||||||
"google.golang.org/protobuf/encoding/protojson"
|
"google.golang.org/protobuf/encoding/protojson"
|
||||||
protov2 "google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/protoadapt"
|
||||||
)
|
)
|
||||||
|
|
||||||
const jsonIndent = " "
|
const jsonIndent = " "
|
||||||
@ -35,21 +34,14 @@ const jsonIndent = " "
|
|||||||
//
|
//
|
||||||
// If marshal fails, it falls back to fmt.Sprintf("%+v").
|
// If marshal fails, it falls back to fmt.Sprintf("%+v").
|
||||||
func ToJSON(e any) string {
|
func ToJSON(e any) string {
|
||||||
switch ee := e.(type) {
|
if ee, ok := e.(protoadapt.MessageV1); ok {
|
||||||
case protov1.Message:
|
e = protoadapt.MessageV2Of(ee)
|
||||||
mm := protojson.MarshalOptions{Indent: jsonIndent}
|
}
|
||||||
ret, err := mm.Marshal(protov1.MessageV2(ee))
|
|
||||||
if err != nil {
|
if ee, ok := e.(protoadapt.MessageV2); ok {
|
||||||
// This may fail for proto.Anys, e.g. for xDS v2, LDS, the v2
|
|
||||||
// messages are not imported, and this will fail because the message
|
|
||||||
// is not found.
|
|
||||||
return fmt.Sprintf("%+v", ee)
|
|
||||||
}
|
|
||||||
return string(ret)
|
|
||||||
case protov2.Message:
|
|
||||||
mm := protojson.MarshalOptions{
|
mm := protojson.MarshalOptions{
|
||||||
Multiline: true,
|
|
||||||
Indent: jsonIndent,
|
Indent: jsonIndent,
|
||||||
|
Multiline: true,
|
||||||
}
|
}
|
||||||
ret, err := mm.Marshal(ee)
|
ret, err := mm.Marshal(ee)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -59,13 +51,13 @@ func ToJSON(e any) string {
|
|||||||
return fmt.Sprintf("%+v", ee)
|
return fmt.Sprintf("%+v", ee)
|
||||||
}
|
}
|
||||||
return string(ret)
|
return string(ret)
|
||||||
default:
|
|
||||||
ret, err := json.MarshalIndent(ee, "", jsonIndent)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Sprintf("%+v", ee)
|
|
||||||
}
|
|
||||||
return string(ret)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret, err := json.MarshalIndent(e, "", jsonIndent)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Sprintf("%+v", e)
|
||||||
|
}
|
||||||
|
return string(ret)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FormatJSON formats the input json bytes with indentation.
|
// FormatJSON formats the input json bytes with indentation.
|
||||||
|
45
vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go
generated
vendored
45
vendor/google.golang.org/grpc/internal/resolver/dns/dns_resolver.go
generated
vendored
@ -41,11 +41,24 @@ import (
|
|||||||
"google.golang.org/grpc/serviceconfig"
|
"google.golang.org/grpc/serviceconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
// EnableSRVLookups controls whether the DNS resolver attempts to fetch gRPCLB
|
var (
|
||||||
// addresses from SRV records. Must not be changed after init time.
|
// EnableSRVLookups controls whether the DNS resolver attempts to fetch gRPCLB
|
||||||
var EnableSRVLookups = false
|
// addresses from SRV records. Must not be changed after init time.
|
||||||
|
EnableSRVLookups = false
|
||||||
|
|
||||||
var logger = grpclog.Component("dns")
|
// MinResolutionInterval is the minimum interval at which re-resolutions are
|
||||||
|
// allowed. This helps to prevent excessive re-resolution.
|
||||||
|
MinResolutionInterval = 30 * time.Second
|
||||||
|
|
||||||
|
// ResolvingTimeout specifies the maximum duration for a DNS resolution request.
|
||||||
|
// If the timeout expires before a response is received, the request will be canceled.
|
||||||
|
//
|
||||||
|
// It is recommended to set this value at application startup. Avoid modifying this variable
|
||||||
|
// after initialization as it's not thread-safe for concurrent modification.
|
||||||
|
ResolvingTimeout = 30 * time.Second
|
||||||
|
|
||||||
|
logger = grpclog.Component("dns")
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
resolver.Register(NewBuilder())
|
resolver.Register(NewBuilder())
|
||||||
@ -201,7 +214,7 @@ func (d *dnsResolver) watcher() {
|
|||||||
// Success resolving, wait for the next ResolveNow. However, also wait 30
|
// Success resolving, wait for the next ResolveNow. However, also wait 30
|
||||||
// seconds at the very least to prevent constantly re-resolving.
|
// seconds at the very least to prevent constantly re-resolving.
|
||||||
backoffIndex = 1
|
backoffIndex = 1
|
||||||
waitTime = internal.MinResolutionRate
|
waitTime = MinResolutionInterval
|
||||||
select {
|
select {
|
||||||
case <-d.ctx.Done():
|
case <-d.ctx.Done():
|
||||||
return
|
return
|
||||||
@ -221,18 +234,18 @@ func (d *dnsResolver) watcher() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dnsResolver) lookupSRV() ([]resolver.Address, error) {
|
func (d *dnsResolver) lookupSRV(ctx context.Context) ([]resolver.Address, error) {
|
||||||
if !EnableSRVLookups {
|
if !EnableSRVLookups {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
var newAddrs []resolver.Address
|
var newAddrs []resolver.Address
|
||||||
_, srvs, err := d.resolver.LookupSRV(d.ctx, "grpclb", "tcp", d.host)
|
_, srvs, err := d.resolver.LookupSRV(ctx, "grpclb", "tcp", d.host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = handleDNSError(err, "SRV") // may become nil
|
err = handleDNSError(err, "SRV") // may become nil
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, s := range srvs {
|
for _, s := range srvs {
|
||||||
lbAddrs, err := d.resolver.LookupHost(d.ctx, s.Target)
|
lbAddrs, err := d.resolver.LookupHost(ctx, s.Target)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = handleDNSError(err, "A") // may become nil
|
err = handleDNSError(err, "A") // may become nil
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -269,8 +282,8 @@ func handleDNSError(err error, lookupType string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dnsResolver) lookupTXT() *serviceconfig.ParseResult {
|
func (d *dnsResolver) lookupTXT(ctx context.Context) *serviceconfig.ParseResult {
|
||||||
ss, err := d.resolver.LookupTXT(d.ctx, txtPrefix+d.host)
|
ss, err := d.resolver.LookupTXT(ctx, txtPrefix+d.host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if envconfig.TXTErrIgnore {
|
if envconfig.TXTErrIgnore {
|
||||||
return nil
|
return nil
|
||||||
@ -297,8 +310,8 @@ func (d *dnsResolver) lookupTXT() *serviceconfig.ParseResult {
|
|||||||
return d.cc.ParseServiceConfig(sc)
|
return d.cc.ParseServiceConfig(sc)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *dnsResolver) lookupHost() ([]resolver.Address, error) {
|
func (d *dnsResolver) lookupHost(ctx context.Context) ([]resolver.Address, error) {
|
||||||
addrs, err := d.resolver.LookupHost(d.ctx, d.host)
|
addrs, err := d.resolver.LookupHost(ctx, d.host)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = handleDNSError(err, "A")
|
err = handleDNSError(err, "A")
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -316,8 +329,10 @@ func (d *dnsResolver) lookupHost() ([]resolver.Address, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *dnsResolver) lookup() (*resolver.State, error) {
|
func (d *dnsResolver) lookup() (*resolver.State, error) {
|
||||||
srv, srvErr := d.lookupSRV()
|
ctx, cancel := context.WithTimeout(d.ctx, ResolvingTimeout)
|
||||||
addrs, hostErr := d.lookupHost()
|
defer cancel()
|
||||||
|
srv, srvErr := d.lookupSRV(ctx)
|
||||||
|
addrs, hostErr := d.lookupHost(ctx)
|
||||||
if hostErr != nil && (srvErr != nil || len(srv) == 0) {
|
if hostErr != nil && (srvErr != nil || len(srv) == 0) {
|
||||||
return nil, hostErr
|
return nil, hostErr
|
||||||
}
|
}
|
||||||
@ -327,7 +342,7 @@ func (d *dnsResolver) lookup() (*resolver.State, error) {
|
|||||||
state = grpclbstate.Set(state, &grpclbstate.State{BalancerAddresses: srv})
|
state = grpclbstate.Set(state, &grpclbstate.State{BalancerAddresses: srv})
|
||||||
}
|
}
|
||||||
if !d.disableServiceConfig {
|
if !d.disableServiceConfig {
|
||||||
state.ServiceConfig = d.lookupTXT()
|
state.ServiceConfig = d.lookupTXT(ctx)
|
||||||
}
|
}
|
||||||
return &state, nil
|
return &state, nil
|
||||||
}
|
}
|
||||||
|
6
vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go
generated
vendored
6
vendor/google.golang.org/grpc/internal/resolver/dns/internal/internal.go
generated
vendored
@ -28,7 +28,7 @@ import (
|
|||||||
|
|
||||||
// NetResolver groups the methods on net.Resolver that are used by the DNS
|
// NetResolver groups the methods on net.Resolver that are used by the DNS
|
||||||
// resolver implementation. This allows the default net.Resolver instance to be
|
// resolver implementation. This allows the default net.Resolver instance to be
|
||||||
// overidden from tests.
|
// overridden from tests.
|
||||||
type NetResolver interface {
|
type NetResolver interface {
|
||||||
LookupHost(ctx context.Context, host string) (addrs []string, err error)
|
LookupHost(ctx context.Context, host string) (addrs []string, err error)
|
||||||
LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*net.SRV, err error)
|
LookupSRV(ctx context.Context, service, proto, name string) (cname string, addrs []*net.SRV, err error)
|
||||||
@ -50,10 +50,6 @@ var (
|
|||||||
|
|
||||||
// The following vars are overridden from tests.
|
// The following vars are overridden from tests.
|
||||||
var (
|
var (
|
||||||
// MinResolutionRate is the minimum rate at which re-resolutions are
|
|
||||||
// allowed. This helps to prevent excessive re-resolution.
|
|
||||||
MinResolutionRate = 30 * time.Second
|
|
||||||
|
|
||||||
// TimeAfterFunc is used by the DNS resolver to wait for the given duration
|
// TimeAfterFunc is used by the DNS resolver to wait for the given duration
|
||||||
// to elapse. In non-test code, this is implemented by time.After. In test
|
// to elapse. In non-test code, this is implemented by time.After. In test
|
||||||
// code, this can be used to control the amount of time the resolver is
|
// code, this can be used to control the amount of time the resolver is
|
||||||
|
33
vendor/google.golang.org/grpc/internal/transport/controlbuf.go
generated
vendored
33
vendor/google.golang.org/grpc/internal/transport/controlbuf.go
generated
vendored
@ -193,7 +193,7 @@ type goAway struct {
|
|||||||
code http2.ErrCode
|
code http2.ErrCode
|
||||||
debugData []byte
|
debugData []byte
|
||||||
headsUp bool
|
headsUp bool
|
||||||
closeConn error // if set, loopyWriter will exit, resulting in conn closure
|
closeConn error // if set, loopyWriter will exit with this error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*goAway) isTransportResponseFrame() bool { return false }
|
func (*goAway) isTransportResponseFrame() bool { return false }
|
||||||
@ -336,7 +336,7 @@ func (c *controlBuffer) put(it cbItem) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *controlBuffer) executeAndPut(f func(it any) bool, it cbItem) (bool, error) {
|
func (c *controlBuffer) executeAndPut(f func() bool, it cbItem) (bool, error) {
|
||||||
var wakeUp bool
|
var wakeUp bool
|
||||||
c.mu.Lock()
|
c.mu.Lock()
|
||||||
if c.err != nil {
|
if c.err != nil {
|
||||||
@ -344,7 +344,7 @@ func (c *controlBuffer) executeAndPut(f func(it any) bool, it cbItem) (bool, err
|
|||||||
return false, c.err
|
return false, c.err
|
||||||
}
|
}
|
||||||
if f != nil {
|
if f != nil {
|
||||||
if !f(it) { // f wasn't successful
|
if !f() { // f wasn't successful
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
@ -495,21 +495,22 @@ type loopyWriter struct {
|
|||||||
ssGoAwayHandler func(*goAway) (bool, error)
|
ssGoAwayHandler func(*goAway) (bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func newLoopyWriter(s side, fr *framer, cbuf *controlBuffer, bdpEst *bdpEstimator, conn net.Conn, logger *grpclog.PrefixLogger) *loopyWriter {
|
func newLoopyWriter(s side, fr *framer, cbuf *controlBuffer, bdpEst *bdpEstimator, conn net.Conn, logger *grpclog.PrefixLogger, goAwayHandler func(*goAway) (bool, error)) *loopyWriter {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
l := &loopyWriter{
|
l := &loopyWriter{
|
||||||
side: s,
|
side: s,
|
||||||
cbuf: cbuf,
|
cbuf: cbuf,
|
||||||
sendQuota: defaultWindowSize,
|
sendQuota: defaultWindowSize,
|
||||||
oiws: defaultWindowSize,
|
oiws: defaultWindowSize,
|
||||||
estdStreams: make(map[uint32]*outStream),
|
estdStreams: make(map[uint32]*outStream),
|
||||||
activeStreams: newOutStreamList(),
|
activeStreams: newOutStreamList(),
|
||||||
framer: fr,
|
framer: fr,
|
||||||
hBuf: &buf,
|
hBuf: &buf,
|
||||||
hEnc: hpack.NewEncoder(&buf),
|
hEnc: hpack.NewEncoder(&buf),
|
||||||
bdpEst: bdpEst,
|
bdpEst: bdpEst,
|
||||||
conn: conn,
|
conn: conn,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
|
ssGoAwayHandler: goAwayHandler,
|
||||||
}
|
}
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
15
vendor/google.golang.org/grpc/internal/transport/handler_server.go
generated
vendored
15
vendor/google.golang.org/grpc/internal/transport/handler_server.go
generated
vendored
@ -51,14 +51,10 @@ import (
|
|||||||
// inside an http.Handler, or writes an HTTP error to w and returns an error.
|
// inside an http.Handler, or writes an HTTP error to w and returns an error.
|
||||||
// It requires that the http Server supports HTTP/2.
|
// It requires that the http Server supports HTTP/2.
|
||||||
func NewServerHandlerTransport(w http.ResponseWriter, r *http.Request, stats []stats.Handler) (ServerTransport, error) {
|
func NewServerHandlerTransport(w http.ResponseWriter, r *http.Request, stats []stats.Handler) (ServerTransport, error) {
|
||||||
if r.ProtoMajor != 2 {
|
if r.Method != http.MethodPost {
|
||||||
msg := "gRPC requires HTTP/2"
|
w.Header().Set("Allow", http.MethodPost)
|
||||||
http.Error(w, msg, http.StatusBadRequest)
|
|
||||||
return nil, errors.New(msg)
|
|
||||||
}
|
|
||||||
if r.Method != "POST" {
|
|
||||||
msg := fmt.Sprintf("invalid gRPC request method %q", r.Method)
|
msg := fmt.Sprintf("invalid gRPC request method %q", r.Method)
|
||||||
http.Error(w, msg, http.StatusBadRequest)
|
http.Error(w, msg, http.StatusMethodNotAllowed)
|
||||||
return nil, errors.New(msg)
|
return nil, errors.New(msg)
|
||||||
}
|
}
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
@ -69,6 +65,11 @@ func NewServerHandlerTransport(w http.ResponseWriter, r *http.Request, stats []s
|
|||||||
http.Error(w, msg, http.StatusUnsupportedMediaType)
|
http.Error(w, msg, http.StatusUnsupportedMediaType)
|
||||||
return nil, errors.New(msg)
|
return nil, errors.New(msg)
|
||||||
}
|
}
|
||||||
|
if r.ProtoMajor != 2 {
|
||||||
|
msg := "gRPC requires HTTP/2"
|
||||||
|
http.Error(w, msg, http.StatusHTTPVersionNotSupported)
|
||||||
|
return nil, errors.New(msg)
|
||||||
|
}
|
||||||
if _, ok := w.(http.Flusher); !ok {
|
if _, ok := w.(http.Flusher); !ok {
|
||||||
msg := "gRPC requires a ResponseWriter supporting http.Flusher"
|
msg := "gRPC requires a ResponseWriter supporting http.Flusher"
|
||||||
http.Error(w, msg, http.StatusInternalServerError)
|
http.Error(w, msg, http.StatusInternalServerError)
|
||||||
|
138
vendor/google.golang.org/grpc/internal/transport/http2_client.go
generated
vendored
138
vendor/google.golang.org/grpc/internal/transport/http2_client.go
generated
vendored
@ -114,11 +114,11 @@ type http2Client struct {
|
|||||||
streamQuota int64
|
streamQuota int64
|
||||||
streamsQuotaAvailable chan struct{}
|
streamsQuotaAvailable chan struct{}
|
||||||
waitingStreams uint32
|
waitingStreams uint32
|
||||||
nextID uint32
|
|
||||||
registeredCompressors string
|
registeredCompressors string
|
||||||
|
|
||||||
// Do not access controlBuf with mu held.
|
// Do not access controlBuf with mu held.
|
||||||
mu sync.Mutex // guard the following variables
|
mu sync.Mutex // guard the following variables
|
||||||
|
nextID uint32
|
||||||
state transportState
|
state transportState
|
||||||
activeStreams map[uint32]*Stream
|
activeStreams map[uint32]*Stream
|
||||||
// prevGoAway ID records the Last-Stream-ID in the previous GOAway frame.
|
// prevGoAway ID records the Last-Stream-ID in the previous GOAway frame.
|
||||||
@ -140,9 +140,7 @@ type http2Client struct {
|
|||||||
// variable.
|
// variable.
|
||||||
kpDormant bool
|
kpDormant bool
|
||||||
|
|
||||||
// Fields below are for channelz metric collection.
|
channelz *channelz.Socket
|
||||||
channelzID *channelz.Identifier
|
|
||||||
czData *channelzData
|
|
||||||
|
|
||||||
onClose func(GoAwayReason)
|
onClose func(GoAwayReason)
|
||||||
|
|
||||||
@ -319,6 +317,7 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
|||||||
if opts.MaxHeaderListSize != nil {
|
if opts.MaxHeaderListSize != nil {
|
||||||
maxHeaderListSize = *opts.MaxHeaderListSize
|
maxHeaderListSize = *opts.MaxHeaderListSize
|
||||||
}
|
}
|
||||||
|
|
||||||
t := &http2Client{
|
t := &http2Client{
|
||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
ctxDone: ctx.Done(), // Cache Done chan.
|
ctxDone: ctx.Done(), // Cache Done chan.
|
||||||
@ -346,11 +345,25 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
|||||||
maxConcurrentStreams: defaultMaxStreamsClient,
|
maxConcurrentStreams: defaultMaxStreamsClient,
|
||||||
streamQuota: defaultMaxStreamsClient,
|
streamQuota: defaultMaxStreamsClient,
|
||||||
streamsQuotaAvailable: make(chan struct{}, 1),
|
streamsQuotaAvailable: make(chan struct{}, 1),
|
||||||
czData: new(channelzData),
|
|
||||||
keepaliveEnabled: keepaliveEnabled,
|
keepaliveEnabled: keepaliveEnabled,
|
||||||
bufferPool: newBufferPool(),
|
bufferPool: newBufferPool(),
|
||||||
onClose: onClose,
|
onClose: onClose,
|
||||||
}
|
}
|
||||||
|
var czSecurity credentials.ChannelzSecurityValue
|
||||||
|
if au, ok := authInfo.(credentials.ChannelzSecurityInfo); ok {
|
||||||
|
czSecurity = au.GetSecurityValue()
|
||||||
|
}
|
||||||
|
t.channelz = channelz.RegisterSocket(
|
||||||
|
&channelz.Socket{
|
||||||
|
SocketType: channelz.SocketTypeNormal,
|
||||||
|
Parent: opts.ChannelzParent,
|
||||||
|
SocketMetrics: channelz.SocketMetrics{},
|
||||||
|
EphemeralMetrics: t.socketMetrics,
|
||||||
|
LocalAddr: t.localAddr,
|
||||||
|
RemoteAddr: t.remoteAddr,
|
||||||
|
SocketOptions: channelz.GetSocketOption(t.conn),
|
||||||
|
Security: czSecurity,
|
||||||
|
})
|
||||||
t.logger = prefixLoggerForClientTransport(t)
|
t.logger = prefixLoggerForClientTransport(t)
|
||||||
// Add peer information to the http2client context.
|
// Add peer information to the http2client context.
|
||||||
t.ctx = peer.NewContext(t.ctx, t.getPeer())
|
t.ctx = peer.NewContext(t.ctx, t.getPeer())
|
||||||
@ -381,10 +394,6 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
|||||||
}
|
}
|
||||||
sh.HandleConn(t.ctx, connBegin)
|
sh.HandleConn(t.ctx, connBegin)
|
||||||
}
|
}
|
||||||
t.channelzID, err = channelz.RegisterNormalSocket(t, opts.ChannelzParentID, fmt.Sprintf("%s -> %s", t.localAddr, t.remoteAddr))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if t.keepaliveEnabled {
|
if t.keepaliveEnabled {
|
||||||
t.kpDormancyCond = sync.NewCond(&t.mu)
|
t.kpDormancyCond = sync.NewCond(&t.mu)
|
||||||
go t.keepalive()
|
go t.keepalive()
|
||||||
@ -399,10 +408,10 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
|||||||
readerErrCh := make(chan error, 1)
|
readerErrCh := make(chan error, 1)
|
||||||
go t.reader(readerErrCh)
|
go t.reader(readerErrCh)
|
||||||
defer func() {
|
defer func() {
|
||||||
if err == nil {
|
|
||||||
err = <-readerErrCh
|
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// writerDone should be closed since the loopy goroutine
|
||||||
|
// wouldn't have started in the case this function returns an error.
|
||||||
|
close(t.writerDone)
|
||||||
t.Close(err)
|
t.Close(err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@ -449,8 +458,12 @@ func newHTTP2Client(connectCtx, ctx context.Context, addr resolver.Address, opts
|
|||||||
if err := t.framer.writer.Flush(); err != nil {
|
if err := t.framer.writer.Flush(); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
// Block until the server preface is received successfully or an error occurs.
|
||||||
|
if err = <-readerErrCh; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
go func() {
|
go func() {
|
||||||
t.loopy = newLoopyWriter(clientSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger)
|
t.loopy = newLoopyWriter(clientSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger, t.outgoingGoAwayHandler)
|
||||||
if err := t.loopy.run(); !isIOError(err) {
|
if err := t.loopy.run(); !isIOError(err) {
|
||||||
// Immediately close the connection, as the loopy writer returns
|
// Immediately close the connection, as the loopy writer returns
|
||||||
// when there are no more active streams and we were draining (the
|
// when there are no more active streams and we were draining (the
|
||||||
@ -508,6 +521,17 @@ func (t *http2Client) getPeer() *peer.Peer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OutgoingGoAwayHandler writes a GOAWAY to the connection. Always returns (false, err) as we want the GoAway
|
||||||
|
// to be the last frame loopy writes to the transport.
|
||||||
|
func (t *http2Client) outgoingGoAwayHandler(g *goAway) (bool, error) {
|
||||||
|
t.mu.Lock()
|
||||||
|
defer t.mu.Unlock()
|
||||||
|
if err := t.framer.fr.WriteGoAway(t.nextID-2, http2.ErrCodeNo, g.debugData); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
return false, g.closeConn
|
||||||
|
}
|
||||||
|
|
||||||
func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) ([]hpack.HeaderField, error) {
|
func (t *http2Client) createHeaderFields(ctx context.Context, callHdr *CallHdr) ([]hpack.HeaderField, error) {
|
||||||
aud := t.createAudience(callHdr)
|
aud := t.createAudience(callHdr)
|
||||||
ri := credentials.RequestInfo{
|
ri := credentials.RequestInfo{
|
||||||
@ -756,8 +780,8 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
|
|||||||
return ErrConnClosing
|
return ErrConnClosing
|
||||||
}
|
}
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
atomic.AddInt64(&t.czData.streamsStarted, 1)
|
t.channelz.SocketMetrics.StreamsStarted.Add(1)
|
||||||
atomic.StoreInt64(&t.czData.lastStreamCreatedTime, time.Now().UnixNano())
|
t.channelz.SocketMetrics.LastLocalStreamCreatedTimestamp.Store(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
// If the keepalive goroutine has gone dormant, wake it up.
|
// If the keepalive goroutine has gone dormant, wake it up.
|
||||||
if t.kpDormant {
|
if t.kpDormant {
|
||||||
@ -772,7 +796,7 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
|
|||||||
firstTry := true
|
firstTry := true
|
||||||
var ch chan struct{}
|
var ch chan struct{}
|
||||||
transportDrainRequired := false
|
transportDrainRequired := false
|
||||||
checkForStreamQuota := func(it any) bool {
|
checkForStreamQuota := func() bool {
|
||||||
if t.streamQuota <= 0 { // Can go negative if server decreases it.
|
if t.streamQuota <= 0 { // Can go negative if server decreases it.
|
||||||
if firstTry {
|
if firstTry {
|
||||||
t.waitingStreams++
|
t.waitingStreams++
|
||||||
@ -784,23 +808,24 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
|
|||||||
t.waitingStreams--
|
t.waitingStreams--
|
||||||
}
|
}
|
||||||
t.streamQuota--
|
t.streamQuota--
|
||||||
h := it.(*headerFrame)
|
|
||||||
h.streamID = t.nextID
|
|
||||||
t.nextID += 2
|
|
||||||
|
|
||||||
// Drain client transport if nextID > MaxStreamID which signals gRPC that
|
|
||||||
// the connection is closed and a new one must be created for subsequent RPCs.
|
|
||||||
transportDrainRequired = t.nextID > MaxStreamID
|
|
||||||
|
|
||||||
s.id = h.streamID
|
|
||||||
s.fc = &inFlow{limit: uint32(t.initialWindowSize)}
|
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
if t.state == draining || t.activeStreams == nil { // Can be niled from Close().
|
if t.state == draining || t.activeStreams == nil { // Can be niled from Close().
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
return false // Don't create a stream if the transport is already closed.
|
return false // Don't create a stream if the transport is already closed.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hdr.streamID = t.nextID
|
||||||
|
t.nextID += 2
|
||||||
|
// Drain client transport if nextID > MaxStreamID which signals gRPC that
|
||||||
|
// the connection is closed and a new one must be created for subsequent RPCs.
|
||||||
|
transportDrainRequired = t.nextID > MaxStreamID
|
||||||
|
|
||||||
|
s.id = hdr.streamID
|
||||||
|
s.fc = &inFlow{limit: uint32(t.initialWindowSize)}
|
||||||
t.activeStreams[s.id] = s
|
t.activeStreams[s.id] = s
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
|
|
||||||
if t.streamQuota > 0 && t.waitingStreams > 0 {
|
if t.streamQuota > 0 && t.waitingStreams > 0 {
|
||||||
select {
|
select {
|
||||||
case t.streamsQuotaAvailable <- struct{}{}:
|
case t.streamsQuotaAvailable <- struct{}{}:
|
||||||
@ -810,13 +835,12 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
var hdrListSizeErr error
|
var hdrListSizeErr error
|
||||||
checkForHeaderListSize := func(it any) bool {
|
checkForHeaderListSize := func() bool {
|
||||||
if t.maxSendHeaderListSize == nil {
|
if t.maxSendHeaderListSize == nil {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
hdrFrame := it.(*headerFrame)
|
|
||||||
var sz int64
|
var sz int64
|
||||||
for _, f := range hdrFrame.hf {
|
for _, f := range hdr.hf {
|
||||||
if sz += int64(f.Size()); sz > int64(*t.maxSendHeaderListSize) {
|
if sz += int64(f.Size()); sz > int64(*t.maxSendHeaderListSize) {
|
||||||
hdrListSizeErr = status.Errorf(codes.Internal, "header list size to send violates the maximum size (%d bytes) set by server", *t.maxSendHeaderListSize)
|
hdrListSizeErr = status.Errorf(codes.Internal, "header list size to send violates the maximum size (%d bytes) set by server", *t.maxSendHeaderListSize)
|
||||||
return false
|
return false
|
||||||
@ -825,8 +849,8 @@ func (t *http2Client) NewStream(ctx context.Context, callHdr *CallHdr) (*Stream,
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
success, err := t.controlBuf.executeAndPut(func(it any) bool {
|
success, err := t.controlBuf.executeAndPut(func() bool {
|
||||||
return checkForHeaderListSize(it) && checkForStreamQuota(it)
|
return checkForHeaderListSize() && checkForStreamQuota()
|
||||||
}, hdr)
|
}, hdr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// Connection closed.
|
// Connection closed.
|
||||||
@ -928,16 +952,16 @@ func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2.
|
|||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
if eosReceived {
|
if eosReceived {
|
||||||
atomic.AddInt64(&t.czData.streamsSucceeded, 1)
|
t.channelz.SocketMetrics.StreamsSucceeded.Add(1)
|
||||||
} else {
|
} else {
|
||||||
atomic.AddInt64(&t.czData.streamsFailed, 1)
|
t.channelz.SocketMetrics.StreamsFailed.Add(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
rst: rst,
|
rst: rst,
|
||||||
rstCode: rstCode,
|
rstCode: rstCode,
|
||||||
}
|
}
|
||||||
addBackStreamQuota := func(any) bool {
|
addBackStreamQuota := func() bool {
|
||||||
t.streamQuota++
|
t.streamQuota++
|
||||||
if t.streamQuota > 0 && t.waitingStreams > 0 {
|
if t.streamQuota > 0 && t.waitingStreams > 0 {
|
||||||
select {
|
select {
|
||||||
@ -957,7 +981,7 @@ func (t *http2Client) closeStream(s *Stream, err error, rst bool, rstCode http2.
|
|||||||
|
|
||||||
// Close kicks off the shutdown process of the transport. This should be called
|
// Close kicks off the shutdown process of the transport. This should be called
|
||||||
// only once on a transport. Once it is called, the transport should not be
|
// only once on a transport. Once it is called, the transport should not be
|
||||||
// accessed any more.
|
// accessed anymore.
|
||||||
func (t *http2Client) Close(err error) {
|
func (t *http2Client) Close(err error) {
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
// Make sure we only close once.
|
// Make sure we only close once.
|
||||||
@ -982,10 +1006,13 @@ func (t *http2Client) Close(err error) {
|
|||||||
t.kpDormancyCond.Signal()
|
t.kpDormancyCond.Signal()
|
||||||
}
|
}
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
t.controlBuf.finish()
|
// Per HTTP/2 spec, a GOAWAY frame must be sent before closing the
|
||||||
|
// connection. See https://httpwg.org/specs/rfc7540.html#GOAWAY.
|
||||||
|
t.controlBuf.put(&goAway{code: http2.ErrCodeNo, debugData: []byte("client transport shutdown"), closeConn: err})
|
||||||
|
<-t.writerDone
|
||||||
t.cancel()
|
t.cancel()
|
||||||
t.conn.Close()
|
t.conn.Close()
|
||||||
channelz.RemoveEntry(t.channelzID)
|
channelz.RemoveEntry(t.channelz.ID)
|
||||||
// Append info about previous goaways if there were any, since this may be important
|
// Append info about previous goaways if there were any, since this may be important
|
||||||
// for understanding the root cause for this connection to be closed.
|
// for understanding the root cause for this connection to be closed.
|
||||||
_, goAwayDebugMessage := t.GetGoAwayReason()
|
_, goAwayDebugMessage := t.GetGoAwayReason()
|
||||||
@ -1090,7 +1117,7 @@ func (t *http2Client) updateWindow(s *Stream, n uint32) {
|
|||||||
// for the transport and the stream based on the current bdp
|
// for the transport and the stream based on the current bdp
|
||||||
// estimation.
|
// estimation.
|
||||||
func (t *http2Client) updateFlowControl(n uint32) {
|
func (t *http2Client) updateFlowControl(n uint32) {
|
||||||
updateIWS := func(any) bool {
|
updateIWS := func() bool {
|
||||||
t.initialWindowSize = int32(n)
|
t.initialWindowSize = int32(n)
|
||||||
t.mu.Lock()
|
t.mu.Lock()
|
||||||
for _, s := range t.activeStreams {
|
for _, s := range t.activeStreams {
|
||||||
@ -1243,7 +1270,7 @@ func (t *http2Client) handleSettings(f *http2.SettingsFrame, isFirst bool) {
|
|||||||
}
|
}
|
||||||
updateFuncs = append(updateFuncs, updateStreamQuota)
|
updateFuncs = append(updateFuncs, updateStreamQuota)
|
||||||
}
|
}
|
||||||
t.controlBuf.executeAndPut(func(any) bool {
|
t.controlBuf.executeAndPut(func() bool {
|
||||||
for _, f := range updateFuncs {
|
for _, f := range updateFuncs {
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
@ -1708,7 +1735,7 @@ func (t *http2Client) keepalive() {
|
|||||||
// keepalive timer expired. In both cases, we need to send a ping.
|
// keepalive timer expired. In both cases, we need to send a ping.
|
||||||
if !outstandingPing {
|
if !outstandingPing {
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
atomic.AddInt64(&t.czData.kpCount, 1)
|
t.channelz.SocketMetrics.KeepAlivesSent.Add(1)
|
||||||
}
|
}
|
||||||
t.controlBuf.put(p)
|
t.controlBuf.put(p)
|
||||||
timeoutLeft = t.kp.Timeout
|
timeoutLeft = t.kp.Timeout
|
||||||
@ -1738,40 +1765,23 @@ func (t *http2Client) GoAway() <-chan struct{} {
|
|||||||
return t.goAway
|
return t.goAway
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Client) ChannelzMetric() *channelz.SocketInternalMetric {
|
func (t *http2Client) socketMetrics() *channelz.EphemeralSocketMetrics {
|
||||||
s := channelz.SocketInternalMetric{
|
return &channelz.EphemeralSocketMetrics{
|
||||||
StreamsStarted: atomic.LoadInt64(&t.czData.streamsStarted),
|
LocalFlowControlWindow: int64(t.fc.getSize()),
|
||||||
StreamsSucceeded: atomic.LoadInt64(&t.czData.streamsSucceeded),
|
RemoteFlowControlWindow: t.getOutFlowWindow(),
|
||||||
StreamsFailed: atomic.LoadInt64(&t.czData.streamsFailed),
|
|
||||||
MessagesSent: atomic.LoadInt64(&t.czData.msgSent),
|
|
||||||
MessagesReceived: atomic.LoadInt64(&t.czData.msgRecv),
|
|
||||||
KeepAlivesSent: atomic.LoadInt64(&t.czData.kpCount),
|
|
||||||
LastLocalStreamCreatedTimestamp: time.Unix(0, atomic.LoadInt64(&t.czData.lastStreamCreatedTime)),
|
|
||||||
LastMessageSentTimestamp: time.Unix(0, atomic.LoadInt64(&t.czData.lastMsgSentTime)),
|
|
||||||
LastMessageReceivedTimestamp: time.Unix(0, atomic.LoadInt64(&t.czData.lastMsgRecvTime)),
|
|
||||||
LocalFlowControlWindow: int64(t.fc.getSize()),
|
|
||||||
SocketOptions: channelz.GetSocketOption(t.conn),
|
|
||||||
LocalAddr: t.localAddr,
|
|
||||||
RemoteAddr: t.remoteAddr,
|
|
||||||
// RemoteName :
|
|
||||||
}
|
}
|
||||||
if au, ok := t.authInfo.(credentials.ChannelzSecurityInfo); ok {
|
|
||||||
s.Security = au.GetSecurityValue()
|
|
||||||
}
|
|
||||||
s.RemoteFlowControlWindow = t.getOutFlowWindow()
|
|
||||||
return &s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Client) RemoteAddr() net.Addr { return t.remoteAddr }
|
func (t *http2Client) RemoteAddr() net.Addr { return t.remoteAddr }
|
||||||
|
|
||||||
func (t *http2Client) IncrMsgSent() {
|
func (t *http2Client) IncrMsgSent() {
|
||||||
atomic.AddInt64(&t.czData.msgSent, 1)
|
t.channelz.SocketMetrics.MessagesSent.Add(1)
|
||||||
atomic.StoreInt64(&t.czData.lastMsgSentTime, time.Now().UnixNano())
|
t.channelz.SocketMetrics.LastMessageSentTimestamp.Store(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Client) IncrMsgRecv() {
|
func (t *http2Client) IncrMsgRecv() {
|
||||||
atomic.AddInt64(&t.czData.msgRecv, 1)
|
t.channelz.SocketMetrics.MessagesReceived.Add(1)
|
||||||
atomic.StoreInt64(&t.czData.lastMsgRecvTime, time.Now().UnixNano())
|
t.channelz.SocketMetrics.LastMessageReceivedTimestamp.Store(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Client) getOutFlowWindow() int64 {
|
func (t *http2Client) getOutFlowWindow() int64 {
|
||||||
|
95
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
95
vendor/google.golang.org/grpc/internal/transport/http2_server.go
generated
vendored
@ -118,8 +118,7 @@ type http2Server struct {
|
|||||||
idle time.Time
|
idle time.Time
|
||||||
|
|
||||||
// Fields below are for channelz metric collection.
|
// Fields below are for channelz metric collection.
|
||||||
channelzID *channelz.Identifier
|
channelz *channelz.Socket
|
||||||
czData *channelzData
|
|
||||||
bufferPool *bufferPool
|
bufferPool *bufferPool
|
||||||
|
|
||||||
connectionID uint64
|
connectionID uint64
|
||||||
@ -262,9 +261,24 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
|
|||||||
idle: time.Now(),
|
idle: time.Now(),
|
||||||
kep: kep,
|
kep: kep,
|
||||||
initialWindowSize: iwz,
|
initialWindowSize: iwz,
|
||||||
czData: new(channelzData),
|
|
||||||
bufferPool: newBufferPool(),
|
bufferPool: newBufferPool(),
|
||||||
}
|
}
|
||||||
|
var czSecurity credentials.ChannelzSecurityValue
|
||||||
|
if au, ok := authInfo.(credentials.ChannelzSecurityInfo); ok {
|
||||||
|
czSecurity = au.GetSecurityValue()
|
||||||
|
}
|
||||||
|
t.channelz = channelz.RegisterSocket(
|
||||||
|
&channelz.Socket{
|
||||||
|
SocketType: channelz.SocketTypeNormal,
|
||||||
|
Parent: config.ChannelzParent,
|
||||||
|
SocketMetrics: channelz.SocketMetrics{},
|
||||||
|
EphemeralMetrics: t.socketMetrics,
|
||||||
|
LocalAddr: t.peer.LocalAddr,
|
||||||
|
RemoteAddr: t.peer.Addr,
|
||||||
|
SocketOptions: channelz.GetSocketOption(t.conn),
|
||||||
|
Security: czSecurity,
|
||||||
|
},
|
||||||
|
)
|
||||||
t.logger = prefixLoggerForServerTransport(t)
|
t.logger = prefixLoggerForServerTransport(t)
|
||||||
|
|
||||||
t.controlBuf = newControlBuffer(t.done)
|
t.controlBuf = newControlBuffer(t.done)
|
||||||
@ -274,10 +288,6 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
|
|||||||
updateFlowControl: t.updateFlowControl,
|
updateFlowControl: t.updateFlowControl,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
t.channelzID, err = channelz.RegisterNormalSocket(t, config.ChannelzParentID, fmt.Sprintf("%s -> %s", t.peer.Addr, t.peer.LocalAddr))
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
t.connectionID = atomic.AddUint64(&serverConnectionCounter, 1)
|
t.connectionID = atomic.AddUint64(&serverConnectionCounter, 1)
|
||||||
t.framer.writer.Flush()
|
t.framer.writer.Flush()
|
||||||
@ -320,8 +330,7 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
|
|||||||
t.handleSettings(sf)
|
t.handleSettings(sf)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
t.loopy = newLoopyWriter(serverSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger)
|
t.loopy = newLoopyWriter(serverSide, t.framer, t.controlBuf, t.bdpEst, t.conn, t.logger, t.outgoingGoAwayHandler)
|
||||||
t.loopy.ssGoAwayHandler = t.outgoingGoAwayHandler
|
|
||||||
err := t.loopy.run()
|
err := t.loopy.run()
|
||||||
close(t.loopyWriterDone)
|
close(t.loopyWriterDone)
|
||||||
if !isIOError(err) {
|
if !isIOError(err) {
|
||||||
@ -334,9 +343,11 @@ func NewServerTransport(conn net.Conn, config *ServerConfig) (_ ServerTransport,
|
|||||||
// closed, would lead to a TCP RST instead of FIN, and the client
|
// closed, would lead to a TCP RST instead of FIN, and the client
|
||||||
// encountering errors. For more info:
|
// encountering errors. For more info:
|
||||||
// https://github.com/grpc/grpc-go/issues/5358
|
// https://github.com/grpc/grpc-go/issues/5358
|
||||||
|
timer := time.NewTimer(time.Second)
|
||||||
|
defer timer.Stop()
|
||||||
select {
|
select {
|
||||||
case <-t.readerDone:
|
case <-t.readerDone:
|
||||||
case <-time.After(time.Second):
|
case <-timer.C:
|
||||||
}
|
}
|
||||||
t.conn.Close()
|
t.conn.Close()
|
||||||
}
|
}
|
||||||
@ -592,8 +603,8 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade
|
|||||||
}
|
}
|
||||||
t.mu.Unlock()
|
t.mu.Unlock()
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
atomic.AddInt64(&t.czData.streamsStarted, 1)
|
t.channelz.SocketMetrics.StreamsStarted.Add(1)
|
||||||
atomic.StoreInt64(&t.czData.lastStreamCreatedTime, time.Now().UnixNano())
|
t.channelz.SocketMetrics.LastRemoteStreamCreatedTimestamp.Store(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
s.requestRead = func(n int) {
|
s.requestRead = func(n int) {
|
||||||
t.adjustWindow(s, uint32(n))
|
t.adjustWindow(s, uint32(n))
|
||||||
@ -658,8 +669,14 @@ func (t *http2Server) HandleStreams(ctx context.Context, handle func(*Stream)) {
|
|||||||
switch frame := frame.(type) {
|
switch frame := frame.(type) {
|
||||||
case *http2.MetaHeadersFrame:
|
case *http2.MetaHeadersFrame:
|
||||||
if err := t.operateHeaders(ctx, frame, handle); err != nil {
|
if err := t.operateHeaders(ctx, frame, handle); err != nil {
|
||||||
t.Close(err)
|
// Any error processing client headers, e.g. invalid stream ID,
|
||||||
break
|
// is considered a protocol violation.
|
||||||
|
t.controlBuf.put(&goAway{
|
||||||
|
code: http2.ErrCodeProtocol,
|
||||||
|
debugData: []byte(err.Error()),
|
||||||
|
closeConn: err,
|
||||||
|
})
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
case *http2.DataFrame:
|
case *http2.DataFrame:
|
||||||
t.handleData(frame)
|
t.handleData(frame)
|
||||||
@ -842,7 +859,7 @@ func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
t.controlBuf.executeAndPut(func(any) bool {
|
t.controlBuf.executeAndPut(func() bool {
|
||||||
for _, f := range updateFuncs {
|
for _, f := range updateFuncs {
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
@ -996,12 +1013,13 @@ func (t *http2Server) writeHeaderLocked(s *Stream) error {
|
|||||||
headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-encoding", Value: s.sendCompress})
|
headerFields = append(headerFields, hpack.HeaderField{Name: "grpc-encoding", Value: s.sendCompress})
|
||||||
}
|
}
|
||||||
headerFields = appendHeaderFieldsFromMD(headerFields, s.header)
|
headerFields = appendHeaderFieldsFromMD(headerFields, s.header)
|
||||||
success, err := t.controlBuf.executeAndPut(t.checkForHeaderListSize, &headerFrame{
|
hf := &headerFrame{
|
||||||
streamID: s.id,
|
streamID: s.id,
|
||||||
hf: headerFields,
|
hf: headerFields,
|
||||||
endStream: false,
|
endStream: false,
|
||||||
onWrite: t.setResetPingStrikes,
|
onWrite: t.setResetPingStrikes,
|
||||||
})
|
}
|
||||||
|
success, err := t.controlBuf.executeAndPut(func() bool { return t.checkForHeaderListSize(hf) }, hf)
|
||||||
if !success {
|
if !success {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -1190,12 +1208,12 @@ func (t *http2Server) keepalive() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if outstandingPing && kpTimeoutLeft <= 0 {
|
if outstandingPing && kpTimeoutLeft <= 0 {
|
||||||
t.Close(fmt.Errorf("keepalive ping not acked within timeout %s", t.kp.Time))
|
t.Close(fmt.Errorf("keepalive ping not acked within timeout %s", t.kp.Timeout))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if !outstandingPing {
|
if !outstandingPing {
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
atomic.AddInt64(&t.czData.kpCount, 1)
|
t.channelz.SocketMetrics.KeepAlivesSent.Add(1)
|
||||||
}
|
}
|
||||||
t.controlBuf.put(p)
|
t.controlBuf.put(p)
|
||||||
kpTimeoutLeft = t.kp.Timeout
|
kpTimeoutLeft = t.kp.Timeout
|
||||||
@ -1235,7 +1253,7 @@ func (t *http2Server) Close(err error) {
|
|||||||
if err := t.conn.Close(); err != nil && t.logger.V(logLevel) {
|
if err := t.conn.Close(); err != nil && t.logger.V(logLevel) {
|
||||||
t.logger.Infof("Error closing underlying net.Conn during Close: %v", err)
|
t.logger.Infof("Error closing underlying net.Conn during Close: %v", err)
|
||||||
}
|
}
|
||||||
channelz.RemoveEntry(t.channelzID)
|
channelz.RemoveEntry(t.channelz.ID)
|
||||||
// Cancel all active streams.
|
// Cancel all active streams.
|
||||||
for _, s := range streams {
|
for _, s := range streams {
|
||||||
s.cancel()
|
s.cancel()
|
||||||
@ -1256,9 +1274,9 @@ func (t *http2Server) deleteStream(s *Stream, eosReceived bool) {
|
|||||||
|
|
||||||
if channelz.IsOn() {
|
if channelz.IsOn() {
|
||||||
if eosReceived {
|
if eosReceived {
|
||||||
atomic.AddInt64(&t.czData.streamsSucceeded, 1)
|
t.channelz.SocketMetrics.StreamsSucceeded.Add(1)
|
||||||
} else {
|
} else {
|
||||||
atomic.AddInt64(&t.czData.streamsFailed, 1)
|
t.channelz.SocketMetrics.StreamsFailed.Add(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1375,38 +1393,21 @@ func (t *http2Server) outgoingGoAwayHandler(g *goAway) (bool, error) {
|
|||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Server) ChannelzMetric() *channelz.SocketInternalMetric {
|
func (t *http2Server) socketMetrics() *channelz.EphemeralSocketMetrics {
|
||||||
s := channelz.SocketInternalMetric{
|
return &channelz.EphemeralSocketMetrics{
|
||||||
StreamsStarted: atomic.LoadInt64(&t.czData.streamsStarted),
|
LocalFlowControlWindow: int64(t.fc.getSize()),
|
||||||
StreamsSucceeded: atomic.LoadInt64(&t.czData.streamsSucceeded),
|
RemoteFlowControlWindow: t.getOutFlowWindow(),
|
||||||
StreamsFailed: atomic.LoadInt64(&t.czData.streamsFailed),
|
|
||||||
MessagesSent: atomic.LoadInt64(&t.czData.msgSent),
|
|
||||||
MessagesReceived: atomic.LoadInt64(&t.czData.msgRecv),
|
|
||||||
KeepAlivesSent: atomic.LoadInt64(&t.czData.kpCount),
|
|
||||||
LastRemoteStreamCreatedTimestamp: time.Unix(0, atomic.LoadInt64(&t.czData.lastStreamCreatedTime)),
|
|
||||||
LastMessageSentTimestamp: time.Unix(0, atomic.LoadInt64(&t.czData.lastMsgSentTime)),
|
|
||||||
LastMessageReceivedTimestamp: time.Unix(0, atomic.LoadInt64(&t.czData.lastMsgRecvTime)),
|
|
||||||
LocalFlowControlWindow: int64(t.fc.getSize()),
|
|
||||||
SocketOptions: channelz.GetSocketOption(t.conn),
|
|
||||||
LocalAddr: t.peer.LocalAddr,
|
|
||||||
RemoteAddr: t.peer.Addr,
|
|
||||||
// RemoteName :
|
|
||||||
}
|
}
|
||||||
if au, ok := t.peer.AuthInfo.(credentials.ChannelzSecurityInfo); ok {
|
|
||||||
s.Security = au.GetSecurityValue()
|
|
||||||
}
|
|
||||||
s.RemoteFlowControlWindow = t.getOutFlowWindow()
|
|
||||||
return &s
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Server) IncrMsgSent() {
|
func (t *http2Server) IncrMsgSent() {
|
||||||
atomic.AddInt64(&t.czData.msgSent, 1)
|
t.channelz.SocketMetrics.MessagesSent.Add(1)
|
||||||
atomic.StoreInt64(&t.czData.lastMsgSentTime, time.Now().UnixNano())
|
t.channelz.SocketMetrics.LastMessageSentTimestamp.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Server) IncrMsgRecv() {
|
func (t *http2Server) IncrMsgRecv() {
|
||||||
atomic.AddInt64(&t.czData.msgRecv, 1)
|
t.channelz.SocketMetrics.MessagesReceived.Add(1)
|
||||||
atomic.StoreInt64(&t.czData.lastMsgRecvTime, time.Now().UnixNano())
|
t.channelz.SocketMetrics.LastMessageReceivedTimestamp.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *http2Server) getOutFlowWindow() int64 {
|
func (t *http2Server) getOutFlowWindow() int64 {
|
||||||
|
3
vendor/google.golang.org/grpc/internal/transport/http_util.go
generated
vendored
3
vendor/google.golang.org/grpc/internal/transport/http_util.go
generated
vendored
@ -418,10 +418,9 @@ func newFramer(conn net.Conn, writeBufferSize, readBufferSize int, sharedWriteBu
|
|||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
func getWriteBufferPool(writeBufferSize int) *sync.Pool {
|
func getWriteBufferPool(size int) *sync.Pool {
|
||||||
writeBufferMutex.Lock()
|
writeBufferMutex.Lock()
|
||||||
defer writeBufferMutex.Unlock()
|
defer writeBufferMutex.Unlock()
|
||||||
size := writeBufferSize * 2
|
|
||||||
pool, ok := writeBufferPoolMap[size]
|
pool, ok := writeBufferPoolMap[size]
|
||||||
if ok {
|
if ok {
|
||||||
return pool
|
return pool
|
||||||
|
32
vendor/google.golang.org/grpc/internal/transport/transport.go
generated
vendored
32
vendor/google.golang.org/grpc/internal/transport/transport.go
generated
vendored
@ -304,7 +304,7 @@ func (s *Stream) isHeaderSent() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// updateHeaderSent updates headerSent and returns true
|
// updateHeaderSent updates headerSent and returns true
|
||||||
// if it was alreay set. It is valid only on server-side.
|
// if it was already set. It is valid only on server-side.
|
||||||
func (s *Stream) updateHeaderSent() bool {
|
func (s *Stream) updateHeaderSent() bool {
|
||||||
return atomic.SwapUint32(&s.headerSent, 1) == 1
|
return atomic.SwapUint32(&s.headerSent, 1) == 1
|
||||||
}
|
}
|
||||||
@ -571,7 +571,7 @@ type ServerConfig struct {
|
|||||||
WriteBufferSize int
|
WriteBufferSize int
|
||||||
ReadBufferSize int
|
ReadBufferSize int
|
||||||
SharedWriteBuffer bool
|
SharedWriteBuffer bool
|
||||||
ChannelzParentID *channelz.Identifier
|
ChannelzParent *channelz.Server
|
||||||
MaxHeaderListSize *uint32
|
MaxHeaderListSize *uint32
|
||||||
HeaderTableSize *uint32
|
HeaderTableSize *uint32
|
||||||
}
|
}
|
||||||
@ -606,8 +606,8 @@ type ConnectOptions struct {
|
|||||||
ReadBufferSize int
|
ReadBufferSize int
|
||||||
// SharedWriteBuffer indicates whether connections should reuse write buffer
|
// SharedWriteBuffer indicates whether connections should reuse write buffer
|
||||||
SharedWriteBuffer bool
|
SharedWriteBuffer bool
|
||||||
// ChannelzParentID sets the addrConn id which initiate the creation of this client transport.
|
// ChannelzParent sets the addrConn id which initiated the creation of this client transport.
|
||||||
ChannelzParentID *channelz.Identifier
|
ChannelzParent *channelz.SubChannel
|
||||||
// MaxHeaderListSize sets the max (uncompressed) size of header list that is prepared to be received.
|
// MaxHeaderListSize sets the max (uncompressed) size of header list that is prepared to be received.
|
||||||
MaxHeaderListSize *uint32
|
MaxHeaderListSize *uint32
|
||||||
// UseProxy specifies if a proxy should be used.
|
// UseProxy specifies if a proxy should be used.
|
||||||
@ -820,30 +820,6 @@ const (
|
|||||||
GoAwayTooManyPings GoAwayReason = 2
|
GoAwayTooManyPings GoAwayReason = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
// channelzData is used to store channelz related data for http2Client and http2Server.
|
|
||||||
// These fields cannot be embedded in the original structs (e.g. http2Client), since to do atomic
|
|
||||||
// operation on int64 variable on 32-bit machine, user is responsible to enforce memory alignment.
|
|
||||||
// Here, by grouping those int64 fields inside a struct, we are enforcing the alignment.
|
|
||||||
type channelzData struct {
|
|
||||||
kpCount int64
|
|
||||||
// The number of streams that have started, including already finished ones.
|
|
||||||
streamsStarted int64
|
|
||||||
// Client side: The number of streams that have ended successfully by receiving
|
|
||||||
// EoS bit set frame from server.
|
|
||||||
// Server side: The number of streams that have ended successfully by sending
|
|
||||||
// frame with EoS bit set.
|
|
||||||
streamsSucceeded int64
|
|
||||||
streamsFailed int64
|
|
||||||
// lastStreamCreatedTime stores the timestamp that the last stream gets created. It is of int64 type
|
|
||||||
// instead of time.Time since it's more costly to atomically update time.Time variable than int64
|
|
||||||
// variable. The same goes for lastMsgSentTime and lastMsgRecvTime.
|
|
||||||
lastStreamCreatedTime int64
|
|
||||||
msgSent int64
|
|
||||||
msgRecv int64
|
|
||||||
lastMsgSentTime int64
|
|
||||||
lastMsgRecvTime int64
|
|
||||||
}
|
|
||||||
|
|
||||||
// ContextErr converts the error from context package into a status error.
|
// ContextErr converts the error from context package into a status error.
|
||||||
func ContextErr(err error) error {
|
func ContextErr(err error) error {
|
||||||
switch err {
|
switch err {
|
||||||
|
40
vendor/google.golang.org/grpc/internal/xds_handshake_cluster.go
generated
vendored
40
vendor/google.golang.org/grpc/internal/xds_handshake_cluster.go
generated
vendored
@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2021 gRPC authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package internal
|
|
||||||
|
|
||||||
import (
|
|
||||||
"google.golang.org/grpc/attributes"
|
|
||||||
"google.golang.org/grpc/resolver"
|
|
||||||
)
|
|
||||||
|
|
||||||
// handshakeClusterNameKey is the type used as the key to store cluster name in
|
|
||||||
// the Attributes field of resolver.Address.
|
|
||||||
type handshakeClusterNameKey struct{}
|
|
||||||
|
|
||||||
// SetXDSHandshakeClusterName returns a copy of addr in which the Attributes field
|
|
||||||
// is updated with the cluster name.
|
|
||||||
func SetXDSHandshakeClusterName(addr resolver.Address, clusterName string) resolver.Address {
|
|
||||||
addr.Attributes = addr.Attributes.WithValue(handshakeClusterNameKey{}, clusterName)
|
|
||||||
return addr
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetXDSHandshakeClusterName returns cluster name stored in attr.
|
|
||||||
func GetXDSHandshakeClusterName(attr *attributes.Attributes) (string, bool) {
|
|
||||||
v := attr.Value(handshakeClusterNameKey{})
|
|
||||||
name, ok := v.(string)
|
|
||||||
return name, ok
|
|
||||||
}
|
|
15
vendor/google.golang.org/grpc/metadata/metadata.go
generated
vendored
15
vendor/google.golang.org/grpc/metadata/metadata.go
generated
vendored
@ -90,6 +90,21 @@ func Pairs(kv ...string) MD {
|
|||||||
return md
|
return md
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String implements the Stringer interface for pretty-printing a MD.
|
||||||
|
// Ordering of the values is non-deterministic as it ranges over a map.
|
||||||
|
func (md MD) String() string {
|
||||||
|
var sb strings.Builder
|
||||||
|
fmt.Fprintf(&sb, "MD{")
|
||||||
|
for k, v := range md {
|
||||||
|
if sb.Len() > 3 {
|
||||||
|
fmt.Fprintf(&sb, ", ")
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&sb, "%s=[%s]", k, strings.Join(v, ", "))
|
||||||
|
}
|
||||||
|
fmt.Fprintf(&sb, "}")
|
||||||
|
return sb.String()
|
||||||
|
}
|
||||||
|
|
||||||
// Len returns the number of items in md.
|
// Len returns the number of items in md.
|
||||||
func (md MD) Len() int {
|
func (md MD) Len() int {
|
||||||
return len(md)
|
return len(md)
|
||||||
|
30
vendor/google.golang.org/grpc/peer/peer.go
generated
vendored
30
vendor/google.golang.org/grpc/peer/peer.go
generated
vendored
@ -22,7 +22,9 @@ package peer
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
)
|
)
|
||||||
@ -39,6 +41,34 @@ type Peer struct {
|
|||||||
AuthInfo credentials.AuthInfo
|
AuthInfo credentials.AuthInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String ensures the Peer types implements the Stringer interface in order to
|
||||||
|
// allow to print a context with a peerKey value effectively.
|
||||||
|
func (p *Peer) String() string {
|
||||||
|
if p == nil {
|
||||||
|
return "Peer<nil>"
|
||||||
|
}
|
||||||
|
sb := &strings.Builder{}
|
||||||
|
sb.WriteString("Peer{")
|
||||||
|
if p.Addr != nil {
|
||||||
|
fmt.Fprintf(sb, "Addr: '%s', ", p.Addr.String())
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(sb, "Addr: <nil>, ")
|
||||||
|
}
|
||||||
|
if p.LocalAddr != nil {
|
||||||
|
fmt.Fprintf(sb, "LocalAddr: '%s', ", p.LocalAddr.String())
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(sb, "LocalAddr: <nil>, ")
|
||||||
|
}
|
||||||
|
if p.AuthInfo != nil {
|
||||||
|
fmt.Fprintf(sb, "AuthInfo: '%s'", p.AuthInfo.AuthType())
|
||||||
|
} else {
|
||||||
|
fmt.Fprintf(sb, "AuthInfo: <nil>")
|
||||||
|
}
|
||||||
|
sb.WriteString("}")
|
||||||
|
|
||||||
|
return sb.String()
|
||||||
|
}
|
||||||
|
|
||||||
type peerKey struct{}
|
type peerKey struct{}
|
||||||
|
|
||||||
// NewContext creates a new context with peer information attached.
|
// NewContext creates a new context with peer information attached.
|
||||||
|
3
vendor/google.golang.org/grpc/picker_wrapper.go
generated
vendored
3
vendor/google.golang.org/grpc/picker_wrapper.go
generated
vendored
@ -20,6 +20,7 @@ package grpc
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
@ -117,7 +118,7 @@ func (pw *pickerWrapper) pick(ctx context.Context, failfast bool, info balancer.
|
|||||||
if lastPickErr != nil {
|
if lastPickErr != nil {
|
||||||
errStr = "latest balancer error: " + lastPickErr.Error()
|
errStr = "latest balancer error: " + lastPickErr.Error()
|
||||||
} else {
|
} else {
|
||||||
errStr = ctx.Err().Error()
|
errStr = fmt.Sprintf("received context error while waiting for new LB policy update: %s", ctx.Err().Error())
|
||||||
}
|
}
|
||||||
switch ctx.Err() {
|
switch ctx.Err() {
|
||||||
case context.DeadlineExceeded:
|
case context.DeadlineExceeded:
|
||||||
|
56
vendor/google.golang.org/grpc/pickfirst.go
generated
vendored
56
vendor/google.golang.org/grpc/pickfirst.go
generated
vendored
@ -38,19 +38,15 @@ const (
|
|||||||
logPrefix = "[pick-first-lb %p] "
|
logPrefix = "[pick-first-lb %p] "
|
||||||
)
|
)
|
||||||
|
|
||||||
func newPickfirstBuilder() balancer.Builder {
|
|
||||||
return &pickfirstBuilder{}
|
|
||||||
}
|
|
||||||
|
|
||||||
type pickfirstBuilder struct{}
|
type pickfirstBuilder struct{}
|
||||||
|
|
||||||
func (*pickfirstBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) balancer.Balancer {
|
func (pickfirstBuilder) Build(cc balancer.ClientConn, opt balancer.BuildOptions) balancer.Balancer {
|
||||||
b := &pickfirstBalancer{cc: cc}
|
b := &pickfirstBalancer{cc: cc}
|
||||||
b.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf(logPrefix, b))
|
b.logger = internalgrpclog.NewPrefixLogger(logger, fmt.Sprintf(logPrefix, b))
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*pickfirstBuilder) Name() string {
|
func (pickfirstBuilder) Name() string {
|
||||||
return PickFirstBalancerName
|
return PickFirstBalancerName
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,12 +54,12 @@ type pfConfig struct {
|
|||||||
serviceconfig.LoadBalancingConfig `json:"-"`
|
serviceconfig.LoadBalancingConfig `json:"-"`
|
||||||
|
|
||||||
// If set to true, instructs the LB policy to shuffle the order of the list
|
// If set to true, instructs the LB policy to shuffle the order of the list
|
||||||
// of addresses received from the name resolver before attempting to
|
// of endpoints received from the name resolver before attempting to
|
||||||
// connect to them.
|
// connect to them.
|
||||||
ShuffleAddressList bool `json:"shuffleAddressList"`
|
ShuffleAddressList bool `json:"shuffleAddressList"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*pickfirstBuilder) ParseConfig(js json.RawMessage) (serviceconfig.LoadBalancingConfig, error) {
|
func (pickfirstBuilder) ParseConfig(js json.RawMessage) (serviceconfig.LoadBalancingConfig, error) {
|
||||||
var cfg pfConfig
|
var cfg pfConfig
|
||||||
if err := json.Unmarshal(js, &cfg); err != nil {
|
if err := json.Unmarshal(js, &cfg); err != nil {
|
||||||
return nil, fmt.Errorf("pickfirst: unable to unmarshal LB policy config: %s, error: %v", string(js), err)
|
return nil, fmt.Errorf("pickfirst: unable to unmarshal LB policy config: %s, error: %v", string(js), err)
|
||||||
@ -98,8 +94,7 @@ func (b *pickfirstBalancer) ResolverError(err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState) error {
|
func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState) error {
|
||||||
addrs := state.ResolverState.Addresses
|
if len(state.ResolverState.Addresses) == 0 && len(state.ResolverState.Endpoints) == 0 {
|
||||||
if len(addrs) == 0 {
|
|
||||||
// The resolver reported an empty address list. Treat it like an error by
|
// The resolver reported an empty address list. Treat it like an error by
|
||||||
// calling b.ResolverError.
|
// calling b.ResolverError.
|
||||||
if b.subConn != nil {
|
if b.subConn != nil {
|
||||||
@ -111,22 +106,49 @@ func (b *pickfirstBalancer) UpdateClientConnState(state balancer.ClientConnState
|
|||||||
b.ResolverError(errors.New("produced zero addresses"))
|
b.ResolverError(errors.New("produced zero addresses"))
|
||||||
return balancer.ErrBadResolverState
|
return balancer.ErrBadResolverState
|
||||||
}
|
}
|
||||||
|
|
||||||
// We don't have to guard this block with the env var because ParseConfig
|
// We don't have to guard this block with the env var because ParseConfig
|
||||||
// already does so.
|
// already does so.
|
||||||
cfg, ok := state.BalancerConfig.(pfConfig)
|
cfg, ok := state.BalancerConfig.(pfConfig)
|
||||||
if state.BalancerConfig != nil && !ok {
|
if state.BalancerConfig != nil && !ok {
|
||||||
return fmt.Errorf("pickfirst: received illegal BalancerConfig (type %T): %v", state.BalancerConfig, state.BalancerConfig)
|
return fmt.Errorf("pickfirst: received illegal BalancerConfig (type %T): %v", state.BalancerConfig, state.BalancerConfig)
|
||||||
}
|
}
|
||||||
if cfg.ShuffleAddressList {
|
|
||||||
addrs = append([]resolver.Address{}, addrs...)
|
|
||||||
grpcrand.Shuffle(len(addrs), func(i, j int) { addrs[i], addrs[j] = addrs[j], addrs[i] })
|
|
||||||
}
|
|
||||||
|
|
||||||
if b.logger.V(2) {
|
if b.logger.V(2) {
|
||||||
b.logger.Infof("Received new config %s, resolver state %s", pretty.ToJSON(cfg), pretty.ToJSON(state.ResolverState))
|
b.logger.Infof("Received new config %s, resolver state %s", pretty.ToJSON(cfg), pretty.ToJSON(state.ResolverState))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var addrs []resolver.Address
|
||||||
|
if endpoints := state.ResolverState.Endpoints; len(endpoints) != 0 {
|
||||||
|
// Perform the optional shuffling described in gRFC A62. The shuffling will
|
||||||
|
// change the order of endpoints but not touch the order of the addresses
|
||||||
|
// within each endpoint. - A61
|
||||||
|
if cfg.ShuffleAddressList {
|
||||||
|
endpoints = append([]resolver.Endpoint{}, endpoints...)
|
||||||
|
grpcrand.Shuffle(len(endpoints), func(i, j int) { endpoints[i], endpoints[j] = endpoints[j], endpoints[i] })
|
||||||
|
}
|
||||||
|
|
||||||
|
// "Flatten the list by concatenating the ordered list of addresses for each
|
||||||
|
// of the endpoints, in order." - A61
|
||||||
|
for _, endpoint := range endpoints {
|
||||||
|
// "In the flattened list, interleave addresses from the two address
|
||||||
|
// families, as per RFC-8304 section 4." - A61
|
||||||
|
// TODO: support the above language.
|
||||||
|
addrs = append(addrs, endpoint.Addresses...)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Endpoints not set, process addresses until we migrate resolver
|
||||||
|
// emissions fully to Endpoints. The top channel does wrap emitted
|
||||||
|
// addresses with endpoints, however some balancers such as weighted
|
||||||
|
// target do not forwarrd the corresponding correct endpoints down/split
|
||||||
|
// endpoints properly. Once all balancers correctly forward endpoints
|
||||||
|
// down, can delete this else conditional.
|
||||||
|
addrs = state.ResolverState.Addresses
|
||||||
|
if cfg.ShuffleAddressList {
|
||||||
|
addrs = append([]resolver.Address{}, addrs...)
|
||||||
|
grpcrand.Shuffle(len(addrs), func(i, j int) { addrs[i], addrs[j] = addrs[j], addrs[i] })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if b.subConn != nil {
|
if b.subConn != nil {
|
||||||
b.cc.UpdateAddresses(b.subConn, addrs)
|
b.cc.UpdateAddresses(b.subConn, addrs)
|
||||||
return nil
|
return nil
|
||||||
@ -243,7 +265,3 @@ func (i *idlePicker) Pick(balancer.PickInfo) (balancer.PickResult, error) {
|
|||||||
i.subConn.Connect()
|
i.subConn.Connect()
|
||||||
return balancer.PickResult{}, balancer.ErrNoSubConnAvailable
|
return balancer.PickResult{}, balancer.ErrNoSubConnAvailable
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
|
||||||
balancer.Register(newPickfirstBuilder())
|
|
||||||
}
|
|
||||||
|
6
vendor/google.golang.org/grpc/regenerate.sh
generated
vendored
6
vendor/google.golang.org/grpc/regenerate.sh
generated
vendored
@ -63,7 +63,7 @@ LEGACY_SOURCES=(
|
|||||||
|
|
||||||
# Generates only the new gRPC Service symbols
|
# Generates only the new gRPC Service symbols
|
||||||
SOURCES=(
|
SOURCES=(
|
||||||
$(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^\(profiling/proto/service.proto\|reflection/grpc_reflection_v1alpha/reflection.proto\)$')
|
$(git ls-files --exclude-standard --cached --others "*.proto" | grep -v '^profiling/proto/service.proto$')
|
||||||
${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto
|
${WORKDIR}/grpc-proto/grpc/gcp/altscontext.proto
|
||||||
${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto
|
${WORKDIR}/grpc-proto/grpc/gcp/handshaker.proto
|
||||||
${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto
|
${WORKDIR}/grpc-proto/grpc/gcp/transport_security_common.proto
|
||||||
@ -93,7 +93,7 @@ Mgrpc/testing/empty.proto=google.golang.org/grpc/interop/grpc_testing
|
|||||||
|
|
||||||
for src in ${SOURCES[@]}; do
|
for src in ${SOURCES[@]}; do
|
||||||
echo "protoc ${src}"
|
echo "protoc ${src}"
|
||||||
protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS}:${WORKDIR}/out \
|
protoc --go_out=${OPTS}:${WORKDIR}/out --go-grpc_out=${OPTS},use_generic_streams_experimental=true:${WORKDIR}/out \
|
||||||
-I"." \
|
-I"." \
|
||||||
-I${WORKDIR}/grpc-proto \
|
-I${WORKDIR}/grpc-proto \
|
||||||
-I${WORKDIR}/googleapis \
|
-I${WORKDIR}/googleapis \
|
||||||
@ -118,6 +118,6 @@ mv ${WORKDIR}/out/google.golang.org/grpc/lookup/grpc_lookup_v1/* ${WORKDIR}/out/
|
|||||||
|
|
||||||
# grpc_testing_not_regenerate/*.pb.go are not re-generated,
|
# grpc_testing_not_regenerate/*.pb.go are not re-generated,
|
||||||
# see grpc_testing_not_regenerate/README.md for details.
|
# see grpc_testing_not_regenerate/README.md for details.
|
||||||
rm ${WORKDIR}/out/google.golang.org/grpc/reflection/grpc_testing_not_regenerate/*.pb.go
|
rm ${WORKDIR}/out/google.golang.org/grpc/reflection/test/grpc_testing_not_regenerate/*.pb.go
|
||||||
|
|
||||||
cp -R ${WORKDIR}/out/google.golang.org/grpc/* .
|
cp -R ${WORKDIR}/out/google.golang.org/grpc/* .
|
||||||
|
30
vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go
generated
vendored
30
vendor/google.golang.org/grpc/resolver/dns/dns_resolver.go
generated
vendored
@ -18,19 +18,43 @@
|
|||||||
|
|
||||||
// Package dns implements a dns resolver to be installed as the default resolver
|
// Package dns implements a dns resolver to be installed as the default resolver
|
||||||
// in grpc.
|
// in grpc.
|
||||||
//
|
|
||||||
// Deprecated: this package is imported by grpc and should not need to be
|
|
||||||
// imported directly by users.
|
|
||||||
package dns
|
package dns
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"google.golang.org/grpc/internal/resolver/dns"
|
"google.golang.org/grpc/internal/resolver/dns"
|
||||||
"google.golang.org/grpc/resolver"
|
"google.golang.org/grpc/resolver"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// SetResolvingTimeout sets the maximum duration for DNS resolution requests.
|
||||||
|
//
|
||||||
|
// This function affects the global timeout used by all channels using the DNS
|
||||||
|
// name resolver scheme.
|
||||||
|
//
|
||||||
|
// It must be called only at application startup, before any gRPC calls are
|
||||||
|
// made. Modifying this value after initialization is not thread-safe.
|
||||||
|
//
|
||||||
|
// The default value is 30 seconds. Setting the timeout too low may result in
|
||||||
|
// premature timeouts during resolution, while setting it too high may lead to
|
||||||
|
// unnecessary delays in service discovery. Choose a value appropriate for your
|
||||||
|
// specific needs and network environment.
|
||||||
|
func SetResolvingTimeout(timeout time.Duration) {
|
||||||
|
dns.ResolvingTimeout = timeout
|
||||||
|
}
|
||||||
|
|
||||||
// NewBuilder creates a dnsBuilder which is used to factory DNS resolvers.
|
// NewBuilder creates a dnsBuilder which is used to factory DNS resolvers.
|
||||||
//
|
//
|
||||||
// Deprecated: import grpc and use resolver.Get("dns") instead.
|
// Deprecated: import grpc and use resolver.Get("dns") instead.
|
||||||
func NewBuilder() resolver.Builder {
|
func NewBuilder() resolver.Builder {
|
||||||
return dns.NewBuilder()
|
return dns.NewBuilder()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetMinResolutionInterval sets the default minimum interval at which DNS
|
||||||
|
// re-resolutions are allowed. This helps to prevent excessive re-resolution.
|
||||||
|
//
|
||||||
|
// It must be called only at application startup, before any gRPC calls are
|
||||||
|
// made. Modifying this value after initialization is not thread-safe.
|
||||||
|
func SetMinResolutionInterval(d time.Duration) {
|
||||||
|
dns.MinResolutionInterval = d
|
||||||
|
}
|
||||||
|
11
vendor/google.golang.org/grpc/resolver/resolver.go
generated
vendored
11
vendor/google.golang.org/grpc/resolver/resolver.go
generated
vendored
@ -29,6 +29,7 @@ import (
|
|||||||
|
|
||||||
"google.golang.org/grpc/attributes"
|
"google.golang.org/grpc/attributes"
|
||||||
"google.golang.org/grpc/credentials"
|
"google.golang.org/grpc/credentials"
|
||||||
|
"google.golang.org/grpc/internal"
|
||||||
"google.golang.org/grpc/serviceconfig"
|
"google.golang.org/grpc/serviceconfig"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -63,16 +64,18 @@ func Get(scheme string) Builder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetDefaultScheme sets the default scheme that will be used. The default
|
// SetDefaultScheme sets the default scheme that will be used. The default
|
||||||
// default scheme is "passthrough".
|
// scheme is initially set to "passthrough".
|
||||||
//
|
//
|
||||||
// NOTE: this function must only be called during initialization time (i.e. in
|
// NOTE: this function must only be called during initialization time (i.e. in
|
||||||
// an init() function), and is not thread-safe. The scheme set last overrides
|
// an init() function), and is not thread-safe. The scheme set last overrides
|
||||||
// previously set values.
|
// previously set values.
|
||||||
func SetDefaultScheme(scheme string) {
|
func SetDefaultScheme(scheme string) {
|
||||||
defaultScheme = scheme
|
defaultScheme = scheme
|
||||||
|
internal.UserSetDefaultScheme = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetDefaultScheme gets the default scheme that will be used.
|
// GetDefaultScheme gets the default scheme that will be used by grpc.Dial. If
|
||||||
|
// SetDefaultScheme is never called, the default scheme used by grpc.NewClient is "dns" instead.
|
||||||
func GetDefaultScheme() string {
|
func GetDefaultScheme() string {
|
||||||
return defaultScheme
|
return defaultScheme
|
||||||
}
|
}
|
||||||
@ -284,9 +287,9 @@ func (t Target) Endpoint() string {
|
|||||||
return strings.TrimPrefix(endpoint, "/")
|
return strings.TrimPrefix(endpoint, "/")
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns a string representation of Target.
|
// String returns the canonical string representation of Target.
|
||||||
func (t Target) String() string {
|
func (t Target) String() string {
|
||||||
return t.URL.String()
|
return t.URL.Scheme + "://" + t.URL.Host + "/" + t.Endpoint()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Builder creates a resolver that will be used to watch name resolution updates.
|
// Builder creates a resolver that will be used to watch name resolution updates.
|
||||||
|
6
vendor/google.golang.org/grpc/resolver_wrapper.go
generated
vendored
6
vendor/google.golang.org/grpc/resolver_wrapper.go
generated
vendored
@ -97,7 +97,7 @@ func (ccr *ccResolverWrapper) resolveNow(o resolver.ResolveNowOptions) {
|
|||||||
// finished shutting down, the channel should block on ccr.serializer.Done()
|
// finished shutting down, the channel should block on ccr.serializer.Done()
|
||||||
// without cc.mu held.
|
// without cc.mu held.
|
||||||
func (ccr *ccResolverWrapper) close() {
|
func (ccr *ccResolverWrapper) close() {
|
||||||
channelz.Info(logger, ccr.cc.channelzID, "Closing the name resolver")
|
channelz.Info(logger, ccr.cc.channelz, "Closing the name resolver")
|
||||||
ccr.mu.Lock()
|
ccr.mu.Lock()
|
||||||
ccr.closed = true
|
ccr.closed = true
|
||||||
ccr.mu.Unlock()
|
ccr.mu.Unlock()
|
||||||
@ -147,7 +147,7 @@ func (ccr *ccResolverWrapper) ReportError(err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
ccr.mu.Unlock()
|
ccr.mu.Unlock()
|
||||||
channelz.Warningf(logger, ccr.cc.channelzID, "ccResolverWrapper: reporting error to cc: %v", err)
|
channelz.Warningf(logger, ccr.cc.channelz, "ccResolverWrapper: reporting error to cc: %v", err)
|
||||||
ccr.cc.updateResolverStateAndUnlock(resolver.State{}, err)
|
ccr.cc.updateResolverStateAndUnlock(resolver.State{}, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,5 +194,5 @@ func (ccr *ccResolverWrapper) addChannelzTraceEvent(s resolver.State) {
|
|||||||
} else if len(ccr.curState.Addresses) == 0 && len(s.Addresses) > 0 {
|
} else if len(ccr.curState.Addresses) == 0 && len(s.Addresses) > 0 {
|
||||||
updates = append(updates, "resolver returned new addresses")
|
updates = append(updates, "resolver returned new addresses")
|
||||||
}
|
}
|
||||||
channelz.Infof(logger, ccr.cc.channelzID, "Resolver state updated: %s (%v)", pretty.ToJSON(s), strings.Join(updates, "; "))
|
channelz.Infof(logger, ccr.cc.channelz, "Resolver state updated: %s (%v)", pretty.ToJSON(s), strings.Join(updates, "; "))
|
||||||
}
|
}
|
||||||
|
16
vendor/google.golang.org/grpc/rpc_util.go
generated
vendored
16
vendor/google.golang.org/grpc/rpc_util.go
generated
vendored
@ -962,22 +962,9 @@ func setCallInfoCodec(c *callInfo) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// channelzData is used to store channelz related data for ClientConn, addrConn and Server.
|
|
||||||
// These fields cannot be embedded in the original structs (e.g. ClientConn), since to do atomic
|
|
||||||
// operation on int64 variable on 32-bit machine, user is responsible to enforce memory alignment.
|
|
||||||
// Here, by grouping those int64 fields inside a struct, we are enforcing the alignment.
|
|
||||||
type channelzData struct {
|
|
||||||
callsStarted int64
|
|
||||||
callsFailed int64
|
|
||||||
callsSucceeded int64
|
|
||||||
// lastCallStartedTime stores the timestamp that last call starts. It is of int64 type instead of
|
|
||||||
// time.Time since it's more costly to atomically update time.Time variable than int64 variable.
|
|
||||||
lastCallStartedTime int64
|
|
||||||
}
|
|
||||||
|
|
||||||
// The SupportPackageIsVersion variables are referenced from generated protocol
|
// The SupportPackageIsVersion variables are referenced from generated protocol
|
||||||
// buffer files to ensure compatibility with the gRPC version used. The latest
|
// buffer files to ensure compatibility with the gRPC version used. The latest
|
||||||
// support package version is 7.
|
// support package version is 9.
|
||||||
//
|
//
|
||||||
// Older versions are kept for compatibility.
|
// Older versions are kept for compatibility.
|
||||||
//
|
//
|
||||||
@ -989,6 +976,7 @@ const (
|
|||||||
SupportPackageIsVersion6 = true
|
SupportPackageIsVersion6 = true
|
||||||
SupportPackageIsVersion7 = true
|
SupportPackageIsVersion7 = true
|
||||||
SupportPackageIsVersion8 = true
|
SupportPackageIsVersion8 = true
|
||||||
|
SupportPackageIsVersion9 = true
|
||||||
)
|
)
|
||||||
|
|
||||||
const grpcUA = "grpc-go/" + Version
|
const grpcUA = "grpc-go/" + Version
|
||||||
|
110
vendor/google.golang.org/grpc/server.go
generated
vendored
110
vendor/google.golang.org/grpc/server.go
generated
vendored
@ -137,8 +137,7 @@ type Server struct {
|
|||||||
serveWG sync.WaitGroup // counts active Serve goroutines for Stop/GracefulStop
|
serveWG sync.WaitGroup // counts active Serve goroutines for Stop/GracefulStop
|
||||||
handlersWG sync.WaitGroup // counts active method handler goroutines
|
handlersWG sync.WaitGroup // counts active method handler goroutines
|
||||||
|
|
||||||
channelzID *channelz.Identifier
|
channelz *channelz.Server
|
||||||
czData *channelzData
|
|
||||||
|
|
||||||
serverWorkerChannel chan func()
|
serverWorkerChannel chan func()
|
||||||
serverWorkerChannelClose func()
|
serverWorkerChannelClose func()
|
||||||
@ -249,11 +248,9 @@ func SharedWriteBuffer(val bool) ServerOption {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// WriteBufferSize determines how much data can be batched before doing a write
|
// WriteBufferSize determines how much data can be batched before doing a write
|
||||||
// on the wire. The corresponding memory allocation for this buffer will be
|
// on the wire. The default value for this buffer is 32KB. Zero or negative
|
||||||
// twice the size to keep syscalls low. The default value for this buffer is
|
// values will disable the write buffer such that each write will be on underlying
|
||||||
// 32KB. Zero or negative values will disable the write buffer such that each
|
// connection. Note: A Send call may not directly translate to a write.
|
||||||
// write will be on underlying connection.
|
|
||||||
// Note: A Send call may not directly translate to a write.
|
|
||||||
func WriteBufferSize(s int) ServerOption {
|
func WriteBufferSize(s int) ServerOption {
|
||||||
return newFuncServerOption(func(o *serverOptions) {
|
return newFuncServerOption(func(o *serverOptions) {
|
||||||
o.writeBufferSize = s
|
o.writeBufferSize = s
|
||||||
@ -530,12 +527,22 @@ func ConnectionTimeout(d time.Duration) ServerOption {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MaxHeaderListSizeServerOption is a ServerOption that sets the max
|
||||||
|
// (uncompressed) size of header list that the server is prepared to accept.
|
||||||
|
type MaxHeaderListSizeServerOption struct {
|
||||||
|
MaxHeaderListSize uint32
|
||||||
|
}
|
||||||
|
|
||||||
|
func (o MaxHeaderListSizeServerOption) apply(so *serverOptions) {
|
||||||
|
so.maxHeaderListSize = &o.MaxHeaderListSize
|
||||||
|
}
|
||||||
|
|
||||||
// MaxHeaderListSize returns a ServerOption that sets the max (uncompressed) size
|
// MaxHeaderListSize returns a ServerOption that sets the max (uncompressed) size
|
||||||
// of header list that the server is prepared to accept.
|
// of header list that the server is prepared to accept.
|
||||||
func MaxHeaderListSize(s uint32) ServerOption {
|
func MaxHeaderListSize(s uint32) ServerOption {
|
||||||
return newFuncServerOption(func(o *serverOptions) {
|
return MaxHeaderListSizeServerOption{
|
||||||
o.maxHeaderListSize = &s
|
MaxHeaderListSize: s,
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// HeaderTableSize returns a ServerOption that sets the size of dynamic
|
// HeaderTableSize returns a ServerOption that sets the size of dynamic
|
||||||
@ -661,7 +668,7 @@ func NewServer(opt ...ServerOption) *Server {
|
|||||||
services: make(map[string]*serviceInfo),
|
services: make(map[string]*serviceInfo),
|
||||||
quit: grpcsync.NewEvent(),
|
quit: grpcsync.NewEvent(),
|
||||||
done: grpcsync.NewEvent(),
|
done: grpcsync.NewEvent(),
|
||||||
czData: new(channelzData),
|
channelz: channelz.RegisterServer(""),
|
||||||
}
|
}
|
||||||
chainUnaryServerInterceptors(s)
|
chainUnaryServerInterceptors(s)
|
||||||
chainStreamServerInterceptors(s)
|
chainStreamServerInterceptors(s)
|
||||||
@ -675,8 +682,7 @@ func NewServer(opt ...ServerOption) *Server {
|
|||||||
s.initServerWorkers()
|
s.initServerWorkers()
|
||||||
}
|
}
|
||||||
|
|
||||||
s.channelzID = channelz.RegisterServer(&channelzServer{s}, "")
|
channelz.Info(logger, s.channelz, "Server created")
|
||||||
channelz.Info(logger, s.channelzID, "Server created")
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -802,20 +808,13 @@ var ErrServerStopped = errors.New("grpc: the server has been stopped")
|
|||||||
|
|
||||||
type listenSocket struct {
|
type listenSocket struct {
|
||||||
net.Listener
|
net.Listener
|
||||||
channelzID *channelz.Identifier
|
channelz *channelz.Socket
|
||||||
}
|
|
||||||
|
|
||||||
func (l *listenSocket) ChannelzMetric() *channelz.SocketInternalMetric {
|
|
||||||
return &channelz.SocketInternalMetric{
|
|
||||||
SocketOptions: channelz.GetSocketOption(l.Listener),
|
|
||||||
LocalAddr: l.Listener.Addr(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *listenSocket) Close() error {
|
func (l *listenSocket) Close() error {
|
||||||
err := l.Listener.Close()
|
err := l.Listener.Close()
|
||||||
channelz.RemoveEntry(l.channelzID)
|
channelz.RemoveEntry(l.channelz.ID)
|
||||||
channelz.Info(logger, l.channelzID, "ListenSocket deleted")
|
channelz.Info(logger, l.channelz, "ListenSocket deleted")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -857,7 +856,16 @@ func (s *Server) Serve(lis net.Listener) error {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ls := &listenSocket{Listener: lis}
|
ls := &listenSocket{
|
||||||
|
Listener: lis,
|
||||||
|
channelz: channelz.RegisterSocket(&channelz.Socket{
|
||||||
|
SocketType: channelz.SocketTypeListen,
|
||||||
|
Parent: s.channelz,
|
||||||
|
RefName: lis.Addr().String(),
|
||||||
|
LocalAddr: lis.Addr(),
|
||||||
|
SocketOptions: channelz.GetSocketOption(lis)},
|
||||||
|
),
|
||||||
|
}
|
||||||
s.lis[ls] = true
|
s.lis[ls] = true
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
@ -869,14 +877,8 @@ func (s *Server) Serve(lis net.Listener) error {
|
|||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
var err error
|
|
||||||
ls.channelzID, err = channelz.RegisterListenSocket(ls, s.channelzID, lis.Addr().String())
|
|
||||||
if err != nil {
|
|
||||||
s.mu.Unlock()
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
s.mu.Unlock()
|
s.mu.Unlock()
|
||||||
channelz.Info(logger, ls.channelzID, "ListenSocket created")
|
channelz.Info(logger, ls.channelz, "ListenSocket created")
|
||||||
|
|
||||||
var tempDelay time.Duration // how long to sleep on accept failure
|
var tempDelay time.Duration // how long to sleep on accept failure
|
||||||
for {
|
for {
|
||||||
@ -975,7 +977,7 @@ func (s *Server) newHTTP2Transport(c net.Conn) transport.ServerTransport {
|
|||||||
WriteBufferSize: s.opts.writeBufferSize,
|
WriteBufferSize: s.opts.writeBufferSize,
|
||||||
ReadBufferSize: s.opts.readBufferSize,
|
ReadBufferSize: s.opts.readBufferSize,
|
||||||
SharedWriteBuffer: s.opts.sharedWriteBuffer,
|
SharedWriteBuffer: s.opts.sharedWriteBuffer,
|
||||||
ChannelzParentID: s.channelzID,
|
ChannelzParent: s.channelz,
|
||||||
MaxHeaderListSize: s.opts.maxHeaderListSize,
|
MaxHeaderListSize: s.opts.maxHeaderListSize,
|
||||||
HeaderTableSize: s.opts.headerTableSize,
|
HeaderTableSize: s.opts.headerTableSize,
|
||||||
}
|
}
|
||||||
@ -989,7 +991,7 @@ func (s *Server) newHTTP2Transport(c net.Conn) transport.ServerTransport {
|
|||||||
if err != credentials.ErrConnDispatched {
|
if err != credentials.ErrConnDispatched {
|
||||||
// Don't log on ErrConnDispatched and io.EOF to prevent log spam.
|
// Don't log on ErrConnDispatched and io.EOF to prevent log spam.
|
||||||
if err != io.EOF {
|
if err != io.EOF {
|
||||||
channelz.Info(logger, s.channelzID, "grpc: Server.Serve failed to create ServerTransport: ", err)
|
channelz.Info(logger, s.channelz, "grpc: Server.Serve failed to create ServerTransport: ", err)
|
||||||
}
|
}
|
||||||
c.Close()
|
c.Close()
|
||||||
}
|
}
|
||||||
@ -1121,37 +1123,28 @@ func (s *Server) removeConn(addr string, st transport.ServerTransport) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) channelzMetric() *channelz.ServerInternalMetric {
|
|
||||||
return &channelz.ServerInternalMetric{
|
|
||||||
CallsStarted: atomic.LoadInt64(&s.czData.callsStarted),
|
|
||||||
CallsSucceeded: atomic.LoadInt64(&s.czData.callsSucceeded),
|
|
||||||
CallsFailed: atomic.LoadInt64(&s.czData.callsFailed),
|
|
||||||
LastCallStartedTimestamp: time.Unix(0, atomic.LoadInt64(&s.czData.lastCallStartedTime)),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) incrCallsStarted() {
|
func (s *Server) incrCallsStarted() {
|
||||||
atomic.AddInt64(&s.czData.callsStarted, 1)
|
s.channelz.ServerMetrics.CallsStarted.Add(1)
|
||||||
atomic.StoreInt64(&s.czData.lastCallStartedTime, time.Now().UnixNano())
|
s.channelz.ServerMetrics.LastCallStartedTimestamp.Store(time.Now().UnixNano())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) incrCallsSucceeded() {
|
func (s *Server) incrCallsSucceeded() {
|
||||||
atomic.AddInt64(&s.czData.callsSucceeded, 1)
|
s.channelz.ServerMetrics.CallsSucceeded.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) incrCallsFailed() {
|
func (s *Server) incrCallsFailed() {
|
||||||
atomic.AddInt64(&s.czData.callsFailed, 1)
|
s.channelz.ServerMetrics.CallsFailed.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) sendResponse(ctx context.Context, t transport.ServerTransport, stream *transport.Stream, msg any, cp Compressor, opts *transport.Options, comp encoding.Compressor) error {
|
func (s *Server) sendResponse(ctx context.Context, t transport.ServerTransport, stream *transport.Stream, msg any, cp Compressor, opts *transport.Options, comp encoding.Compressor) error {
|
||||||
data, err := encode(s.getCodec(stream.ContentSubtype()), msg)
|
data, err := encode(s.getCodec(stream.ContentSubtype()), msg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
channelz.Error(logger, s.channelzID, "grpc: server failed to encode response: ", err)
|
channelz.Error(logger, s.channelz, "grpc: server failed to encode response: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
compData, err := compress(data, cp, comp)
|
compData, err := compress(data, cp, comp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
channelz.Error(logger, s.channelzID, "grpc: server failed to compress response: ", err)
|
channelz.Error(logger, s.channelz, "grpc: server failed to compress response: ", err)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hdr, payload := msgHeader(data, compData)
|
hdr, payload := msgHeader(data, compData)
|
||||||
@ -1346,7 +1339,7 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
|
|||||||
d, cancel, err := recvAndDecompress(&parser{r: stream, recvBufferPool: s.opts.recvBufferPool}, stream, dc, s.opts.maxReceiveMessageSize, payInfo, decomp)
|
d, cancel, err := recvAndDecompress(&parser{r: stream, recvBufferPool: s.opts.recvBufferPool}, stream, dc, s.opts.maxReceiveMessageSize, payInfo, decomp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if e := t.WriteStatus(stream, status.Convert(err)); e != nil {
|
if e := t.WriteStatus(stream, status.Convert(err)); e != nil {
|
||||||
channelz.Warningf(logger, s.channelzID, "grpc: Server.processUnaryRPC failed to write status: %v", e)
|
channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -1397,7 +1390,7 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
|
|||||||
trInfo.tr.SetError()
|
trInfo.tr.SetError()
|
||||||
}
|
}
|
||||||
if e := t.WriteStatus(stream, appStatus); e != nil {
|
if e := t.WriteStatus(stream, appStatus); e != nil {
|
||||||
channelz.Warningf(logger, s.channelzID, "grpc: Server.processUnaryRPC failed to write status: %v", e)
|
channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e)
|
||||||
}
|
}
|
||||||
if len(binlogs) != 0 {
|
if len(binlogs) != 0 {
|
||||||
if h, _ := stream.Header(); h.Len() > 0 {
|
if h, _ := stream.Header(); h.Len() > 0 {
|
||||||
@ -1437,7 +1430,7 @@ func (s *Server) processUnaryRPC(ctx context.Context, t transport.ServerTranspor
|
|||||||
}
|
}
|
||||||
if sts, ok := status.FromError(err); ok {
|
if sts, ok := status.FromError(err); ok {
|
||||||
if e := t.WriteStatus(stream, sts); e != nil {
|
if e := t.WriteStatus(stream, sts); e != nil {
|
||||||
channelz.Warningf(logger, s.channelzID, "grpc: Server.processUnaryRPC failed to write status: %v", e)
|
channelz.Warningf(logger, s.channelz, "grpc: Server.processUnaryRPC failed to write status: %v", e)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch st := err.(type) {
|
switch st := err.(type) {
|
||||||
@ -1765,7 +1758,7 @@ func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Str
|
|||||||
ti.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true)
|
ti.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true)
|
||||||
ti.tr.SetError()
|
ti.tr.SetError()
|
||||||
}
|
}
|
||||||
channelz.Warningf(logger, s.channelzID, "grpc: Server.handleStream failed to write status: %v", err)
|
channelz.Warningf(logger, s.channelz, "grpc: Server.handleStream failed to write status: %v", err)
|
||||||
}
|
}
|
||||||
if ti != nil {
|
if ti != nil {
|
||||||
ti.tr.Finish()
|
ti.tr.Finish()
|
||||||
@ -1822,7 +1815,7 @@ func (s *Server) handleStream(t transport.ServerTransport, stream *transport.Str
|
|||||||
ti.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true)
|
ti.tr.LazyLog(&fmtStringer{"%v", []any{err}}, true)
|
||||||
ti.tr.SetError()
|
ti.tr.SetError()
|
||||||
}
|
}
|
||||||
channelz.Warningf(logger, s.channelzID, "grpc: Server.handleStream failed to write status: %v", err)
|
channelz.Warningf(logger, s.channelz, "grpc: Server.handleStream failed to write status: %v", err)
|
||||||
}
|
}
|
||||||
if ti != nil {
|
if ti != nil {
|
||||||
ti.tr.Finish()
|
ti.tr.Finish()
|
||||||
@ -1894,8 +1887,7 @@ func (s *Server) stop(graceful bool) {
|
|||||||
s.quit.Fire()
|
s.quit.Fire()
|
||||||
defer s.done.Fire()
|
defer s.done.Fire()
|
||||||
|
|
||||||
s.channelzRemoveOnce.Do(func() { channelz.RemoveEntry(s.channelzID) })
|
s.channelzRemoveOnce.Do(func() { channelz.RemoveEntry(s.channelz.ID) })
|
||||||
|
|
||||||
s.mu.Lock()
|
s.mu.Lock()
|
||||||
s.closeListenersLocked()
|
s.closeListenersLocked()
|
||||||
// Wait for serving threads to be ready to exit. Only then can we be sure no
|
// Wait for serving threads to be ready to exit. Only then can we be sure no
|
||||||
@ -2150,14 +2142,6 @@ func Method(ctx context.Context) (string, bool) {
|
|||||||
return s.Method(), true
|
return s.Method(), true
|
||||||
}
|
}
|
||||||
|
|
||||||
type channelzServer struct {
|
|
||||||
s *Server
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *channelzServer) ChannelzMetric() *channelz.ServerInternalMetric {
|
|
||||||
return c.s.channelzMetric()
|
|
||||||
}
|
|
||||||
|
|
||||||
// validateSendCompressor returns an error when given compressor name cannot be
|
// validateSendCompressor returns an error when given compressor name cannot be
|
||||||
// handled by the server or the client based on the advertised compressors.
|
// handled by the server or the client based on the advertised compressors.
|
||||||
func validateSendCompressor(name string, clientCompressors []string) error {
|
func validateSendCompressor(name string, clientCompressors []string) error {
|
||||||
|
49
vendor/google.golang.org/grpc/service_config.go
generated
vendored
49
vendor/google.golang.org/grpc/service_config.go
generated
vendored
@ -25,8 +25,10 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"google.golang.org/grpc/balancer"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/internal"
|
"google.golang.org/grpc/internal"
|
||||||
|
"google.golang.org/grpc/internal/balancer/gracefulswitch"
|
||||||
internalserviceconfig "google.golang.org/grpc/internal/serviceconfig"
|
internalserviceconfig "google.golang.org/grpc/internal/serviceconfig"
|
||||||
"google.golang.org/grpc/serviceconfig"
|
"google.golang.org/grpc/serviceconfig"
|
||||||
)
|
)
|
||||||
@ -41,11 +43,6 @@ const maxInt = int(^uint(0) >> 1)
|
|||||||
// https://github.com/grpc/grpc/blob/master/doc/service_config.md
|
// https://github.com/grpc/grpc/blob/master/doc/service_config.md
|
||||||
type MethodConfig = internalserviceconfig.MethodConfig
|
type MethodConfig = internalserviceconfig.MethodConfig
|
||||||
|
|
||||||
type lbConfig struct {
|
|
||||||
name string
|
|
||||||
cfg serviceconfig.LoadBalancingConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServiceConfig is provided by the service provider and contains parameters for how
|
// ServiceConfig is provided by the service provider and contains parameters for how
|
||||||
// clients that connect to the service should behave.
|
// clients that connect to the service should behave.
|
||||||
//
|
//
|
||||||
@ -55,14 +52,9 @@ type lbConfig struct {
|
|||||||
type ServiceConfig struct {
|
type ServiceConfig struct {
|
||||||
serviceconfig.Config
|
serviceconfig.Config
|
||||||
|
|
||||||
// LB is the load balancer the service providers recommends. This is
|
|
||||||
// deprecated; lbConfigs is preferred. If lbConfig and LB are both present,
|
|
||||||
// lbConfig will be used.
|
|
||||||
LB *string
|
|
||||||
|
|
||||||
// lbConfig is the service config's load balancing configuration. If
|
// lbConfig is the service config's load balancing configuration. If
|
||||||
// lbConfig and LB are both present, lbConfig will be used.
|
// lbConfig and LB are both present, lbConfig will be used.
|
||||||
lbConfig *lbConfig
|
lbConfig serviceconfig.LoadBalancingConfig
|
||||||
|
|
||||||
// Methods contains a map for the methods in this service. If there is an
|
// Methods contains a map for the methods in this service. If there is an
|
||||||
// exact match for a method (i.e. /service/method) in the map, use the
|
// exact match for a method (i.e. /service/method) in the map, use the
|
||||||
@ -164,7 +156,7 @@ type jsonMC struct {
|
|||||||
// TODO(lyuxuan): delete this struct after cleaning up old service config implementation.
|
// TODO(lyuxuan): delete this struct after cleaning up old service config implementation.
|
||||||
type jsonSC struct {
|
type jsonSC struct {
|
||||||
LoadBalancingPolicy *string
|
LoadBalancingPolicy *string
|
||||||
LoadBalancingConfig *internalserviceconfig.BalancerConfig
|
LoadBalancingConfig *json.RawMessage
|
||||||
MethodConfig *[]jsonMC
|
MethodConfig *[]jsonMC
|
||||||
RetryThrottling *retryThrottlingPolicy
|
RetryThrottling *retryThrottlingPolicy
|
||||||
HealthCheckConfig *healthCheckConfig
|
HealthCheckConfig *healthCheckConfig
|
||||||
@ -180,22 +172,37 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult {
|
|||||||
var rsc jsonSC
|
var rsc jsonSC
|
||||||
err := json.Unmarshal([]byte(js), &rsc)
|
err := json.Unmarshal([]byte(js), &rsc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warningf("grpc: unmarshaling service config %s: %v", js, err)
|
logger.Warningf("grpc: unmarshalling service config %s: %v", js, err)
|
||||||
return &serviceconfig.ParseResult{Err: err}
|
return &serviceconfig.ParseResult{Err: err}
|
||||||
}
|
}
|
||||||
sc := ServiceConfig{
|
sc := ServiceConfig{
|
||||||
LB: rsc.LoadBalancingPolicy,
|
|
||||||
Methods: make(map[string]MethodConfig),
|
Methods: make(map[string]MethodConfig),
|
||||||
retryThrottling: rsc.RetryThrottling,
|
retryThrottling: rsc.RetryThrottling,
|
||||||
healthCheckConfig: rsc.HealthCheckConfig,
|
healthCheckConfig: rsc.HealthCheckConfig,
|
||||||
rawJSONString: js,
|
rawJSONString: js,
|
||||||
}
|
}
|
||||||
if c := rsc.LoadBalancingConfig; c != nil {
|
c := rsc.LoadBalancingConfig
|
||||||
sc.lbConfig = &lbConfig{
|
if c == nil {
|
||||||
name: c.Name,
|
name := PickFirstBalancerName
|
||||||
cfg: c.Config,
|
if rsc.LoadBalancingPolicy != nil {
|
||||||
|
name = *rsc.LoadBalancingPolicy
|
||||||
}
|
}
|
||||||
|
if balancer.Get(name) == nil {
|
||||||
|
name = PickFirstBalancerName
|
||||||
|
}
|
||||||
|
cfg := []map[string]any{{name: struct{}{}}}
|
||||||
|
strCfg, err := json.Marshal(cfg)
|
||||||
|
if err != nil {
|
||||||
|
return &serviceconfig.ParseResult{Err: fmt.Errorf("unexpected error marshaling simple LB config: %w", err)}
|
||||||
|
}
|
||||||
|
r := json.RawMessage(strCfg)
|
||||||
|
c = &r
|
||||||
}
|
}
|
||||||
|
cfg, err := gracefulswitch.ParseConfig(*c)
|
||||||
|
if err != nil {
|
||||||
|
return &serviceconfig.ParseResult{Err: err}
|
||||||
|
}
|
||||||
|
sc.lbConfig = cfg
|
||||||
|
|
||||||
if rsc.MethodConfig == nil {
|
if rsc.MethodConfig == nil {
|
||||||
return &serviceconfig.ParseResult{Config: &sc}
|
return &serviceconfig.ParseResult{Config: &sc}
|
||||||
@ -212,7 +219,7 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult {
|
|||||||
Timeout: (*time.Duration)(m.Timeout),
|
Timeout: (*time.Duration)(m.Timeout),
|
||||||
}
|
}
|
||||||
if mc.RetryPolicy, err = convertRetryPolicy(m.RetryPolicy); err != nil {
|
if mc.RetryPolicy, err = convertRetryPolicy(m.RetryPolicy); err != nil {
|
||||||
logger.Warningf("grpc: unmarshaling service config %s: %v", js, err)
|
logger.Warningf("grpc: unmarshalling service config %s: %v", js, err)
|
||||||
return &serviceconfig.ParseResult{Err: err}
|
return &serviceconfig.ParseResult{Err: err}
|
||||||
}
|
}
|
||||||
if m.MaxRequestMessageBytes != nil {
|
if m.MaxRequestMessageBytes != nil {
|
||||||
@ -232,13 +239,13 @@ func parseServiceConfig(js string) *serviceconfig.ParseResult {
|
|||||||
for i, n := range *m.Name {
|
for i, n := range *m.Name {
|
||||||
path, err := n.generatePath()
|
path, err := n.generatePath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warningf("grpc: error unmarshaling service config %s due to methodConfig[%d]: %v", js, i, err)
|
logger.Warningf("grpc: error unmarshalling service config %s due to methodConfig[%d]: %v", js, i, err)
|
||||||
return &serviceconfig.ParseResult{Err: err}
|
return &serviceconfig.ParseResult{Err: err}
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := paths[path]; ok {
|
if _, ok := paths[path]; ok {
|
||||||
err = errDuplicatedName
|
err = errDuplicatedName
|
||||||
logger.Warningf("grpc: error unmarshaling service config %s due to methodConfig[%d]: %v", js, i, err)
|
logger.Warningf("grpc: error unmarshalling service config %s due to methodConfig[%d]: %v", js, i, err)
|
||||||
return &serviceconfig.ParseResult{Err: err}
|
return &serviceconfig.ParseResult{Err: err}
|
||||||
}
|
}
|
||||||
paths[path] = struct{}{}
|
paths[path] = struct{}{}
|
||||||
|
10
vendor/google.golang.org/grpc/stats/stats.go
generated
vendored
10
vendor/google.golang.org/grpc/stats/stats.go
generated
vendored
@ -73,9 +73,12 @@ func (*PickerUpdated) isRPCStats() {}
|
|||||||
type InPayload struct {
|
type InPayload struct {
|
||||||
// Client is true if this InPayload is from client side.
|
// Client is true if this InPayload is from client side.
|
||||||
Client bool
|
Client bool
|
||||||
// Payload is the payload with original type.
|
// Payload is the payload with original type. This may be modified after
|
||||||
|
// the call to HandleRPC which provides the InPayload returns and must be
|
||||||
|
// copied if needed later.
|
||||||
Payload any
|
Payload any
|
||||||
// Data is the serialized message payload.
|
// Data is the serialized message payload.
|
||||||
|
// Deprecated: Data will be removed in the next release.
|
||||||
Data []byte
|
Data []byte
|
||||||
|
|
||||||
// Length is the size of the uncompressed payload data. Does not include any
|
// Length is the size of the uncompressed payload data. Does not include any
|
||||||
@ -143,9 +146,12 @@ func (s *InTrailer) isRPCStats() {}
|
|||||||
type OutPayload struct {
|
type OutPayload struct {
|
||||||
// Client is true if this OutPayload is from client side.
|
// Client is true if this OutPayload is from client side.
|
||||||
Client bool
|
Client bool
|
||||||
// Payload is the payload with original type.
|
// Payload is the payload with original type. This may be modified after
|
||||||
|
// the call to HandleRPC which provides the OutPayload returns and must be
|
||||||
|
// copied if needed later.
|
||||||
Payload any
|
Payload any
|
||||||
// Data is the serialized message payload.
|
// Data is the serialized message payload.
|
||||||
|
// Deprecated: Data will be removed in the next release.
|
||||||
Data []byte
|
Data []byte
|
||||||
// Length is the size of the uncompressed payload data. Does not include any
|
// Length is the size of the uncompressed payload data. Does not include any
|
||||||
// framing (gRPC or HTTP/2).
|
// framing (gRPC or HTTP/2).
|
||||||
|
5
vendor/google.golang.org/grpc/stream.go
generated
vendored
5
vendor/google.golang.org/grpc/stream.go
generated
vendored
@ -516,6 +516,7 @@ func (a *csAttempt) newStream() error {
|
|||||||
return toRPCErr(nse.Err)
|
return toRPCErr(nse.Err)
|
||||||
}
|
}
|
||||||
a.s = s
|
a.s = s
|
||||||
|
a.ctx = s.Context()
|
||||||
a.p = &parser{r: s, recvBufferPool: a.cs.cc.dopts.recvBufferPool}
|
a.p = &parser{r: s, recvBufferPool: a.cs.cc.dopts.recvBufferPool}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -655,13 +656,13 @@ func (a *csAttempt) shouldRetry(err error) (bool, error) {
|
|||||||
if len(sps) == 1 {
|
if len(sps) == 1 {
|
||||||
var e error
|
var e error
|
||||||
if pushback, e = strconv.Atoi(sps[0]); e != nil || pushback < 0 {
|
if pushback, e = strconv.Atoi(sps[0]); e != nil || pushback < 0 {
|
||||||
channelz.Infof(logger, cs.cc.channelzID, "Server retry pushback specified to abort (%q).", sps[0])
|
channelz.Infof(logger, cs.cc.channelz, "Server retry pushback specified to abort (%q).", sps[0])
|
||||||
cs.retryThrottler.throttle() // This counts as a failure for throttling.
|
cs.retryThrottler.throttle() // This counts as a failure for throttling.
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
hasPushback = true
|
hasPushback = true
|
||||||
} else if len(sps) > 1 {
|
} else if len(sps) > 1 {
|
||||||
channelz.Warningf(logger, cs.cc.channelzID, "Server retry pushback specified multiple values (%q); not retrying.", sps)
|
channelz.Warningf(logger, cs.cc.channelz, "Server retry pushback specified multiple values (%q); not retrying.", sps)
|
||||||
cs.retryThrottler.throttle() // This counts as a failure for throttling.
|
cs.retryThrottler.throttle() // This counts as a failure for throttling.
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
152
vendor/google.golang.org/grpc/stream_interfaces.go
generated
vendored
Normal file
152
vendor/google.golang.org/grpc/stream_interfaces.go
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
/*
|
||||||
|
*
|
||||||
|
* Copyright 2024 gRPC authors.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package grpc
|
||||||
|
|
||||||
|
// ServerStreamingClient represents the client side of a server-streaming (one
|
||||||
|
// request, many responses) RPC. It is generic over the type of the response
|
||||||
|
// message. It is used in generated code.
|
||||||
|
type ServerStreamingClient[Res any] interface {
|
||||||
|
Recv() (*Res, error)
|
||||||
|
ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServerStreamingServer represents the server side of a server-streaming (one
|
||||||
|
// request, many responses) RPC. It is generic over the type of the response
|
||||||
|
// message. It is used in generated code.
|
||||||
|
type ServerStreamingServer[Res any] interface {
|
||||||
|
Send(*Res) error
|
||||||
|
ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientStreamingClient represents the client side of a client-streaming (many
|
||||||
|
// requests, one response) RPC. It is generic over both the type of the request
|
||||||
|
// message stream and the type of the unary response message. It is used in
|
||||||
|
// generated code.
|
||||||
|
type ClientStreamingClient[Req any, Res any] interface {
|
||||||
|
Send(*Req) error
|
||||||
|
CloseAndRecv() (*Res, error)
|
||||||
|
ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
// ClientStreamingServer represents the server side of a client-streaming (many
|
||||||
|
// requests, one response) RPC. It is generic over both the type of the request
|
||||||
|
// message stream and the type of the unary response message. It is used in
|
||||||
|
// generated code.
|
||||||
|
type ClientStreamingServer[Req any, Res any] interface {
|
||||||
|
Recv() (*Req, error)
|
||||||
|
SendAndClose(*Res) error
|
||||||
|
ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
// BidiStreamingClient represents the client side of a bidirectional-streaming
|
||||||
|
// (many requests, many responses) RPC. It is generic over both the type of the
|
||||||
|
// request message stream and the type of the response message stream. It is
|
||||||
|
// used in generated code.
|
||||||
|
type BidiStreamingClient[Req any, Res any] interface {
|
||||||
|
Send(*Req) error
|
||||||
|
Recv() (*Res, error)
|
||||||
|
ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
// BidiStreamingServer represents the server side of a bidirectional-streaming
|
||||||
|
// (many requests, many responses) RPC. It is generic over both the type of the
|
||||||
|
// request message stream and the type of the response message stream. It is
|
||||||
|
// used in generated code.
|
||||||
|
type BidiStreamingServer[Req any, Res any] interface {
|
||||||
|
Recv() (*Req, error)
|
||||||
|
Send(*Res) error
|
||||||
|
ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenericClientStream implements the ServerStreamingClient, ClientStreamingClient,
|
||||||
|
// and BidiStreamingClient interfaces. It is used in generated code.
|
||||||
|
type GenericClientStream[Req any, Res any] struct {
|
||||||
|
ClientStream
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ ServerStreamingClient[string] = (*GenericClientStream[int, string])(nil)
|
||||||
|
var _ ClientStreamingClient[int, string] = (*GenericClientStream[int, string])(nil)
|
||||||
|
var _ BidiStreamingClient[int, string] = (*GenericClientStream[int, string])(nil)
|
||||||
|
|
||||||
|
// Send pushes one message into the stream of requests to be consumed by the
|
||||||
|
// server. The type of message which can be sent is determined by the Req type
|
||||||
|
// parameter of the GenericClientStream receiver.
|
||||||
|
func (x *GenericClientStream[Req, Res]) Send(m *Req) error {
|
||||||
|
return x.ClientStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recv reads one message from the stream of responses generated by the server.
|
||||||
|
// The type of the message returned is determined by the Res type parameter
|
||||||
|
// of the GenericClientStream receiver.
|
||||||
|
func (x *GenericClientStream[Req, Res]) Recv() (*Res, error) {
|
||||||
|
m := new(Res)
|
||||||
|
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloseAndRecv closes the sending side of the stream, then receives the unary
|
||||||
|
// response from the server. The type of message which it returns is determined
|
||||||
|
// by the Res type parameter of the GenericClientStream receiver.
|
||||||
|
func (x *GenericClientStream[Req, Res]) CloseAndRecv() (*Res, error) {
|
||||||
|
if err := x.ClientStream.CloseSend(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
m := new(Res)
|
||||||
|
if err := x.ClientStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GenericServerStream implements the ServerStreamingServer, ClientStreamingServer,
|
||||||
|
// and BidiStreamingServer interfaces. It is used in generated code.
|
||||||
|
type GenericServerStream[Req any, Res any] struct {
|
||||||
|
ServerStream
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ ServerStreamingServer[string] = (*GenericServerStream[int, string])(nil)
|
||||||
|
var _ ClientStreamingServer[int, string] = (*GenericServerStream[int, string])(nil)
|
||||||
|
var _ BidiStreamingServer[int, string] = (*GenericServerStream[int, string])(nil)
|
||||||
|
|
||||||
|
// Send pushes one message into the stream of responses to be consumed by the
|
||||||
|
// client. The type of message which can be sent is determined by the Res
|
||||||
|
// type parameter of the serverStreamServer receiver.
|
||||||
|
func (x *GenericServerStream[Req, Res]) Send(m *Res) error {
|
||||||
|
return x.ServerStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// SendAndClose pushes the unary response to the client. The type of message
|
||||||
|
// which can be sent is determined by the Res type parameter of the
|
||||||
|
// clientStreamServer receiver.
|
||||||
|
func (x *GenericServerStream[Req, Res]) SendAndClose(m *Res) error {
|
||||||
|
return x.ServerStream.SendMsg(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Recv reads one message from the stream of requests generated by the client.
|
||||||
|
// The type of the message returned is determined by the Req type parameter
|
||||||
|
// of the clientStreamServer receiver.
|
||||||
|
func (x *GenericServerStream[Req, Res]) Recv() (*Req, error) {
|
||||||
|
m := new(Req)
|
||||||
|
if err := x.ServerStream.RecvMsg(m); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
2
vendor/google.golang.org/grpc/version.go
generated
vendored
2
vendor/google.golang.org/grpc/version.go
generated
vendored
@ -19,4 +19,4 @@
|
|||||||
package grpc
|
package grpc
|
||||||
|
|
||||||
// Version is the current grpc version.
|
// Version is the current grpc version.
|
||||||
const Version = "1.62.1"
|
const Version = "1.64.0"
|
||||||
|
190
vendor/google.golang.org/grpc/vet.sh
generated
vendored
190
vendor/google.golang.org/grpc/vet.sh
generated
vendored
@ -1,190 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -ex # Exit on error; debugging enabled.
|
|
||||||
set -o pipefail # Fail a pipe if any sub-command fails.
|
|
||||||
|
|
||||||
# not makes sure the command passed to it does not exit with a return code of 0.
|
|
||||||
not() {
|
|
||||||
# This is required instead of the earlier (! $COMMAND) because subshells and
|
|
||||||
# pipefail don't work the same on Darwin as in Linux.
|
|
||||||
! "$@"
|
|
||||||
}
|
|
||||||
|
|
||||||
die() {
|
|
||||||
echo "$@" >&2
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
fail_on_output() {
|
|
||||||
tee /dev/stderr | not read
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check to make sure it's safe to modify the user's git repo.
|
|
||||||
git status --porcelain | fail_on_output
|
|
||||||
|
|
||||||
# Undo any edits made by this script.
|
|
||||||
cleanup() {
|
|
||||||
git reset --hard HEAD
|
|
||||||
}
|
|
||||||
trap cleanup EXIT
|
|
||||||
|
|
||||||
PATH="${HOME}/go/bin:${GOROOT}/bin:${PATH}"
|
|
||||||
go version
|
|
||||||
|
|
||||||
if [[ "$1" = "-install" ]]; then
|
|
||||||
# Install the pinned versions as defined in module tools.
|
|
||||||
pushd ./test/tools
|
|
||||||
go install \
|
|
||||||
golang.org/x/tools/cmd/goimports \
|
|
||||||
honnef.co/go/tools/cmd/staticcheck \
|
|
||||||
github.com/client9/misspell/cmd/misspell
|
|
||||||
popd
|
|
||||||
if [[ -z "${VET_SKIP_PROTO}" ]]; then
|
|
||||||
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
|
|
||||||
PROTOBUF_VERSION=25.2 # a.k.a. v4.22.0 in pb.go files.
|
|
||||||
PROTOC_FILENAME=protoc-${PROTOBUF_VERSION}-linux-x86_64.zip
|
|
||||||
pushd /home/runner/go
|
|
||||||
wget https://github.com/google/protobuf/releases/download/v${PROTOBUF_VERSION}/${PROTOC_FILENAME}
|
|
||||||
unzip ${PROTOC_FILENAME}
|
|
||||||
bin/protoc --version
|
|
||||||
popd
|
|
||||||
elif not which protoc > /dev/null; then
|
|
||||||
die "Please install protoc into your path"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
exit 0
|
|
||||||
elif [[ "$#" -ne 0 ]]; then
|
|
||||||
die "Unknown argument(s): $*"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# - Check that generated proto files are up to date.
|
|
||||||
if [[ -z "${VET_SKIP_PROTO}" ]]; then
|
|
||||||
make proto && git status --porcelain 2>&1 | fail_on_output || \
|
|
||||||
(git status; git --no-pager diff; exit 1)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -n "${VET_ONLY_PROTO}" ]]; then
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# - Ensure all source files contain a copyright message.
|
|
||||||
# (Done in two parts because Darwin "git grep" has broken support for compound
|
|
||||||
# exclusion matches.)
|
|
||||||
(grep -L "DO NOT EDIT" $(git grep -L "\(Copyright [0-9]\{4,\} gRPC authors\)" -- '*.go') || true) | fail_on_output
|
|
||||||
|
|
||||||
# - Make sure all tests in grpc and grpc/test use leakcheck via Teardown.
|
|
||||||
not grep 'func Test[^(]' *_test.go
|
|
||||||
not grep 'func Test[^(]' test/*.go
|
|
||||||
|
|
||||||
# - Check for typos in test function names
|
|
||||||
git grep 'func (s) ' -- "*_test.go" | not grep -v 'func (s) Test'
|
|
||||||
git grep 'func [A-Z]' -- "*_test.go" | not grep -v 'func Test\|Benchmark\|Example'
|
|
||||||
|
|
||||||
# - Do not import x/net/context.
|
|
||||||
not git grep -l 'x/net/context' -- "*.go"
|
|
||||||
|
|
||||||
# - Do not import math/rand for real library code. Use internal/grpcrand for
|
|
||||||
# thread safety.
|
|
||||||
git grep -l '"math/rand"' -- "*.go" 2>&1 | not grep -v '^examples\|^interop/stress\|grpcrand\|^benchmark\|wrr_test'
|
|
||||||
|
|
||||||
# - Do not use "interface{}"; use "any" instead.
|
|
||||||
git grep -l 'interface{}' -- "*.go" 2>&1 | not grep -v '\.pb\.go\|protoc-gen-go-grpc\|grpc_testing_not_regenerate'
|
|
||||||
|
|
||||||
# - Do not call grpclog directly. Use grpclog.Component instead.
|
|
||||||
git grep -l -e 'grpclog.I' --or -e 'grpclog.W' --or -e 'grpclog.E' --or -e 'grpclog.F' --or -e 'grpclog.V' -- "*.go" | not grep -v '^grpclog/component.go\|^internal/grpctest/tlogger_test.go'
|
|
||||||
|
|
||||||
# - Ensure all ptypes proto packages are renamed when importing.
|
|
||||||
not git grep "\(import \|^\s*\)\"github.com/golang/protobuf/ptypes/" -- "*.go"
|
|
||||||
|
|
||||||
# - Ensure all usages of grpc_testing package are renamed when importing.
|
|
||||||
not git grep "\(import \|^\s*\)\"google.golang.org/grpc/interop/grpc_testing" -- "*.go"
|
|
||||||
|
|
||||||
# - Ensure all xds proto imports are renamed to *pb or *grpc.
|
|
||||||
git grep '"github.com/envoyproxy/go-control-plane/envoy' -- '*.go' ':(exclude)*.pb.go' | not grep -v 'pb "\|grpc "'
|
|
||||||
|
|
||||||
misspell -error .
|
|
||||||
|
|
||||||
# - gofmt, goimports, go vet, go mod tidy.
|
|
||||||
# Perform these checks on each module inside gRPC.
|
|
||||||
for MOD_FILE in $(find . -name 'go.mod'); do
|
|
||||||
MOD_DIR=$(dirname ${MOD_FILE})
|
|
||||||
pushd ${MOD_DIR}
|
|
||||||
go vet -all ./... | fail_on_output
|
|
||||||
gofmt -s -d -l . 2>&1 | fail_on_output
|
|
||||||
goimports -l . 2>&1 | not grep -vE "\.pb\.go"
|
|
||||||
|
|
||||||
go mod tidy -compat=1.19
|
|
||||||
git status --porcelain 2>&1 | fail_on_output || \
|
|
||||||
(git status; git --no-pager diff; exit 1)
|
|
||||||
popd
|
|
||||||
done
|
|
||||||
|
|
||||||
# - Collection of static analysis checks
|
|
||||||
SC_OUT="$(mktemp)"
|
|
||||||
staticcheck -go 1.19 -checks 'all' ./... > "${SC_OUT}" || true
|
|
||||||
|
|
||||||
# Error for anything other than checks that need exclusions.
|
|
||||||
grep -v "(ST1000)" "${SC_OUT}" | grep -v "(SA1019)" | grep -v "(ST1003)" | not grep -v "(ST1019)\|\(other import of\)"
|
|
||||||
|
|
||||||
# Exclude underscore checks for generated code.
|
|
||||||
grep "(ST1003)" "${SC_OUT}" | not grep -v '\(.pb.go:\)\|\(code_string_test.go:\)\|\(grpc_testing_not_regenerate\)'
|
|
||||||
|
|
||||||
# Error for duplicate imports not including grpc protos.
|
|
||||||
grep "(ST1019)\|\(other import of\)" "${SC_OUT}" | not grep -Fv 'XXXXX PleaseIgnoreUnused
|
|
||||||
channelz/grpc_channelz_v1"
|
|
||||||
go-control-plane/envoy
|
|
||||||
grpclb/grpc_lb_v1"
|
|
||||||
health/grpc_health_v1"
|
|
||||||
interop/grpc_testing"
|
|
||||||
orca/v3"
|
|
||||||
proto/grpc_gcp"
|
|
||||||
proto/grpc_lookup_v1"
|
|
||||||
reflection/grpc_reflection_v1"
|
|
||||||
reflection/grpc_reflection_v1alpha"
|
|
||||||
XXXXX PleaseIgnoreUnused'
|
|
||||||
|
|
||||||
# Error for any package comments not in generated code.
|
|
||||||
grep "(ST1000)" "${SC_OUT}" | not grep -v "\.pb\.go:"
|
|
||||||
|
|
||||||
# Only ignore the following deprecated types/fields/functions and exclude
|
|
||||||
# generated code.
|
|
||||||
grep "(SA1019)" "${SC_OUT}" | not grep -Fv 'XXXXX PleaseIgnoreUnused
|
|
||||||
XXXXX Protobuf related deprecation errors:
|
|
||||||
"github.com/golang/protobuf
|
|
||||||
.pb.go:
|
|
||||||
grpc_testing_not_regenerate
|
|
||||||
: ptypes.
|
|
||||||
proto.RegisterType
|
|
||||||
XXXXX gRPC internal usage deprecation errors:
|
|
||||||
"google.golang.org/grpc
|
|
||||||
: grpc.
|
|
||||||
: v1alpha.
|
|
||||||
: v1alphareflectionpb.
|
|
||||||
BalancerAttributes is deprecated:
|
|
||||||
CredsBundle is deprecated:
|
|
||||||
Metadata is deprecated: use Attributes instead.
|
|
||||||
NewSubConn is deprecated:
|
|
||||||
OverrideServerName is deprecated:
|
|
||||||
RemoveSubConn is deprecated:
|
|
||||||
SecurityVersion is deprecated:
|
|
||||||
Target is deprecated: Use the Target field in the BuildOptions instead.
|
|
||||||
UpdateAddresses is deprecated:
|
|
||||||
UpdateSubConnState is deprecated:
|
|
||||||
balancer.ErrTransientFailure is deprecated:
|
|
||||||
grpc/reflection/v1alpha/reflection.proto
|
|
||||||
XXXXX xDS deprecated fields we support
|
|
||||||
.ExactMatch
|
|
||||||
.PrefixMatch
|
|
||||||
.SafeRegexMatch
|
|
||||||
.SuffixMatch
|
|
||||||
GetContainsMatch
|
|
||||||
GetExactMatch
|
|
||||||
GetMatchSubjectAltNames
|
|
||||||
GetPrefixMatch
|
|
||||||
GetSafeRegexMatch
|
|
||||||
GetSuffixMatch
|
|
||||||
GetTlsCertificateCertificateProviderInstance
|
|
||||||
GetValidationContextCertificateProviderInstance
|
|
||||||
XXXXX PleaseIgnoreUnused'
|
|
||||||
|
|
||||||
echo SUCCESS
|
|
12
vendor/modules.txt
vendored
12
vendor/modules.txt
vendored
@ -147,8 +147,8 @@ github.com/containers/image/v5/version
|
|||||||
# github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01
|
# github.com/containers/libtrust v0.0.0-20230121012942-c1716e8a8d01
|
||||||
## explicit
|
## explicit
|
||||||
github.com/containers/libtrust
|
github.com/containers/libtrust
|
||||||
# github.com/containers/ocicrypt v1.1.10
|
# github.com/containers/ocicrypt v1.2.0
|
||||||
## explicit; go 1.20
|
## explicit; go 1.21
|
||||||
github.com/containers/ocicrypt
|
github.com/containers/ocicrypt
|
||||||
github.com/containers/ocicrypt/blockcipher
|
github.com/containers/ocicrypt/blockcipher
|
||||||
github.com/containers/ocicrypt/config
|
github.com/containers/ocicrypt/config
|
||||||
@ -277,7 +277,7 @@ github.com/felixge/httpsnoop
|
|||||||
github.com/go-jose/go-jose/v3
|
github.com/go-jose/go-jose/v3
|
||||||
github.com/go-jose/go-jose/v3/cipher
|
github.com/go-jose/go-jose/v3/cipher
|
||||||
github.com/go-jose/go-jose/v3/json
|
github.com/go-jose/go-jose/v3/json
|
||||||
# github.com/go-jose/go-jose/v4 v4.0.1
|
# github.com/go-jose/go-jose/v4 v4.0.2
|
||||||
## explicit; go 1.21
|
## explicit; go 1.21
|
||||||
github.com/go-jose/go-jose/v4
|
github.com/go-jose/go-jose/v4
|
||||||
github.com/go-jose/go-jose/v4/cipher
|
github.com/go-jose/go-jose/v4/cipher
|
||||||
@ -614,7 +614,7 @@ go.opentelemetry.io/otel/metric/embedded
|
|||||||
## explicit; go 1.20
|
## explicit; go 1.20
|
||||||
go.opentelemetry.io/otel/trace
|
go.opentelemetry.io/otel/trace
|
||||||
go.opentelemetry.io/otel/trace/embedded
|
go.opentelemetry.io/otel/trace/embedded
|
||||||
# golang.org/x/crypto v0.23.0
|
# golang.org/x/crypto v0.24.0
|
||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
golang.org/x/crypto/cast5
|
golang.org/x/crypto/cast5
|
||||||
golang.org/x/crypto/ed25519
|
golang.org/x/crypto/ed25519
|
||||||
@ -664,7 +664,7 @@ golang.org/x/sys/windows/registry
|
|||||||
# golang.org/x/term v0.21.0
|
# golang.org/x/term v0.21.0
|
||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
golang.org/x/term
|
golang.org/x/term
|
||||||
# golang.org/x/text v0.15.0
|
# golang.org/x/text v0.16.0
|
||||||
## explicit; go 1.18
|
## explicit; go 1.18
|
||||||
golang.org/x/text/secure/bidirule
|
golang.org/x/text/secure/bidirule
|
||||||
golang.org/x/text/transform
|
golang.org/x/text/transform
|
||||||
@ -673,7 +673,7 @@ golang.org/x/text/unicode/norm
|
|||||||
# google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237
|
# google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237
|
||||||
## explicit; go 1.19
|
## explicit; go 1.19
|
||||||
google.golang.org/genproto/googleapis/rpc/status
|
google.golang.org/genproto/googleapis/rpc/status
|
||||||
# google.golang.org/grpc v1.62.1
|
# google.golang.org/grpc v1.64.0
|
||||||
## explicit; go 1.19
|
## explicit; go 1.19
|
||||||
google.golang.org/grpc
|
google.golang.org/grpc
|
||||||
google.golang.org/grpc/attributes
|
google.golang.org/grpc/attributes
|
||||||
|
Loading…
Reference in New Issue
Block a user