diff --git a/CHANGELOG.md b/CHANGELOG.md index 0851e0540c9..db1b2eaa381 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ * [ENHANCEMENT] Parquet Storage: Allow Parquet Queryable to disable fallback to Store Gateway. #6920 * [ENHANCEMENT] Query Frontend: Add a `format_query` label value to the `op` label at `cortex_query_frontend_queries_total` metric. #6925 * [ENHANCEMENT] API: add request ID injection to context to enable tracking requests across downstream services. #6895 +* [ENHANCEMENT] gRPC: Add gRPC Channelz monitoring. #6950 * [BUGFIX] Ingester: Avoid error or early throttling when READONLY ingesters are present in the ring #6517 * [BUGFIX] Ingester: Fix labelset data race condition. #6573 * [BUGFIX] Compactor: Cleaner should not put deletion marker for blocks with no-compact marker. #6576 diff --git a/docs/configuration/config-file-reference.md b/docs/configuration/config-file-reference.md index f5d5aa2432f..5d5a4f4184f 100644 --- a/docs/configuration/config-file-reference.md +++ b/docs/configuration/config-file-reference.md @@ -5992,6 +5992,11 @@ grpc_tls_config: # CLI flag: -server.grpc.keepalive.ping-without-stream-allowed [grpc_server_ping_without_stream_allowed: | default = true] +# Enable Channelz for gRPC server. A web UI will be also exposed on the HTTP +# server at /channelz +# CLI flag: -server.enable-channelz +[enable_channelz: | default = false] + # Output log messages in the given format. Valid formats: [logfmt, json] # CLI flag: -log.format [log_format: | default = "logfmt"] diff --git a/go.mod b/go.mod index 043a61da101..2b5df756503 100644 --- a/go.mod +++ b/go.mod @@ -148,6 +148,7 @@ require ( github.com/fatih/color v1.18.0 // indirect github.com/felixge/httpsnoop v1.0.4 // indirect github.com/fsnotify/fsnotify v1.9.0 // indirect + github.com/go-chi/chi/v5 v5.0.7 // indirect github.com/go-ini/ini v1.67.0 // indirect github.com/go-jose/go-jose/v4 v4.0.5 // indirect github.com/go-logfmt/logfmt v0.6.0 // indirect @@ -229,6 +230,7 @@ require ( github.com/prometheus/otlptranslator v0.0.0-20250620074007-94f535e0c588 // indirect github.com/prometheus/sigv4 v0.2.0 // indirect github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect + github.com/rantav/go-grpc-channelz v0.0.4 // indirect github.com/redis/rueidis v1.0.61 // indirect github.com/rs/cors v1.11.1 // indirect github.com/rs/xid v1.6.0 // indirect @@ -299,7 +301,7 @@ require ( ) // Using cortex fork of weaveworks/common -replace github.com/weaveworks/common => github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1 +replace github.com/weaveworks/common => github.com/cortexproject/weaveworks-common v0.0.0-20250806170222-876764c695f2 // Override since git.apache.org is down. The docs say to fetch from github. replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999 diff --git a/go.sum b/go.sum index 461f204f903..8c6e8fe5302 100644 --- a/go.sum +++ b/go.sum @@ -243,8 +243,8 @@ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/cortexproject/promqlsmith v0.0.0-20250407233056-90db95b1a4e4 h1:dpo7kQ24uFSV6Zgm9/kB34TIUWjGmadlbKrM6fNfQko= github.com/cortexproject/promqlsmith v0.0.0-20250407233056-90db95b1a4e4/go.mod h1:jh6POgN18lXU133HBMfwr/1TjvBp8e5kL4ZtRsAPvGY= -github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1 h1:UoSixdl0sBUhfEOMpIGxFnJjp3/y/+nkw6Du7su05FE= -github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1/go.mod h1:7cl8fS/nivXe2DmBUUmr/3UGTJG2jVU2NRaIayR2Zjs= +github.com/cortexproject/weaveworks-common v0.0.0-20250806170222-876764c695f2 h1:F9AVQMNf48V02H6cB1hQpgbU6h7CkonGTmie9aMNHUw= +github.com/cortexproject/weaveworks-common v0.0.0-20250806170222-876764c695f2/go.mod h1:SnIoS7WUpqsW2y1VGA63VS2RNSAMXGireDhqW6ZZWLA= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/cristalhq/hedgedhttp v0.9.1 h1:g68L9cf8uUyQKQJwciD0A1Vgbsz+QgCjuB1I8FAsCDs= github.com/cristalhq/hedgedhttp v0.9.1/go.mod h1:XkqWU6qVMutbhW68NnzjWrGtH8NUx1UfYqGYtHVKIsI= @@ -327,6 +327,8 @@ github.com/fullstorydev/emulators/storage v0.0.0-20240401123056-edc69752f474/go. github.com/fxamacker/cbor/v2 v2.7.0 h1:iM5WgngdRBanHcxugY4JySA0nk1wZorNOpTgCMedv5E= github.com/fxamacker/cbor/v2 v2.7.0/go.mod h1:pxXPTn3joSm21Gbwsv0w9OSA2y1HFR9qXEeXQVeNoDQ= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= +github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= @@ -865,6 +867,8 @@ github.com/prometheus/sigv4 v0.2.0 h1:qDFKnHYFswJxdzGeRP63c4HlH3Vbn1Yf/Ao2zabtVX github.com/prometheus/sigv4 v0.2.0/go.mod h1:D04rqmAaPPEUkjRQxGqjoxdyJuyCh6E0M18fZr0zBiE= github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg= github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= +github.com/rantav/go-grpc-channelz v0.0.4 h1:8GvqhA6siQVBsZYzal3yHhyJ9YiHEJx7RtSH2Jvm9Co= +github.com/rantav/go-grpc-channelz v0.0.4/go.mod h1:HodrRmnnH1zXcEEfK7EJrI23YMPMT7uvyAYkq2JUIcI= github.com/redis/go-redis/v9 v9.8.0 h1:q3nRvjrlge/6UD7eTu/DSg2uYiU2mCL0G/uzBWqhicI= github.com/redis/go-redis/v9 v9.8.0/go.mod h1:huWgSWd8mW6+m0VPhJjSSQ+d6Nh1VICQ6Q5lHuCH/Iw= github.com/redis/rueidis v1.0.61 h1:AkbCMeTyjFSQraGaNYncg3unMCTYGr6Y8WOqGhDOQu4= diff --git a/vendor/github.com/go-chi/chi/v5/.gitignore b/vendor/github.com/go-chi/chi/v5/.gitignore new file mode 100644 index 00000000000..ba22c99a99e --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/.gitignore @@ -0,0 +1,3 @@ +.idea +*.sw? +.vscode diff --git a/vendor/github.com/go-chi/chi/v5/CHANGELOG.md b/vendor/github.com/go-chi/chi/v5/CHANGELOG.md new file mode 100644 index 00000000000..88c68c6d035 --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/CHANGELOG.md @@ -0,0 +1,315 @@ +# Changelog + +## v5.0.7 (2021-11-18) + +- History of changes: see https://github.com/go-chi/chi/compare/v5.0.6...v5.0.7 + + +## v5.0.6 (2021-11-15) + +- History of changes: see https://github.com/go-chi/chi/compare/v5.0.5...v5.0.6 + + +## v5.0.5 (2021-10-27) + +- History of changes: see https://github.com/go-chi/chi/compare/v5.0.4...v5.0.5 + + +## v5.0.4 (2021-08-29) + +- History of changes: see https://github.com/go-chi/chi/compare/v5.0.3...v5.0.4 + + +## v5.0.3 (2021-04-29) + +- History of changes: see https://github.com/go-chi/chi/compare/v5.0.2...v5.0.3 + + +## v5.0.2 (2021-03-25) + +- History of changes: see https://github.com/go-chi/chi/compare/v5.0.1...v5.0.2 + + +## v5.0.1 (2021-03-10) + +- Small improvements +- History of changes: see https://github.com/go-chi/chi/compare/v5.0.0...v5.0.1 + + +## v5.0.0 (2021-02-27) + +- chi v5, `github.com/go-chi/chi/v5` introduces the adoption of Go's SIV to adhere to the current state-of-the-tools in Go. +- chi v1.5.x did not work out as planned, as the Go tooling is too powerful and chi's adoption is too wide. + The most responsible thing to do for everyone's benefit is to just release v5 with SIV, so I present to you all, + chi v5 at `github.com/go-chi/chi/v5`. I hope someday the developer experience and ergonomics I've been seeking + will still come to fruition in some form, see https://github.com/golang/go/issues/44550 +- History of changes: see https://github.com/go-chi/chi/compare/v1.5.4...v5.0.0 + + +## v1.5.4 (2021-02-27) + +- Undo prior retraction in v1.5.3 as we prepare for v5.0.0 release +- History of changes: see https://github.com/go-chi/chi/compare/v1.5.3...v1.5.4 + + +## v1.5.3 (2021-02-21) + +- Update go.mod to go 1.16 with new retract directive marking all versions without prior go.mod support +- History of changes: see https://github.com/go-chi/chi/compare/v1.5.2...v1.5.3 + + +## v1.5.2 (2021-02-10) + +- Reverting allocation optimization as a precaution as go test -race fails. +- Minor improvements, see history below +- History of changes: see https://github.com/go-chi/chi/compare/v1.5.1...v1.5.2 + + +## v1.5.1 (2020-12-06) + +- Performance improvement: removing 1 allocation by foregoing context.WithValue, thank you @bouk for + your contribution (https://github.com/go-chi/chi/pull/555). Note: new benchmarks posted in README. +- `middleware.CleanPath`: new middleware that clean's request path of double slashes +- deprecate & remove `chi.ServerBaseContext` in favour of stdlib `http.Server#BaseContext` +- plus other tiny improvements, see full commit history below +- History of changes: see https://github.com/go-chi/chi/compare/v4.1.2...v1.5.1 + + +## v1.5.0 (2020-11-12) - now with go.mod support + +`chi` dates back to 2016 with it's original implementation as one of the first routers to adopt the newly introduced +context.Context api to the stdlib -- set out to design a router that is faster, more modular and simpler than anything +else out there -- while not introducing any custom handler types or dependencies. Today, `chi` still has zero dependencies, +and in many ways is future proofed from changes, given it's minimal nature. Between versions, chi's iterations have been very +incremental, with the architecture and api being the same today as it was originally designed in 2016. For this reason it +makes chi a pretty easy project to maintain, as well thanks to the many amazing community contributions over the years +to who all help make chi better (total of 86 contributors to date -- thanks all!). + +Chi has been an labour of love, art and engineering, with the goals to offer beautiful ergonomics, flexibility, performance +and simplicity when building HTTP services with Go. I've strived to keep the router very minimal in surface area / code size, +and always improving the code wherever possible -- and as of today the `chi` package is just 1082 lines of code (not counting +middlewares, which are all optional). As well, I don't have the exact metrics, but from my analysis and email exchanges from +companies and developers, chi is used by thousands of projects around the world -- thank you all as there is no better form of +joy for me than to have art I had started be helpful and enjoyed by others. And of course I use chi in all of my own projects too :) + +For me, the asthetics of chi's code and usage are very important. With the introduction of Go's module support +(which I'm a big fan of), chi's past versioning scheme choice to v2, v3 and v4 would mean I'd require the import path +of "github.com/go-chi/chi/v4", leading to the lengthy discussion at https://github.com/go-chi/chi/issues/462. +Haha, to some, you may be scratching your head why I've spent > 1 year stalling to adopt "/vXX" convention in the import +path -- which isn't horrible in general -- but for chi, I'm unable to accept it as I strive for perfection in it's API design, +aesthetics and simplicity. It just doesn't feel good to me given chi's simple nature -- I do not foresee a "v5" or "v6", +and upgrading between versions in the future will also be just incremental. + +I do understand versioning is a part of the API design as well, which is why the solution for a while has been to "do nothing", +as Go supports both old and new import paths with/out go.mod. However, now that Go module support has had time to iron out kinks and +is adopted everywhere, it's time for chi to get with the times. Luckily, I've discovered a path forward that will make me happy, +while also not breaking anyone's app who adopted a prior versioning from tags in v2/v3/v4. I've made an experimental release of +v1.5.0 with go.mod silently, and tested it with new and old projects, to ensure the developer experience is preserved, and it's +largely unnoticed. Fortunately, Go's toolchain will check the tags of a repo and consider the "latest" tag the one with go.mod. +However, you can still request a specific older tag such as v4.1.2, and everything will "just work". But new users can just +`go get github.com/go-chi/chi` or `go get github.com/go-chi/chi@latest` and they will get the latest version which contains +go.mod support, which is v1.5.0+. `chi` will not change very much over the years, just like it hasn't changed much from 4 years ago. +Therefore, we will stay on v1.x from here on, starting from v1.5.0. Any breaking changes will bump a "minor" release and +backwards-compatible improvements/fixes will bump a "tiny" release. + +For existing projects who want to upgrade to the latest go.mod version, run: `go get -u github.com/go-chi/chi@v1.5.0`, +which will get you on the go.mod version line (as Go's mod cache may still remember v4.x). Brand new systems can run +`go get -u github.com/go-chi/chi` or `go get -u github.com/go-chi/chi@latest` to install chi, which will install v1.5.0+ +built with go.mod support. + +My apologies to the developers who will disagree with the decisions above, but, hope you'll try it and see it's a very +minor request which is backwards compatible and won't break your existing installations. + +Cheers all, happy coding! + + +--- + + +## v4.1.2 (2020-06-02) + +- fix that handles MethodNotAllowed with path variables, thank you @caseyhadden for your contribution +- fix to replace nested wildcards correctly in RoutePattern, thank you @@unmultimedio for your contribution +- History of changes: see https://github.com/go-chi/chi/compare/v4.1.1...v4.1.2 + + +## v4.1.1 (2020-04-16) + +- fix for issue https://github.com/go-chi/chi/issues/411 which allows for overlapping regexp + route to the correct handler through a recursive tree search, thanks to @Jahaja for the PR/fix! +- new middleware.RouteHeaders as a simple router for request headers with wildcard support +- History of changes: see https://github.com/go-chi/chi/compare/v4.1.0...v4.1.1 + + +## v4.1.0 (2020-04-1) + +- middleware.LogEntry: Write method on interface now passes the response header + and an extra interface type useful for custom logger implementations. +- middleware.WrapResponseWriter: minor fix +- middleware.Recoverer: a bit prettier +- History of changes: see https://github.com/go-chi/chi/compare/v4.0.4...v4.1.0 + +## v4.0.4 (2020-03-24) + +- middleware.Recoverer: new pretty stack trace printing (https://github.com/go-chi/chi/pull/496) +- a few minor improvements and fixes +- History of changes: see https://github.com/go-chi/chi/compare/v4.0.3...v4.0.4 + + +## v4.0.3 (2020-01-09) + +- core: fix regexp routing to include default value when param is not matched +- middleware: rewrite of middleware.Compress +- middleware: suppress http.ErrAbortHandler in middleware.Recoverer +- History of changes: see https://github.com/go-chi/chi/compare/v4.0.2...v4.0.3 + + +## v4.0.2 (2019-02-26) + +- Minor fixes +- History of changes: see https://github.com/go-chi/chi/compare/v4.0.1...v4.0.2 + + +## v4.0.1 (2019-01-21) + +- Fixes issue with compress middleware: #382 #385 +- History of changes: see https://github.com/go-chi/chi/compare/v4.0.0...v4.0.1 + + +## v4.0.0 (2019-01-10) + +- chi v4 requires Go 1.10.3+ (or Go 1.9.7+) - we have deprecated support for Go 1.7 and 1.8 +- router: respond with 404 on router with no routes (#362) +- router: additional check to ensure wildcard is at the end of a url pattern (#333) +- middleware: deprecate use of http.CloseNotifier (#347) +- middleware: fix RedirectSlashes to include query params on redirect (#334) +- History of changes: see https://github.com/go-chi/chi/compare/v3.3.4...v4.0.0 + + +## v3.3.4 (2019-01-07) + +- Minor middleware improvements. No changes to core library/router. Moving v3 into its +- own branch as a version of chi for Go 1.7, 1.8, 1.9, 1.10, 1.11 +- History of changes: see https://github.com/go-chi/chi/compare/v3.3.3...v3.3.4 + + +## v3.3.3 (2018-08-27) + +- Minor release +- See https://github.com/go-chi/chi/compare/v3.3.2...v3.3.3 + + +## v3.3.2 (2017-12-22) + +- Support to route trailing slashes on mounted sub-routers (#281) +- middleware: new `ContentCharset` to check matching charsets. Thank you + @csucu for your community contribution! + + +## v3.3.1 (2017-11-20) + +- middleware: new `AllowContentType` handler for explicit whitelist of accepted request Content-Types +- middleware: new `SetHeader` handler for short-hand middleware to set a response header key/value +- Minor bug fixes + + +## v3.3.0 (2017-10-10) + +- New chi.RegisterMethod(method) to add support for custom HTTP methods, see _examples/custom-method for usage +- Deprecated LINK and UNLINK methods from the default list, please use `chi.RegisterMethod("LINK")` and `chi.RegisterMethod("UNLINK")` in an `init()` function + + +## v3.2.1 (2017-08-31) + +- Add new `Match(rctx *Context, method, path string) bool` method to `Routes` interface + and `Mux`. Match searches the mux's routing tree for a handler that matches the method/path +- Add new `RouteMethod` to `*Context` +- Add new `Routes` pointer to `*Context` +- Add new `middleware.GetHead` to route missing HEAD requests to GET handler +- Updated benchmarks (see README) + + +## v3.1.5 (2017-08-02) + +- Setup golint and go vet for the project +- As per golint, we've redefined `func ServerBaseContext(h http.Handler, baseCtx context.Context) http.Handler` + to `func ServerBaseContext(baseCtx context.Context, h http.Handler) http.Handler` + + +## v3.1.0 (2017-07-10) + +- Fix a few minor issues after v3 release +- Move `docgen` sub-pkg to https://github.com/go-chi/docgen +- Move `render` sub-pkg to https://github.com/go-chi/render +- Add new `URLFormat` handler to chi/middleware sub-pkg to make working with url mime + suffixes easier, ie. parsing `/articles/1.json` and `/articles/1.xml`. See comments in + https://github.com/go-chi/chi/blob/master/middleware/url_format.go for example usage. + + +## v3.0.0 (2017-06-21) + +- Major update to chi library with many exciting updates, but also some *breaking changes* +- URL parameter syntax changed from `/:id` to `/{id}` for even more flexible routing, such as + `/articles/{month}-{day}-{year}-{slug}`, `/articles/{id}`, and `/articles/{id}.{ext}` on the + same router +- Support for regexp for routing patterns, in the form of `/{paramKey:regExp}` for example: + `r.Get("/articles/{name:[a-z]+}", h)` and `chi.URLParam(r, "name")` +- Add `Method` and `MethodFunc` to `chi.Router` to allow routing definitions such as + `r.Method("GET", "/", h)` which provides a cleaner interface for custom handlers like + in `_examples/custom-handler` +- Deprecating `mux#FileServer` helper function. Instead, we encourage users to create their + own using file handler with the stdlib, see `_examples/fileserver` for an example +- Add support for LINK/UNLINK http methods via `r.Method()` and `r.MethodFunc()` +- Moved the chi project to its own organization, to allow chi-related community packages to + be easily discovered and supported, at: https://github.com/go-chi +- *NOTE:* please update your import paths to `"github.com/go-chi/chi"` +- *NOTE:* chi v2 is still available at https://github.com/go-chi/chi/tree/v2 + + +## v2.1.0 (2017-03-30) + +- Minor improvements and update to the chi core library +- Introduced a brand new `chi/render` sub-package to complete the story of building + APIs to offer a pattern for managing well-defined request / response payloads. Please + check out the updated `_examples/rest` example for how it works. +- Added `MethodNotAllowed(h http.HandlerFunc)` to chi.Router interface + + +## v2.0.0 (2017-01-06) + +- After many months of v2 being in an RC state with many companies and users running it in + production, the inclusion of some improvements to the middlewares, we are very pleased to + announce v2.0.0 of chi. + + +## v2.0.0-rc1 (2016-07-26) + +- Huge update! chi v2 is a large refactor targetting Go 1.7+. As of Go 1.7, the popular + community `"net/context"` package has been included in the standard library as `"context"` and + utilized by `"net/http"` and `http.Request` to managing deadlines, cancelation signals and other + request-scoped values. We're very excited about the new context addition and are proud to + introduce chi v2, a minimal and powerful routing package for building large HTTP services, + with zero external dependencies. Chi focuses on idiomatic design and encourages the use of + stdlib HTTP handlers and middlwares. +- chi v2 deprecates its `chi.Handler` interface and requires `http.Handler` or `http.HandlerFunc` +- chi v2 stores URL routing parameters and patterns in the standard request context: `r.Context()` +- chi v2 lower-level routing context is accessible by `chi.RouteContext(r.Context()) *chi.Context`, + which provides direct access to URL routing parameters, the routing path and the matching + routing patterns. +- Users upgrading from chi v1 to v2, need to: + 1. Update the old chi.Handler signature, `func(ctx context.Context, w http.ResponseWriter, r *http.Request)` to + the standard http.Handler: `func(w http.ResponseWriter, r *http.Request)` + 2. Use `chi.URLParam(r *http.Request, paramKey string) string` + or `URLParamFromCtx(ctx context.Context, paramKey string) string` to access a url parameter value + + +## v1.0.0 (2016-07-01) + +- Released chi v1 stable https://github.com/go-chi/chi/tree/v1.0.0 for Go 1.6 and older. + + +## v0.9.0 (2016-03-31) + +- Reuse context objects via sync.Pool for zero-allocation routing [#33](https://github.com/go-chi/chi/pull/33) +- BREAKING NOTE: due to subtle API changes, previously `chi.URLParams(ctx)["id"]` used to access url parameters + has changed to: `chi.URLParam(ctx, "id")` diff --git a/vendor/github.com/go-chi/chi/v5/CONTRIBUTING.md b/vendor/github.com/go-chi/chi/v5/CONTRIBUTING.md new file mode 100644 index 00000000000..c0ac2dfe853 --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/CONTRIBUTING.md @@ -0,0 +1,31 @@ +# Contributing + +## Prerequisites + +1. [Install Go][go-install]. +2. Download the sources and switch the working directory: + + ```bash + go get -u -d github.com/go-chi/chi + cd $GOPATH/src/github.com/go-chi/chi + ``` + +## Submitting a Pull Request + +A typical workflow is: + +1. [Fork the repository.][fork] [This tip maybe also helpful.][go-fork-tip] +2. [Create a topic branch.][branch] +3. Add tests for your change. +4. Run `go test`. If your tests pass, return to the step 3. +5. Implement the change and ensure the steps from the previous step pass. +6. Run `goimports -w .`, to ensure the new code conforms to Go formatting guideline. +7. [Add, commit and push your changes.][git-help] +8. [Submit a pull request.][pull-req] + +[go-install]: https://golang.org/doc/install +[go-fork-tip]: http://blog.campoy.cat/2014/03/github-and-go-forking-pull-requests-and.html +[fork]: https://help.github.com/articles/fork-a-repo +[branch]: http://learn.github.com/p/branching.html +[git-help]: https://guides.github.com +[pull-req]: https://help.github.com/articles/using-pull-requests diff --git a/vendor/github.com/go-chi/chi/v5/LICENSE b/vendor/github.com/go-chi/chi/v5/LICENSE new file mode 100644 index 00000000000..d99f02ffac5 --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2015-present Peter Kieltyka (https://github.com/pkieltyka), Google Inc. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/github.com/go-chi/chi/v5/Makefile b/vendor/github.com/go-chi/chi/v5/Makefile new file mode 100644 index 00000000000..970a219684d --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/Makefile @@ -0,0 +1,18 @@ +all: + @echo "**********************************************************" + @echo "** chi build tool **" + @echo "**********************************************************" + + +test: + go clean -testcache && $(MAKE) test-router && $(MAKE) test-middleware + +test-router: + go test -race -v . + +test-middleware: + go test -race -v ./middleware + +.PHONY: docs +docs: + npx docsify-cli serve ./docs diff --git a/vendor/github.com/go-chi/chi/v5/README.md b/vendor/github.com/go-chi/chi/v5/README.md new file mode 100644 index 00000000000..5d504d18c19 --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/README.md @@ -0,0 +1,500 @@ +# chi + + +[![GoDoc Widget]][GoDoc] [![Travis Widget]][Travis] + +`chi` is a lightweight, idiomatic and composable router for building Go HTTP services. It's +especially good at helping you write large REST API services that are kept maintainable as your +project grows and changes. `chi` is built on the new `context` package introduced in Go 1.7 to +handle signaling, cancelation and request-scoped values across a handler chain. + +The focus of the project has been to seek out an elegant and comfortable design for writing +REST API servers, written during the development of the Pressly API service that powers our +public API service, which in turn powers all of our client-side applications. + +The key considerations of chi's design are: project structure, maintainability, standard http +handlers (stdlib-only), developer productivity, and deconstructing a large system into many small +parts. The core router `github.com/go-chi/chi` is quite small (less than 1000 LOC), but we've also +included some useful/optional subpackages: [middleware](/middleware), [render](https://github.com/go-chi/render) +and [docgen](https://github.com/go-chi/docgen). We hope you enjoy it too! + +## Install + +`go get -u github.com/go-chi/chi/v5` + + +## Features + +* **Lightweight** - cloc'd in ~1000 LOC for the chi router +* **Fast** - yes, see [benchmarks](#benchmarks) +* **100% compatible with net/http** - use any http or middleware pkg in the ecosystem that is also compatible with `net/http` +* **Designed for modular/composable APIs** - middlewares, inline middlewares, route groups and sub-router mounting +* **Context control** - built on new `context` package, providing value chaining, cancellations and timeouts +* **Robust** - in production at Pressly, CloudFlare, Heroku, 99Designs, and many others (see [discussion](https://github.com/go-chi/chi/issues/91)) +* **Doc generation** - `docgen` auto-generates routing documentation from your source to JSON or Markdown +* **Go.mod support** - as of v5, go.mod support (see [CHANGELOG](https://github.com/go-chi/chi/blob/master/CHANGELOG.md)) +* **No external dependencies** - plain ol' Go stdlib + net/http + + +## Examples + +See [_examples/](https://github.com/go-chi/chi/blob/master/_examples/) for a variety of examples. + + +**As easy as:** + +```go +package main + +import ( + "net/http" + + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" +) + +func main() { + r := chi.NewRouter() + r.Use(middleware.Logger) + r.Get("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("welcome")) + }) + http.ListenAndServe(":3000", r) +} +``` + +**REST Preview:** + +Here is a little preview of how routing looks like with chi. Also take a look at the generated routing docs +in JSON ([routes.json](https://github.com/go-chi/chi/blob/master/_examples/rest/routes.json)) and in +Markdown ([routes.md](https://github.com/go-chi/chi/blob/master/_examples/rest/routes.md)). + +I highly recommend reading the source of the [examples](https://github.com/go-chi/chi/blob/master/_examples/) listed +above, they will show you all the features of chi and serve as a good form of documentation. + +```go +import ( + //... + "context" + "github.com/go-chi/chi/v5" + "github.com/go-chi/chi/v5/middleware" +) + +func main() { + r := chi.NewRouter() + + // A good base middleware stack + r.Use(middleware.RequestID) + r.Use(middleware.RealIP) + r.Use(middleware.Logger) + r.Use(middleware.Recoverer) + + // Set a timeout value on the request context (ctx), that will signal + // through ctx.Done() that the request has timed out and further + // processing should be stopped. + r.Use(middleware.Timeout(60 * time.Second)) + + r.Get("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte("hi")) + }) + + // RESTy routes for "articles" resource + r.Route("/articles", func(r chi.Router) { + r.With(paginate).Get("/", listArticles) // GET /articles + r.With(paginate).Get("/{month}-{day}-{year}", listArticlesByDate) // GET /articles/01-16-2017 + + r.Post("/", createArticle) // POST /articles + r.Get("/search", searchArticles) // GET /articles/search + + // Regexp url parameters: + r.Get("/{articleSlug:[a-z-]+}", getArticleBySlug) // GET /articles/home-is-toronto + + // Subrouters: + r.Route("/{articleID}", func(r chi.Router) { + r.Use(ArticleCtx) + r.Get("/", getArticle) // GET /articles/123 + r.Put("/", updateArticle) // PUT /articles/123 + r.Delete("/", deleteArticle) // DELETE /articles/123 + }) + }) + + // Mount the admin sub-router + r.Mount("/admin", adminRouter()) + + http.ListenAndServe(":3333", r) +} + +func ArticleCtx(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + articleID := chi.URLParam(r, "articleID") + article, err := dbGetArticle(articleID) + if err != nil { + http.Error(w, http.StatusText(404), 404) + return + } + ctx := context.WithValue(r.Context(), "article", article) + next.ServeHTTP(w, r.WithContext(ctx)) + }) +} + +func getArticle(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + article, ok := ctx.Value("article").(*Article) + if !ok { + http.Error(w, http.StatusText(422), 422) + return + } + w.Write([]byte(fmt.Sprintf("title:%s", article.Title))) +} + +// A completely separate router for administrator routes +func adminRouter() http.Handler { + r := chi.NewRouter() + r.Use(AdminOnly) + r.Get("/", adminIndex) + r.Get("/accounts", adminListAccounts) + return r +} + +func AdminOnly(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + perm, ok := ctx.Value("acl.permission").(YourPermissionType) + if !ok || !perm.IsAdmin() { + http.Error(w, http.StatusText(403), 403) + return + } + next.ServeHTTP(w, r) + }) +} +``` + + +## Router interface + +chi's router is based on a kind of [Patricia Radix trie](https://en.wikipedia.org/wiki/Radix_tree). +The router is fully compatible with `net/http`. + +Built on top of the tree is the `Router` interface: + +```go +// Router consisting of the core routing methods used by chi's Mux, +// using only the standard net/http. +type Router interface { + http.Handler + Routes + + // Use appends one or more middlewares onto the Router stack. + Use(middlewares ...func(http.Handler) http.Handler) + + // With adds inline middlewares for an endpoint handler. + With(middlewares ...func(http.Handler) http.Handler) Router + + // Group adds a new inline-Router along the current routing + // path, with a fresh middleware stack for the inline-Router. + Group(fn func(r Router)) Router + + // Route mounts a sub-Router along a `pattern`` string. + Route(pattern string, fn func(r Router)) Router + + // Mount attaches another http.Handler along ./pattern/* + Mount(pattern string, h http.Handler) + + // Handle and HandleFunc adds routes for `pattern` that matches + // all HTTP methods. + Handle(pattern string, h http.Handler) + HandleFunc(pattern string, h http.HandlerFunc) + + // Method and MethodFunc adds routes for `pattern` that matches + // the `method` HTTP method. + Method(method, pattern string, h http.Handler) + MethodFunc(method, pattern string, h http.HandlerFunc) + + // HTTP-method routing along `pattern` + Connect(pattern string, h http.HandlerFunc) + Delete(pattern string, h http.HandlerFunc) + Get(pattern string, h http.HandlerFunc) + Head(pattern string, h http.HandlerFunc) + Options(pattern string, h http.HandlerFunc) + Patch(pattern string, h http.HandlerFunc) + Post(pattern string, h http.HandlerFunc) + Put(pattern string, h http.HandlerFunc) + Trace(pattern string, h http.HandlerFunc) + + // NotFound defines a handler to respond whenever a route could + // not be found. + NotFound(h http.HandlerFunc) + + // MethodNotAllowed defines a handler to respond whenever a method is + // not allowed. + MethodNotAllowed(h http.HandlerFunc) +} + +// Routes interface adds two methods for router traversal, which is also +// used by the github.com/go-chi/docgen package to generate documentation for Routers. +type Routes interface { + // Routes returns the routing tree in an easily traversable structure. + Routes() []Route + + // Middlewares returns the list of middlewares in use by the router. + Middlewares() Middlewares + + // Match searches the routing tree for a handler that matches + // the method/path - similar to routing a http request, but without + // executing the handler thereafter. + Match(rctx *Context, method, path string) bool +} +``` + +Each routing method accepts a URL `pattern` and chain of `handlers`. The URL pattern +supports named params (ie. `/users/{userID}`) and wildcards (ie. `/admin/*`). URL parameters +can be fetched at runtime by calling `chi.URLParam(r, "userID")` for named parameters +and `chi.URLParam(r, "*")` for a wildcard parameter. + + +### Middleware handlers + +chi's middlewares are just stdlib net/http middleware handlers. There is nothing special +about them, which means the router and all the tooling is designed to be compatible and +friendly with any middleware in the community. This offers much better extensibility and reuse +of packages and is at the heart of chi's purpose. + +Here is an example of a standard net/http middleware where we assign a context key `"user"` +the value of `"123"`. This middleware sets a hypothetical user identifier on the request +context and calls the next handler in the chain. + +```go +// HTTP middleware setting a value on the request context +func MyMiddleware(next http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + // create new context from `r` request context, and assign key `"user"` + // to value of `"123"` + ctx := context.WithValue(r.Context(), "user", "123") + + // call the next handler in the chain, passing the response writer and + // the updated request object with the new context value. + // + // note: context.Context values are nested, so any previously set + // values will be accessible as well, and the new `"user"` key + // will be accessible from this point forward. + next.ServeHTTP(w, r.WithContext(ctx)) + }) +} +``` + + +### Request handlers + +chi uses standard net/http request handlers. This little snippet is an example of a http.Handler +func that reads a user identifier from the request context - hypothetically, identifying +the user sending an authenticated request, validated+set by a previous middleware handler. + +```go +// HTTP handler accessing data from the request context. +func MyRequestHandler(w http.ResponseWriter, r *http.Request) { + // here we read from the request context and fetch out `"user"` key set in + // the MyMiddleware example above. + user := r.Context().Value("user").(string) + + // respond to the client + w.Write([]byte(fmt.Sprintf("hi %s", user))) +} +``` + + +### URL parameters + +chi's router parses and stores URL parameters right onto the request context. Here is +an example of how to access URL params in your net/http handlers. And of course, middlewares +are able to access the same information. + +```go +// HTTP handler accessing the url routing parameters. +func MyRequestHandler(w http.ResponseWriter, r *http.Request) { + // fetch the url parameter `"userID"` from the request of a matching + // routing pattern. An example routing pattern could be: /users/{userID} + userID := chi.URLParam(r, "userID") + + // fetch `"key"` from the request context + ctx := r.Context() + key := ctx.Value("key").(string) + + // respond to the client + w.Write([]byte(fmt.Sprintf("hi %v, %v", userID, key))) +} +``` + + +## Middlewares + +chi comes equipped with an optional `middleware` package, providing a suite of standard +`net/http` middlewares. Please note, any middleware in the ecosystem that is also compatible +with `net/http` can be used with chi's mux. + +### Core middlewares + +---------------------------------------------------------------------------------------------------- +| chi/middleware Handler | description | +| :--------------------- | :---------------------------------------------------------------------- | +| [AllowContentEncoding] | Enforces a whitelist of request Content-Encoding headers | +| [AllowContentType] | Explicit whitelist of accepted request Content-Types | +| [BasicAuth] | Basic HTTP authentication | +| [Compress] | Gzip compression for clients that accept compressed responses | +| [ContentCharset] | Ensure charset for Content-Type request headers | +| [CleanPath] | Clean double slashes from request path | +| [GetHead] | Automatically route undefined HEAD requests to GET handlers | +| [Heartbeat] | Monitoring endpoint to check the servers pulse | +| [Logger] | Logs the start and end of each request with the elapsed processing time | +| [NoCache] | Sets response headers to prevent clients from caching | +| [Profiler] | Easily attach net/http/pprof to your routers | +| [RealIP] | Sets a http.Request's RemoteAddr to either X-Real-IP or X-Forwarded-For | +| [Recoverer] | Gracefully absorb panics and prints the stack trace | +| [RequestID] | Injects a request ID into the context of each request | +| [RedirectSlashes] | Redirect slashes on routing paths | +| [RouteHeaders] | Route handling for request headers | +| [SetHeader] | Short-hand middleware to set a response header key/value | +| [StripSlashes] | Strip slashes on routing paths | +| [Throttle] | Puts a ceiling on the number of concurrent requests | +| [Timeout] | Signals to the request context when the timeout deadline is reached | +| [URLFormat] | Parse extension from url and put it on request context | +| [WithValue] | Short-hand middleware to set a key/value on the request context | +---------------------------------------------------------------------------------------------------- + +[AllowContentEncoding]: https://pkg.go.dev/github.com/go-chi/chi/middleware#AllowContentEncoding +[AllowContentType]: https://pkg.go.dev/github.com/go-chi/chi/middleware#AllowContentType +[BasicAuth]: https://pkg.go.dev/github.com/go-chi/chi/middleware#BasicAuth +[Compress]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Compress +[ContentCharset]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ContentCharset +[CleanPath]: https://pkg.go.dev/github.com/go-chi/chi/middleware#CleanPath +[GetHead]: https://pkg.go.dev/github.com/go-chi/chi/middleware#GetHead +[GetReqID]: https://pkg.go.dev/github.com/go-chi/chi/middleware#GetReqID +[Heartbeat]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Heartbeat +[Logger]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Logger +[NoCache]: https://pkg.go.dev/github.com/go-chi/chi/middleware#NoCache +[Profiler]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Profiler +[RealIP]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RealIP +[Recoverer]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Recoverer +[RedirectSlashes]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RedirectSlashes +[RequestLogger]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RequestLogger +[RequestID]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RequestID +[RouteHeaders]: https://pkg.go.dev/github.com/go-chi/chi/middleware#RouteHeaders +[SetHeader]: https://pkg.go.dev/github.com/go-chi/chi/middleware#SetHeader +[StripSlashes]: https://pkg.go.dev/github.com/go-chi/chi/middleware#StripSlashes +[Throttle]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Throttle +[ThrottleBacklog]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ThrottleBacklog +[ThrottleWithOpts]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ThrottleWithOpts +[Timeout]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Timeout +[URLFormat]: https://pkg.go.dev/github.com/go-chi/chi/middleware#URLFormat +[WithLogEntry]: https://pkg.go.dev/github.com/go-chi/chi/middleware#WithLogEntry +[WithValue]: https://pkg.go.dev/github.com/go-chi/chi/middleware#WithValue +[Compressor]: https://pkg.go.dev/github.com/go-chi/chi/middleware#Compressor +[DefaultLogFormatter]: https://pkg.go.dev/github.com/go-chi/chi/middleware#DefaultLogFormatter +[EncoderFunc]: https://pkg.go.dev/github.com/go-chi/chi/middleware#EncoderFunc +[HeaderRoute]: https://pkg.go.dev/github.com/go-chi/chi/middleware#HeaderRoute +[HeaderRouter]: https://pkg.go.dev/github.com/go-chi/chi/middleware#HeaderRouter +[LogEntry]: https://pkg.go.dev/github.com/go-chi/chi/middleware#LogEntry +[LogFormatter]: https://pkg.go.dev/github.com/go-chi/chi/middleware#LogFormatter +[LoggerInterface]: https://pkg.go.dev/github.com/go-chi/chi/middleware#LoggerInterface +[ThrottleOpts]: https://pkg.go.dev/github.com/go-chi/chi/middleware#ThrottleOpts +[WrapResponseWriter]: https://pkg.go.dev/github.com/go-chi/chi/middleware#WrapResponseWriter + +### Extra middlewares & packages + +Please see https://github.com/go-chi for additional packages. + +-------------------------------------------------------------------------------------------------------------------- +| package | description | +|:---------------------------------------------------|:------------------------------------------------------------- +| [cors](https://github.com/go-chi/cors) | Cross-origin resource sharing (CORS) | +| [docgen](https://github.com/go-chi/docgen) | Print chi.Router routes at runtime | +| [jwtauth](https://github.com/go-chi/jwtauth) | JWT authentication | +| [hostrouter](https://github.com/go-chi/hostrouter) | Domain/host based request routing | +| [httplog](https://github.com/go-chi/httplog) | Small but powerful structured HTTP request logging | +| [httprate](https://github.com/go-chi/httprate) | HTTP request rate limiter | +| [httptracer](https://github.com/go-chi/httptracer) | HTTP request performance tracing library | +| [httpvcr](https://github.com/go-chi/httpvcr) | Write deterministic tests for external sources | +| [stampede](https://github.com/go-chi/stampede) | HTTP request coalescer | +-------------------------------------------------------------------------------------------------------------------- + + +## context? + +`context` is a tiny pkg that provides simple interface to signal context across call stacks +and goroutines. It was originally written by [Sameer Ajmani](https://github.com/Sajmani) +and is available in stdlib since go1.7. + +Learn more at https://blog.golang.org/context + +and.. +* Docs: https://golang.org/pkg/context +* Source: https://github.com/golang/go/tree/master/src/context + + +## Benchmarks + +The benchmark suite: https://github.com/pkieltyka/go-http-routing-benchmark + +Results as of Nov 29, 2020 with Go 1.15.5 on Linux AMD 3950x + +```shell +BenchmarkChi_Param 3075895 384 ns/op 400 B/op 2 allocs/op +BenchmarkChi_Param5 2116603 566 ns/op 400 B/op 2 allocs/op +BenchmarkChi_Param20 964117 1227 ns/op 400 B/op 2 allocs/op +BenchmarkChi_ParamWrite 2863413 420 ns/op 400 B/op 2 allocs/op +BenchmarkChi_GithubStatic 3045488 395 ns/op 400 B/op 2 allocs/op +BenchmarkChi_GithubParam 2204115 540 ns/op 400 B/op 2 allocs/op +BenchmarkChi_GithubAll 10000 113811 ns/op 81203 B/op 406 allocs/op +BenchmarkChi_GPlusStatic 3337485 359 ns/op 400 B/op 2 allocs/op +BenchmarkChi_GPlusParam 2825853 423 ns/op 400 B/op 2 allocs/op +BenchmarkChi_GPlus2Params 2471697 483 ns/op 400 B/op 2 allocs/op +BenchmarkChi_GPlusAll 194220 5950 ns/op 5200 B/op 26 allocs/op +BenchmarkChi_ParseStatic 3365324 356 ns/op 400 B/op 2 allocs/op +BenchmarkChi_ParseParam 2976614 404 ns/op 400 B/op 2 allocs/op +BenchmarkChi_Parse2Params 2638084 439 ns/op 400 B/op 2 allocs/op +BenchmarkChi_ParseAll 109567 11295 ns/op 10400 B/op 52 allocs/op +BenchmarkChi_StaticAll 16846 71308 ns/op 62802 B/op 314 allocs/op +``` + +Comparison with other routers: https://gist.github.com/pkieltyka/123032f12052520aaccab752bd3e78cc + +NOTE: the allocs in the benchmark above are from the calls to http.Request's +`WithContext(context.Context)` method that clones the http.Request, sets the `Context()` +on the duplicated (alloc'd) request and returns it the new request object. This is just +how setting context on a request in Go works. + + +## Credits + +* Carl Jackson for https://github.com/zenazn/goji + * Parts of chi's thinking comes from goji, and chi's middleware package + sources from goji. +* Armon Dadgar for https://github.com/armon/go-radix +* Contributions: [@VojtechVitek](https://github.com/VojtechVitek) + +We'll be more than happy to see [your contributions](./CONTRIBUTING.md)! + + +## Beyond REST + +chi is just a http router that lets you decompose request handling into many smaller layers. +Many companies use chi to write REST services for their public APIs. But, REST is just a convention +for managing state via HTTP, and there's a lot of other pieces required to write a complete client-server +system or network of microservices. + +Looking beyond REST, I also recommend some newer works in the field: +* [webrpc](https://github.com/webrpc/webrpc) - Web-focused RPC client+server framework with code-gen +* [gRPC](https://github.com/grpc/grpc-go) - Google's RPC framework via protobufs +* [graphql](https://github.com/99designs/gqlgen) - Declarative query language +* [NATS](https://nats.io) - lightweight pub-sub + + +## License + +Copyright (c) 2015-present [Peter Kieltyka](https://github.com/pkieltyka) + +Licensed under [MIT License](./LICENSE) + +[GoDoc]: https://pkg.go.dev/github.com/go-chi/chi?tab=versions +[GoDoc Widget]: https://godoc.org/github.com/go-chi/chi?status.svg +[Travis]: https://travis-ci.org/go-chi/chi +[Travis Widget]: https://travis-ci.org/go-chi/chi.svg?branch=master diff --git a/vendor/github.com/go-chi/chi/v5/chain.go b/vendor/github.com/go-chi/chi/v5/chain.go new file mode 100644 index 00000000000..a2278414f40 --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/chain.go @@ -0,0 +1,49 @@ +package chi + +import "net/http" + +// Chain returns a Middlewares type from a slice of middleware handlers. +func Chain(middlewares ...func(http.Handler) http.Handler) Middlewares { + return Middlewares(middlewares) +} + +// Handler builds and returns a http.Handler from the chain of middlewares, +// with `h http.Handler` as the final handler. +func (mws Middlewares) Handler(h http.Handler) http.Handler { + return &ChainHandler{h, chain(mws, h), mws} +} + +// HandlerFunc builds and returns a http.Handler from the chain of middlewares, +// with `h http.Handler` as the final handler. +func (mws Middlewares) HandlerFunc(h http.HandlerFunc) http.Handler { + return &ChainHandler{h, chain(mws, h), mws} +} + +// ChainHandler is a http.Handler with support for handler composition and +// execution. +type ChainHandler struct { + Endpoint http.Handler + chain http.Handler + Middlewares Middlewares +} + +func (c *ChainHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + c.chain.ServeHTTP(w, r) +} + +// chain builds a http.Handler composed of an inline middleware stack and endpoint +// handler in the order they are passed. +func chain(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler { + // Return ahead of time if there aren't any middlewares for the chain + if len(middlewares) == 0 { + return endpoint + } + + // Wrap the end handler with the middleware chain + h := middlewares[len(middlewares)-1](endpoint) + for i := len(middlewares) - 2; i >= 0; i-- { + h = middlewares[i](h) + } + + return h +} diff --git a/vendor/github.com/go-chi/chi/v5/chi.go b/vendor/github.com/go-chi/chi/v5/chi.go new file mode 100644 index 00000000000..d2e5354dc11 --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/chi.go @@ -0,0 +1,134 @@ +// +// Package chi is a small, idiomatic and composable router for building HTTP services. +// +// chi requires Go 1.10 or newer. +// +// Example: +// package main +// +// import ( +// "net/http" +// +// "github.com/go-chi/chi/v5" +// "github.com/go-chi/chi/v5/middleware" +// ) +// +// func main() { +// r := chi.NewRouter() +// r.Use(middleware.Logger) +// r.Use(middleware.Recoverer) +// +// r.Get("/", func(w http.ResponseWriter, r *http.Request) { +// w.Write([]byte("root.")) +// }) +// +// http.ListenAndServe(":3333", r) +// } +// +// See github.com/go-chi/chi/_examples/ for more in-depth examples. +// +// URL patterns allow for easy matching of path components in HTTP +// requests. The matching components can then be accessed using +// chi.URLParam(). All patterns must begin with a slash. +// +// A simple named placeholder {name} matches any sequence of characters +// up to the next / or the end of the URL. Trailing slashes on paths must +// be handled explicitly. +// +// A placeholder with a name followed by a colon allows a regular +// expression match, for example {number:\\d+}. The regular expression +// syntax is Go's normal regexp RE2 syntax, except that regular expressions +// including { or } are not supported, and / will never be +// matched. An anonymous regexp pattern is allowed, using an empty string +// before the colon in the placeholder, such as {:\\d+} +// +// The special placeholder of asterisk matches the rest of the requested +// URL. Any trailing characters in the pattern are ignored. This is the only +// placeholder which will match / characters. +// +// Examples: +// "/user/{name}" matches "/user/jsmith" but not "/user/jsmith/info" or "/user/jsmith/" +// "/user/{name}/info" matches "/user/jsmith/info" +// "/page/*" matches "/page/intro/latest" +// "/page/*/index" also matches "/page/intro/latest" +// "/date/{yyyy:\\d\\d\\d\\d}/{mm:\\d\\d}/{dd:\\d\\d}" matches "/date/2017/04/01" +// +package chi + +import "net/http" + +// NewRouter returns a new Mux object that implements the Router interface. +func NewRouter() *Mux { + return NewMux() +} + +// Router consisting of the core routing methods used by chi's Mux, +// using only the standard net/http. +type Router interface { + http.Handler + Routes + + // Use appends one or more middlewares onto the Router stack. + Use(middlewares ...func(http.Handler) http.Handler) + + // With adds inline middlewares for an endpoint handler. + With(middlewares ...func(http.Handler) http.Handler) Router + + // Group adds a new inline-Router along the current routing + // path, with a fresh middleware stack for the inline-Router. + Group(fn func(r Router)) Router + + // Route mounts a sub-Router along a `pattern`` string. + Route(pattern string, fn func(r Router)) Router + + // Mount attaches another http.Handler along ./pattern/* + Mount(pattern string, h http.Handler) + + // Handle and HandleFunc adds routes for `pattern` that matches + // all HTTP methods. + Handle(pattern string, h http.Handler) + HandleFunc(pattern string, h http.HandlerFunc) + + // Method and MethodFunc adds routes for `pattern` that matches + // the `method` HTTP method. + Method(method, pattern string, h http.Handler) + MethodFunc(method, pattern string, h http.HandlerFunc) + + // HTTP-method routing along `pattern` + Connect(pattern string, h http.HandlerFunc) + Delete(pattern string, h http.HandlerFunc) + Get(pattern string, h http.HandlerFunc) + Head(pattern string, h http.HandlerFunc) + Options(pattern string, h http.HandlerFunc) + Patch(pattern string, h http.HandlerFunc) + Post(pattern string, h http.HandlerFunc) + Put(pattern string, h http.HandlerFunc) + Trace(pattern string, h http.HandlerFunc) + + // NotFound defines a handler to respond whenever a route could + // not be found. + NotFound(h http.HandlerFunc) + + // MethodNotAllowed defines a handler to respond whenever a method is + // not allowed. + MethodNotAllowed(h http.HandlerFunc) +} + +// Routes interface adds two methods for router traversal, which is also +// used by the `docgen` subpackage to generation documentation for Routers. +type Routes interface { + // Routes returns the routing tree in an easily traversable structure. + Routes() []Route + + // Middlewares returns the list of middlewares in use by the router. + Middlewares() Middlewares + + // Match searches the routing tree for a handler that matches + // the method/path - similar to routing a http request, but without + // executing the handler thereafter. + Match(rctx *Context, method, path string) bool +} + +// Middlewares type is a slice of standard middleware handlers with methods +// to compose middleware chains and http.Handler's. +type Middlewares []func(http.Handler) http.Handler diff --git a/vendor/github.com/go-chi/chi/v5/context.go b/vendor/github.com/go-chi/chi/v5/context.go new file mode 100644 index 00000000000..814c2630121 --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/context.go @@ -0,0 +1,157 @@ +package chi + +import ( + "context" + "net/http" + "strings" +) + +// URLParam returns the url parameter from a http.Request object. +func URLParam(r *http.Request, key string) string { + if rctx := RouteContext(r.Context()); rctx != nil { + return rctx.URLParam(key) + } + return "" +} + +// URLParamFromCtx returns the url parameter from a http.Request Context. +func URLParamFromCtx(ctx context.Context, key string) string { + if rctx := RouteContext(ctx); rctx != nil { + return rctx.URLParam(key) + } + return "" +} + +// RouteContext returns chi's routing Context object from a +// http.Request Context. +func RouteContext(ctx context.Context) *Context { + val, _ := ctx.Value(RouteCtxKey).(*Context) + return val +} + +// NewRouteContext returns a new routing Context object. +func NewRouteContext() *Context { + return &Context{} +} + +var ( + // RouteCtxKey is the context.Context key to store the request context. + RouteCtxKey = &contextKey{"RouteContext"} +) + +// Context is the default routing context set on the root node of a +// request context to track route patterns, URL parameters and +// an optional routing path. +type Context struct { + Routes Routes + + // parentCtx is the parent of this one, for using Context as a + // context.Context directly. This is an optimization that saves + // 1 allocation. + parentCtx context.Context + + // Routing path/method override used during the route search. + // See Mux#routeHTTP method. + RoutePath string + RouteMethod string + + // URLParams are the stack of routeParams captured during the + // routing lifecycle across a stack of sub-routers. + URLParams RouteParams + + // Route parameters matched for the current sub-router. It is + // intentionally unexported so it cant be tampered. + routeParams RouteParams + + // The endpoint routing pattern that matched the request URI path + // or `RoutePath` of the current sub-router. This value will update + // during the lifecycle of a request passing through a stack of + // sub-routers. + routePattern string + + // Routing pattern stack throughout the lifecycle of the request, + // across all connected routers. It is a record of all matching + // patterns across a stack of sub-routers. + RoutePatterns []string + + // methodNotAllowed hint + methodNotAllowed bool +} + +// Reset a routing context to its initial state. +func (x *Context) Reset() { + x.Routes = nil + x.RoutePath = "" + x.RouteMethod = "" + x.RoutePatterns = x.RoutePatterns[:0] + x.URLParams.Keys = x.URLParams.Keys[:0] + x.URLParams.Values = x.URLParams.Values[:0] + + x.routePattern = "" + x.routeParams.Keys = x.routeParams.Keys[:0] + x.routeParams.Values = x.routeParams.Values[:0] + x.methodNotAllowed = false + x.parentCtx = nil +} + +// URLParam returns the corresponding URL parameter value from the request +// routing context. +func (x *Context) URLParam(key string) string { + for k := len(x.URLParams.Keys) - 1; k >= 0; k-- { + if x.URLParams.Keys[k] == key { + return x.URLParams.Values[k] + } + } + return "" +} + +// RoutePattern builds the routing pattern string for the particular +// request, at the particular point during routing. This means, the value +// will change throughout the execution of a request in a router. That is +// why its advised to only use this value after calling the next handler. +// +// For example, +// +// func Instrument(next http.Handler) http.Handler { +// return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { +// next.ServeHTTP(w, r) +// routePattern := chi.RouteContext(r.Context()).RoutePattern() +// measure(w, r, routePattern) +// }) +// } +func (x *Context) RoutePattern() string { + routePattern := strings.Join(x.RoutePatterns, "") + return replaceWildcards(routePattern) +} + +// replaceWildcards takes a route pattern and recursively replaces all +// occurrences of "/*/" to "/". +func replaceWildcards(p string) string { + if strings.Contains(p, "/*/") { + return replaceWildcards(strings.Replace(p, "/*/", "/", -1)) + } + + return p +} + +// RouteParams is a structure to track URL routing parameters efficiently. +type RouteParams struct { + Keys, Values []string +} + +// Add will append a URL parameter to the end of the route param +func (s *RouteParams) Add(key, value string) { + s.Keys = append(s.Keys, key) + s.Values = append(s.Values, value) +} + +// contextKey is a value for use with context.WithValue. It's used as +// a pointer so it fits in an interface{} without allocation. This technique +// for defining context keys was copied from Go 1.7's new use of context in net/http. +type contextKey struct { + name string +} + +func (k *contextKey) String() string { + return "chi context value " + k.name +} diff --git a/vendor/github.com/go-chi/chi/v5/mux.go b/vendor/github.com/go-chi/chi/v5/mux.go new file mode 100644 index 00000000000..fff6a3c5e3c --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/mux.go @@ -0,0 +1,485 @@ +package chi + +import ( + "context" + "fmt" + "net/http" + "strings" + "sync" +) + +var _ Router = &Mux{} + +// Mux is a simple HTTP route multiplexer that parses a request path, +// records any URL params, and executes an end handler. It implements +// the http.Handler interface and is friendly with the standard library. +// +// Mux is designed to be fast, minimal and offer a powerful API for building +// modular and composable HTTP services with a large set of handlers. It's +// particularly useful for writing large REST API services that break a handler +// into many smaller parts composed of middlewares and end handlers. +type Mux struct { + // The computed mux handler made of the chained middleware stack and + // the tree router + handler http.Handler + + // The radix trie router + tree *node + + // Custom method not allowed handler + methodNotAllowedHandler http.HandlerFunc + + // Controls the behaviour of middleware chain generation when a mux + // is registered as an inline group inside another mux. + parent *Mux + + // Routing context pool + pool *sync.Pool + + // Custom route not found handler + notFoundHandler http.HandlerFunc + + // The middleware stack + middlewares []func(http.Handler) http.Handler + + inline bool +} + +// NewMux returns a newly initialized Mux object that implements the Router +// interface. +func NewMux() *Mux { + mux := &Mux{tree: &node{}, pool: &sync.Pool{}} + mux.pool.New = func() interface{} { + return NewRouteContext() + } + return mux +} + +// ServeHTTP is the single method of the http.Handler interface that makes +// Mux interoperable with the standard library. It uses a sync.Pool to get and +// reuse routing contexts for each request. +func (mx *Mux) ServeHTTP(w http.ResponseWriter, r *http.Request) { + // Ensure the mux has some routes defined on the mux + if mx.handler == nil { + mx.NotFoundHandler().ServeHTTP(w, r) + return + } + + // Check if a routing context already exists from a parent router. + rctx, _ := r.Context().Value(RouteCtxKey).(*Context) + if rctx != nil { + mx.handler.ServeHTTP(w, r) + return + } + + // Fetch a RouteContext object from the sync pool, and call the computed + // mx.handler that is comprised of mx.middlewares + mx.routeHTTP. + // Once the request is finished, reset the routing context and put it back + // into the pool for reuse from another request. + rctx = mx.pool.Get().(*Context) + rctx.Reset() + rctx.Routes = mx + rctx.parentCtx = r.Context() + + // NOTE: r.WithContext() causes 2 allocations and context.WithValue() causes 1 allocation + r = r.WithContext(context.WithValue(r.Context(), RouteCtxKey, rctx)) + + // Serve the request and once its done, put the request context back in the sync pool + mx.handler.ServeHTTP(w, r) + mx.pool.Put(rctx) +} + +// Use appends a middleware handler to the Mux middleware stack. +// +// The middleware stack for any Mux will execute before searching for a matching +// route to a specific handler, which provides opportunity to respond early, +// change the course of the request execution, or set request-scoped values for +// the next http.Handler. +func (mx *Mux) Use(middlewares ...func(http.Handler) http.Handler) { + if mx.handler != nil { + panic("chi: all middlewares must be defined before routes on a mux") + } + mx.middlewares = append(mx.middlewares, middlewares...) +} + +// Handle adds the route `pattern` that matches any http method to +// execute the `handler` http.Handler. +func (mx *Mux) Handle(pattern string, handler http.Handler) { + mx.handle(mALL, pattern, handler) +} + +// HandleFunc adds the route `pattern` that matches any http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) HandleFunc(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mALL, pattern, handlerFn) +} + +// Method adds the route `pattern` that matches `method` http method to +// execute the `handler` http.Handler. +func (mx *Mux) Method(method, pattern string, handler http.Handler) { + m, ok := methodMap[strings.ToUpper(method)] + if !ok { + panic(fmt.Sprintf("chi: '%s' http method is not supported.", method)) + } + mx.handle(m, pattern, handler) +} + +// MethodFunc adds the route `pattern` that matches `method` http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) MethodFunc(method, pattern string, handlerFn http.HandlerFunc) { + mx.Method(method, pattern, handlerFn) +} + +// Connect adds the route `pattern` that matches a CONNECT http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Connect(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mCONNECT, pattern, handlerFn) +} + +// Delete adds the route `pattern` that matches a DELETE http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Delete(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mDELETE, pattern, handlerFn) +} + +// Get adds the route `pattern` that matches a GET http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Get(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mGET, pattern, handlerFn) +} + +// Head adds the route `pattern` that matches a HEAD http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Head(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mHEAD, pattern, handlerFn) +} + +// Options adds the route `pattern` that matches a OPTIONS http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Options(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mOPTIONS, pattern, handlerFn) +} + +// Patch adds the route `pattern` that matches a PATCH http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Patch(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mPATCH, pattern, handlerFn) +} + +// Post adds the route `pattern` that matches a POST http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Post(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mPOST, pattern, handlerFn) +} + +// Put adds the route `pattern` that matches a PUT http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Put(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mPUT, pattern, handlerFn) +} + +// Trace adds the route `pattern` that matches a TRACE http method to +// execute the `handlerFn` http.HandlerFunc. +func (mx *Mux) Trace(pattern string, handlerFn http.HandlerFunc) { + mx.handle(mTRACE, pattern, handlerFn) +} + +// NotFound sets a custom http.HandlerFunc for routing paths that could +// not be found. The default 404 handler is `http.NotFound`. +func (mx *Mux) NotFound(handlerFn http.HandlerFunc) { + // Build NotFound handler chain + m := mx + hFn := handlerFn + if mx.inline && mx.parent != nil { + m = mx.parent + hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP + } + + // Update the notFoundHandler from this point forward + m.notFoundHandler = hFn + m.updateSubRoutes(func(subMux *Mux) { + if subMux.notFoundHandler == nil { + subMux.NotFound(hFn) + } + }) +} + +// MethodNotAllowed sets a custom http.HandlerFunc for routing paths where the +// method is unresolved. The default handler returns a 405 with an empty body. +func (mx *Mux) MethodNotAllowed(handlerFn http.HandlerFunc) { + // Build MethodNotAllowed handler chain + m := mx + hFn := handlerFn + if mx.inline && mx.parent != nil { + m = mx.parent + hFn = Chain(mx.middlewares...).HandlerFunc(hFn).ServeHTTP + } + + // Update the methodNotAllowedHandler from this point forward + m.methodNotAllowedHandler = hFn + m.updateSubRoutes(func(subMux *Mux) { + if subMux.methodNotAllowedHandler == nil { + subMux.MethodNotAllowed(hFn) + } + }) +} + +// With adds inline middlewares for an endpoint handler. +func (mx *Mux) With(middlewares ...func(http.Handler) http.Handler) Router { + // Similarly as in handle(), we must build the mux handler once additional + // middleware registration isn't allowed for this stack, like now. + if !mx.inline && mx.handler == nil { + mx.updateRouteHandler() + } + + // Copy middlewares from parent inline muxs + var mws Middlewares + if mx.inline { + mws = make(Middlewares, len(mx.middlewares)) + copy(mws, mx.middlewares) + } + mws = append(mws, middlewares...) + + im := &Mux{ + pool: mx.pool, inline: true, parent: mx, tree: mx.tree, middlewares: mws, + notFoundHandler: mx.notFoundHandler, methodNotAllowedHandler: mx.methodNotAllowedHandler, + } + + return im +} + +// Group creates a new inline-Mux with a fresh middleware stack. It's useful +// for a group of handlers along the same routing path that use an additional +// set of middlewares. See _examples/. +func (mx *Mux) Group(fn func(r Router)) Router { + im := mx.With().(*Mux) + if fn != nil { + fn(im) + } + return im +} + +// Route creates a new Mux with a fresh middleware stack and mounts it +// along the `pattern` as a subrouter. Effectively, this is a short-hand +// call to Mount. See _examples/. +func (mx *Mux) Route(pattern string, fn func(r Router)) Router { + if fn == nil { + panic(fmt.Sprintf("chi: attempting to Route() a nil subrouter on '%s'", pattern)) + } + subRouter := NewRouter() + fn(subRouter) + mx.Mount(pattern, subRouter) + return subRouter +} + +// Mount attaches another http.Handler or chi Router as a subrouter along a routing +// path. It's very useful to split up a large API as many independent routers and +// compose them as a single service using Mount. See _examples/. +// +// Note that Mount() simply sets a wildcard along the `pattern` that will continue +// routing at the `handler`, which in most cases is another chi.Router. As a result, +// if you define two Mount() routes on the exact same pattern the mount will panic. +func (mx *Mux) Mount(pattern string, handler http.Handler) { + if handler == nil { + panic(fmt.Sprintf("chi: attempting to Mount() a nil handler on '%s'", pattern)) + } + + // Provide runtime safety for ensuring a pattern isn't mounted on an existing + // routing pattern. + if mx.tree.findPattern(pattern+"*") || mx.tree.findPattern(pattern+"/*") { + panic(fmt.Sprintf("chi: attempting to Mount() a handler on an existing path, '%s'", pattern)) + } + + // Assign sub-Router's with the parent not found & method not allowed handler if not specified. + subr, ok := handler.(*Mux) + if ok && subr.notFoundHandler == nil && mx.notFoundHandler != nil { + subr.NotFound(mx.notFoundHandler) + } + if ok && subr.methodNotAllowedHandler == nil && mx.methodNotAllowedHandler != nil { + subr.MethodNotAllowed(mx.methodNotAllowedHandler) + } + + mountHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + rctx := RouteContext(r.Context()) + + // shift the url path past the previous subrouter + rctx.RoutePath = mx.nextRoutePath(rctx) + + // reset the wildcard URLParam which connects the subrouter + n := len(rctx.URLParams.Keys) - 1 + if n >= 0 && rctx.URLParams.Keys[n] == "*" && len(rctx.URLParams.Values) > n { + rctx.URLParams.Values[n] = "" + } + + handler.ServeHTTP(w, r) + }) + + if pattern == "" || pattern[len(pattern)-1] != '/' { + mx.handle(mALL|mSTUB, pattern, mountHandler) + mx.handle(mALL|mSTUB, pattern+"/", mountHandler) + pattern += "/" + } + + method := mALL + subroutes, _ := handler.(Routes) + if subroutes != nil { + method |= mSTUB + } + n := mx.handle(method, pattern+"*", mountHandler) + + if subroutes != nil { + n.subroutes = subroutes + } +} + +// Routes returns a slice of routing information from the tree, +// useful for traversing available routes of a router. +func (mx *Mux) Routes() []Route { + return mx.tree.routes() +} + +// Middlewares returns a slice of middleware handler functions. +func (mx *Mux) Middlewares() Middlewares { + return mx.middlewares +} + +// Match searches the routing tree for a handler that matches the method/path. +// It's similar to routing a http request, but without executing the handler +// thereafter. +// +// Note: the *Context state is updated during execution, so manage +// the state carefully or make a NewRouteContext(). +func (mx *Mux) Match(rctx *Context, method, path string) bool { + m, ok := methodMap[method] + if !ok { + return false + } + + node, _, h := mx.tree.FindRoute(rctx, m, path) + + if node != nil && node.subroutes != nil { + rctx.RoutePath = mx.nextRoutePath(rctx) + return node.subroutes.Match(rctx, method, rctx.RoutePath) + } + + return h != nil +} + +// NotFoundHandler returns the default Mux 404 responder whenever a route +// cannot be found. +func (mx *Mux) NotFoundHandler() http.HandlerFunc { + if mx.notFoundHandler != nil { + return mx.notFoundHandler + } + return http.NotFound +} + +// MethodNotAllowedHandler returns the default Mux 405 responder whenever +// a method cannot be resolved for a route. +func (mx *Mux) MethodNotAllowedHandler() http.HandlerFunc { + if mx.methodNotAllowedHandler != nil { + return mx.methodNotAllowedHandler + } + return methodNotAllowedHandler +} + +// handle registers a http.Handler in the routing tree for a particular http method +// and routing pattern. +func (mx *Mux) handle(method methodTyp, pattern string, handler http.Handler) *node { + if len(pattern) == 0 || pattern[0] != '/' { + panic(fmt.Sprintf("chi: routing pattern must begin with '/' in '%s'", pattern)) + } + + // Build the computed routing handler for this routing pattern. + if !mx.inline && mx.handler == nil { + mx.updateRouteHandler() + } + + // Build endpoint handler with inline middlewares for the route + var h http.Handler + if mx.inline { + mx.handler = http.HandlerFunc(mx.routeHTTP) + h = Chain(mx.middlewares...).Handler(handler) + } else { + h = handler + } + + // Add the endpoint to the tree and return the node + return mx.tree.InsertRoute(method, pattern, h) +} + +// routeHTTP routes a http.Request through the Mux routing tree to serve +// the matching handler for a particular http method. +func (mx *Mux) routeHTTP(w http.ResponseWriter, r *http.Request) { + // Grab the route context object + rctx := r.Context().Value(RouteCtxKey).(*Context) + + // The request routing path + routePath := rctx.RoutePath + if routePath == "" { + if r.URL.RawPath != "" { + routePath = r.URL.RawPath + } else { + routePath = r.URL.Path + } + if routePath == "" { + routePath = "/" + } + } + + // Check if method is supported by chi + if rctx.RouteMethod == "" { + rctx.RouteMethod = r.Method + } + method, ok := methodMap[rctx.RouteMethod] + if !ok { + mx.MethodNotAllowedHandler().ServeHTTP(w, r) + return + } + + // Find the route + if _, _, h := mx.tree.FindRoute(rctx, method, routePath); h != nil { + h.ServeHTTP(w, r) + return + } + if rctx.methodNotAllowed { + mx.MethodNotAllowedHandler().ServeHTTP(w, r) + } else { + mx.NotFoundHandler().ServeHTTP(w, r) + } +} + +func (mx *Mux) nextRoutePath(rctx *Context) string { + routePath := "/" + nx := len(rctx.routeParams.Keys) - 1 // index of last param in list + if nx >= 0 && rctx.routeParams.Keys[nx] == "*" && len(rctx.routeParams.Values) > nx { + routePath = "/" + rctx.routeParams.Values[nx] + } + return routePath +} + +// Recursively update data on child routers. +func (mx *Mux) updateSubRoutes(fn func(subMux *Mux)) { + for _, r := range mx.tree.routes() { + subMux, ok := r.SubRoutes.(*Mux) + if !ok { + continue + } + fn(subMux) + } +} + +// updateRouteHandler builds the single mux handler that is a chain of the middleware +// stack, as defined by calls to Use(), and the tree router (Mux) itself. After this +// point, no other middlewares can be registered on this Mux's stack. But you can still +// compose additional middlewares via Group()'s or using a chained middleware handler. +func (mx *Mux) updateRouteHandler() { + mx.handler = chain(mx.middlewares, http.HandlerFunc(mx.routeHTTP)) +} + +// methodNotAllowedHandler is a helper function to respond with a 405, +// method not allowed. +func methodNotAllowedHandler(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(405) + w.Write(nil) +} diff --git a/vendor/github.com/go-chi/chi/v5/tree.go b/vendor/github.com/go-chi/chi/v5/tree.go new file mode 100644 index 00000000000..4189b5228b2 --- /dev/null +++ b/vendor/github.com/go-chi/chi/v5/tree.go @@ -0,0 +1,866 @@ +package chi + +// Radix tree implementation below is a based on the original work by +// Armon Dadgar in https://github.com/armon/go-radix/blob/master/radix.go +// (MIT licensed). It's been heavily modified for use as a HTTP routing tree. + +import ( + "fmt" + "net/http" + "regexp" + "sort" + "strconv" + "strings" +) + +type methodTyp uint + +const ( + mSTUB methodTyp = 1 << iota + mCONNECT + mDELETE + mGET + mHEAD + mOPTIONS + mPATCH + mPOST + mPUT + mTRACE +) + +var mALL = mCONNECT | mDELETE | mGET | mHEAD | + mOPTIONS | mPATCH | mPOST | mPUT | mTRACE + +var methodMap = map[string]methodTyp{ + http.MethodConnect: mCONNECT, + http.MethodDelete: mDELETE, + http.MethodGet: mGET, + http.MethodHead: mHEAD, + http.MethodOptions: mOPTIONS, + http.MethodPatch: mPATCH, + http.MethodPost: mPOST, + http.MethodPut: mPUT, + http.MethodTrace: mTRACE, +} + +// RegisterMethod adds support for custom HTTP method handlers, available +// via Router#Method and Router#MethodFunc +func RegisterMethod(method string) { + if method == "" { + return + } + method = strings.ToUpper(method) + if _, ok := methodMap[method]; ok { + return + } + n := len(methodMap) + if n > strconv.IntSize-2 { + panic(fmt.Sprintf("chi: max number of methods reached (%d)", strconv.IntSize)) + } + mt := methodTyp(2 << n) + methodMap[method] = mt + mALL |= mt +} + +type nodeTyp uint8 + +const ( + ntStatic nodeTyp = iota // /home + ntRegexp // /{id:[0-9]+} + ntParam // /{user} + ntCatchAll // /api/v1/* +) + +type node struct { + // subroutes on the leaf node + subroutes Routes + + // regexp matcher for regexp nodes + rex *regexp.Regexp + + // HTTP handler endpoints on the leaf node + endpoints endpoints + + // prefix is the common prefix we ignore + prefix string + + // child nodes should be stored in-order for iteration, + // in groups of the node type. + children [ntCatchAll + 1]nodes + + // first byte of the child prefix + tail byte + + // node type: static, regexp, param, catchAll + typ nodeTyp + + // first byte of the prefix + label byte +} + +// endpoints is a mapping of http method constants to handlers +// for a given route. +type endpoints map[methodTyp]*endpoint + +type endpoint struct { + // endpoint handler + handler http.Handler + + // pattern is the routing pattern for handler nodes + pattern string + + // parameter keys recorded on handler nodes + paramKeys []string +} + +func (s endpoints) Value(method methodTyp) *endpoint { + mh, ok := s[method] + if !ok { + mh = &endpoint{} + s[method] = mh + } + return mh +} + +func (n *node) InsertRoute(method methodTyp, pattern string, handler http.Handler) *node { + var parent *node + search := pattern + + for { + // Handle key exhaustion + if len(search) == 0 { + // Insert or update the node's leaf handler + n.setEndpoint(method, handler, pattern) + return n + } + + // We're going to be searching for a wild node next, + // in this case, we need to get the tail + var label = search[0] + var segTail byte + var segEndIdx int + var segTyp nodeTyp + var segRexpat string + if label == '{' || label == '*' { + segTyp, _, segRexpat, segTail, _, segEndIdx = patNextSegment(search) + } + + var prefix string + if segTyp == ntRegexp { + prefix = segRexpat + } + + // Look for the edge to attach to + parent = n + n = n.getEdge(segTyp, label, segTail, prefix) + + // No edge, create one + if n == nil { + child := &node{label: label, tail: segTail, prefix: search} + hn := parent.addChild(child, search) + hn.setEndpoint(method, handler, pattern) + + return hn + } + + // Found an edge to match the pattern + + if n.typ > ntStatic { + // We found a param node, trim the param from the search path and continue. + // This param/wild pattern segment would already be on the tree from a previous + // call to addChild when creating a new node. + search = search[segEndIdx:] + continue + } + + // Static nodes fall below here. + // Determine longest prefix of the search key on match. + commonPrefix := longestPrefix(search, n.prefix) + if commonPrefix == len(n.prefix) { + // the common prefix is as long as the current node's prefix we're attempting to insert. + // keep the search going. + search = search[commonPrefix:] + continue + } + + // Split the node + child := &node{ + typ: ntStatic, + prefix: search[:commonPrefix], + } + parent.replaceChild(search[0], segTail, child) + + // Restore the existing node + n.label = n.prefix[commonPrefix] + n.prefix = n.prefix[commonPrefix:] + child.addChild(n, n.prefix) + + // If the new key is a subset, set the method/handler on this node and finish. + search = search[commonPrefix:] + if len(search) == 0 { + child.setEndpoint(method, handler, pattern) + return child + } + + // Create a new edge for the node + subchild := &node{ + typ: ntStatic, + label: search[0], + prefix: search, + } + hn := child.addChild(subchild, search) + hn.setEndpoint(method, handler, pattern) + return hn + } +} + +// addChild appends the new `child` node to the tree using the `pattern` as the trie key. +// For a URL router like chi's, we split the static, param, regexp and wildcard segments +// into different nodes. In addition, addChild will recursively call itself until every +// pattern segment is added to the url pattern tree as individual nodes, depending on type. +func (n *node) addChild(child *node, prefix string) *node { + search := prefix + + // handler leaf node added to the tree is the child. + // this may be overridden later down the flow + hn := child + + // Parse next segment + segTyp, _, segRexpat, segTail, segStartIdx, segEndIdx := patNextSegment(search) + + // Add child depending on next up segment + switch segTyp { + + case ntStatic: + // Search prefix is all static (that is, has no params in path) + // noop + + default: + // Search prefix contains a param, regexp or wildcard + + if segTyp == ntRegexp { + rex, err := regexp.Compile(segRexpat) + if err != nil { + panic(fmt.Sprintf("chi: invalid regexp pattern '%s' in route param", segRexpat)) + } + child.prefix = segRexpat + child.rex = rex + } + + if segStartIdx == 0 { + // Route starts with a param + child.typ = segTyp + + if segTyp == ntCatchAll { + segStartIdx = -1 + } else { + segStartIdx = segEndIdx + } + if segStartIdx < 0 { + segStartIdx = len(search) + } + child.tail = segTail // for params, we set the tail + + if segStartIdx != len(search) { + // add static edge for the remaining part, split the end. + // its not possible to have adjacent param nodes, so its certainly + // going to be a static node next. + + search = search[segStartIdx:] // advance search position + + nn := &node{ + typ: ntStatic, + label: search[0], + prefix: search, + } + hn = child.addChild(nn, search) + } + + } else if segStartIdx > 0 { + // Route has some param + + // starts with a static segment + child.typ = ntStatic + child.prefix = search[:segStartIdx] + child.rex = nil + + // add the param edge node + search = search[segStartIdx:] + + nn := &node{ + typ: segTyp, + label: search[0], + tail: segTail, + } + hn = child.addChild(nn, search) + + } + } + + n.children[child.typ] = append(n.children[child.typ], child) + n.children[child.typ].Sort() + return hn +} + +func (n *node) replaceChild(label, tail byte, child *node) { + for i := 0; i < len(n.children[child.typ]); i++ { + if n.children[child.typ][i].label == label && n.children[child.typ][i].tail == tail { + n.children[child.typ][i] = child + n.children[child.typ][i].label = label + n.children[child.typ][i].tail = tail + return + } + } + panic("chi: replacing missing child") +} + +func (n *node) getEdge(ntyp nodeTyp, label, tail byte, prefix string) *node { + nds := n.children[ntyp] + for i := 0; i < len(nds); i++ { + if nds[i].label == label && nds[i].tail == tail { + if ntyp == ntRegexp && nds[i].prefix != prefix { + continue + } + return nds[i] + } + } + return nil +} + +func (n *node) setEndpoint(method methodTyp, handler http.Handler, pattern string) { + // Set the handler for the method type on the node + if n.endpoints == nil { + n.endpoints = make(endpoints) + } + + paramKeys := patParamKeys(pattern) + + if method&mSTUB == mSTUB { + n.endpoints.Value(mSTUB).handler = handler + } + if method&mALL == mALL { + h := n.endpoints.Value(mALL) + h.handler = handler + h.pattern = pattern + h.paramKeys = paramKeys + for _, m := range methodMap { + h := n.endpoints.Value(m) + h.handler = handler + h.pattern = pattern + h.paramKeys = paramKeys + } + } else { + h := n.endpoints.Value(method) + h.handler = handler + h.pattern = pattern + h.paramKeys = paramKeys + } +} + +func (n *node) FindRoute(rctx *Context, method methodTyp, path string) (*node, endpoints, http.Handler) { + // Reset the context routing pattern and params + rctx.routePattern = "" + rctx.routeParams.Keys = rctx.routeParams.Keys[:0] + rctx.routeParams.Values = rctx.routeParams.Values[:0] + + // Find the routing handlers for the path + rn := n.findRoute(rctx, method, path) + if rn == nil { + return nil, nil, nil + } + + // Record the routing params in the request lifecycle + rctx.URLParams.Keys = append(rctx.URLParams.Keys, rctx.routeParams.Keys...) + rctx.URLParams.Values = append(rctx.URLParams.Values, rctx.routeParams.Values...) + + // Record the routing pattern in the request lifecycle + if rn.endpoints[method].pattern != "" { + rctx.routePattern = rn.endpoints[method].pattern + rctx.RoutePatterns = append(rctx.RoutePatterns, rctx.routePattern) + } + + return rn, rn.endpoints, rn.endpoints[method].handler +} + +// Recursive edge traversal by checking all nodeTyp groups along the way. +// It's like searching through a multi-dimensional radix trie. +func (n *node) findRoute(rctx *Context, method methodTyp, path string) *node { + nn := n + search := path + + for t, nds := range nn.children { + ntyp := nodeTyp(t) + if len(nds) == 0 { + continue + } + + var xn *node + xsearch := search + + var label byte + if search != "" { + label = search[0] + } + + switch ntyp { + case ntStatic: + xn = nds.findEdge(label) + if xn == nil || !strings.HasPrefix(xsearch, xn.prefix) { + continue + } + xsearch = xsearch[len(xn.prefix):] + + case ntParam, ntRegexp: + // short-circuit and return no matching route for empty param values + if xsearch == "" { + continue + } + + // serially loop through each node grouped by the tail delimiter + for idx := 0; idx < len(nds); idx++ { + xn = nds[idx] + + // label for param nodes is the delimiter byte + p := strings.IndexByte(xsearch, xn.tail) + + if p < 0 { + if xn.tail == '/' { + p = len(xsearch) + } else { + continue + } + } else if ntyp == ntRegexp && p == 0 { + continue + } + + if ntyp == ntRegexp && xn.rex != nil { + if !xn.rex.MatchString(xsearch[:p]) { + continue + } + } else if strings.IndexByte(xsearch[:p], '/') != -1 { + // avoid a match across path segments + continue + } + + prevlen := len(rctx.routeParams.Values) + rctx.routeParams.Values = append(rctx.routeParams.Values, xsearch[:p]) + xsearch = xsearch[p:] + + if len(xsearch) == 0 { + if xn.isLeaf() { + h := xn.endpoints[method] + if h != nil && h.handler != nil { + rctx.routeParams.Keys = append(rctx.routeParams.Keys, h.paramKeys...) + return xn + } + + // flag that the routing context found a route, but not a corresponding + // supported method + rctx.methodNotAllowed = true + } + } + + // recursively find the next node on this branch + fin := xn.findRoute(rctx, method, xsearch) + if fin != nil { + return fin + } + + // not found on this branch, reset vars + rctx.routeParams.Values = rctx.routeParams.Values[:prevlen] + xsearch = search + } + + rctx.routeParams.Values = append(rctx.routeParams.Values, "") + + default: + // catch-all nodes + rctx.routeParams.Values = append(rctx.routeParams.Values, search) + xn = nds[0] + xsearch = "" + } + + if xn == nil { + continue + } + + // did we find it yet? + if len(xsearch) == 0 { + if xn.isLeaf() { + h := xn.endpoints[method] + if h != nil && h.handler != nil { + rctx.routeParams.Keys = append(rctx.routeParams.Keys, h.paramKeys...) + return xn + } + + // flag that the routing context found a route, but not a corresponding + // supported method + rctx.methodNotAllowed = true + } + } + + // recursively find the next node.. + fin := xn.findRoute(rctx, method, xsearch) + if fin != nil { + return fin + } + + // Did not find final handler, let's remove the param here if it was set + if xn.typ > ntStatic { + if len(rctx.routeParams.Values) > 0 { + rctx.routeParams.Values = rctx.routeParams.Values[:len(rctx.routeParams.Values)-1] + } + } + + } + + return nil +} + +func (n *node) findEdge(ntyp nodeTyp, label byte) *node { + nds := n.children[ntyp] + num := len(nds) + idx := 0 + + switch ntyp { + case ntStatic, ntParam, ntRegexp: + i, j := 0, num-1 + for i <= j { + idx = i + (j-i)/2 + if label > nds[idx].label { + i = idx + 1 + } else if label < nds[idx].label { + j = idx - 1 + } else { + i = num // breaks cond + } + } + if nds[idx].label != label { + return nil + } + return nds[idx] + + default: // catch all + return nds[idx] + } +} + +func (n *node) isLeaf() bool { + return n.endpoints != nil +} + +func (n *node) findPattern(pattern string) bool { + nn := n + for _, nds := range nn.children { + if len(nds) == 0 { + continue + } + + n = nn.findEdge(nds[0].typ, pattern[0]) + if n == nil { + continue + } + + var idx int + var xpattern string + + switch n.typ { + case ntStatic: + idx = longestPrefix(pattern, n.prefix) + if idx < len(n.prefix) { + continue + } + + case ntParam, ntRegexp: + idx = strings.IndexByte(pattern, '}') + 1 + + case ntCatchAll: + idx = longestPrefix(pattern, "*") + + default: + panic("chi: unknown node type") + } + + xpattern = pattern[idx:] + if len(xpattern) == 0 { + return true + } + + return n.findPattern(xpattern) + } + return false +} + +func (n *node) routes() []Route { + rts := []Route{} + + n.walk(func(eps endpoints, subroutes Routes) bool { + if eps[mSTUB] != nil && eps[mSTUB].handler != nil && subroutes == nil { + return false + } + + // Group methodHandlers by unique patterns + pats := make(map[string]endpoints) + + for mt, h := range eps { + if h.pattern == "" { + continue + } + p, ok := pats[h.pattern] + if !ok { + p = endpoints{} + pats[h.pattern] = p + } + p[mt] = h + } + + for p, mh := range pats { + hs := make(map[string]http.Handler) + if mh[mALL] != nil && mh[mALL].handler != nil { + hs["*"] = mh[mALL].handler + } + + for mt, h := range mh { + if h.handler == nil { + continue + } + m := methodTypString(mt) + if m == "" { + continue + } + hs[m] = h.handler + } + + rt := Route{subroutes, hs, p} + rts = append(rts, rt) + } + + return false + }) + + return rts +} + +func (n *node) walk(fn func(eps endpoints, subroutes Routes) bool) bool { + // Visit the leaf values if any + if (n.endpoints != nil || n.subroutes != nil) && fn(n.endpoints, n.subroutes) { + return true + } + + // Recurse on the children + for _, ns := range n.children { + for _, cn := range ns { + if cn.walk(fn) { + return true + } + } + } + return false +} + +// patNextSegment returns the next segment details from a pattern: +// node type, param key, regexp string, param tail byte, param starting index, param ending index +func patNextSegment(pattern string) (nodeTyp, string, string, byte, int, int) { + ps := strings.Index(pattern, "{") + ws := strings.Index(pattern, "*") + + if ps < 0 && ws < 0 { + return ntStatic, "", "", 0, 0, len(pattern) // we return the entire thing + } + + // Sanity check + if ps >= 0 && ws >= 0 && ws < ps { + panic("chi: wildcard '*' must be the last pattern in a route, otherwise use a '{param}'") + } + + var tail byte = '/' // Default endpoint tail to / byte + + if ps >= 0 { + // Param/Regexp pattern is next + nt := ntParam + + // Read to closing } taking into account opens and closes in curl count (cc) + cc := 0 + pe := ps + for i, c := range pattern[ps:] { + if c == '{' { + cc++ + } else if c == '}' { + cc-- + if cc == 0 { + pe = ps + i + break + } + } + } + if pe == ps { + panic("chi: route param closing delimiter '}' is missing") + } + + key := pattern[ps+1 : pe] + pe++ // set end to next position + + if pe < len(pattern) { + tail = pattern[pe] + } + + var rexpat string + if idx := strings.Index(key, ":"); idx >= 0 { + nt = ntRegexp + rexpat = key[idx+1:] + key = key[:idx] + } + + if len(rexpat) > 0 { + if rexpat[0] != '^' { + rexpat = "^" + rexpat + } + if rexpat[len(rexpat)-1] != '$' { + rexpat += "$" + } + } + + return nt, key, rexpat, tail, ps, pe + } + + // Wildcard pattern as finale + if ws < len(pattern)-1 { + panic("chi: wildcard '*' must be the last value in a route. trim trailing text or use a '{param}' instead") + } + return ntCatchAll, "*", "", 0, ws, len(pattern) +} + +func patParamKeys(pattern string) []string { + pat := pattern + paramKeys := []string{} + for { + ptyp, paramKey, _, _, _, e := patNextSegment(pat) + if ptyp == ntStatic { + return paramKeys + } + for i := 0; i < len(paramKeys); i++ { + if paramKeys[i] == paramKey { + panic(fmt.Sprintf("chi: routing pattern '%s' contains duplicate param key, '%s'", pattern, paramKey)) + } + } + paramKeys = append(paramKeys, paramKey) + pat = pat[e:] + } +} + +// longestPrefix finds the length of the shared prefix +// of two strings +func longestPrefix(k1, k2 string) int { + max := len(k1) + if l := len(k2); l < max { + max = l + } + var i int + for i = 0; i < max; i++ { + if k1[i] != k2[i] { + break + } + } + return i +} + +func methodTypString(method methodTyp) string { + for s, t := range methodMap { + if method == t { + return s + } + } + return "" +} + +type nodes []*node + +// Sort the list of nodes by label +func (ns nodes) Sort() { sort.Sort(ns); ns.tailSort() } +func (ns nodes) Len() int { return len(ns) } +func (ns nodes) Swap(i, j int) { ns[i], ns[j] = ns[j], ns[i] } +func (ns nodes) Less(i, j int) bool { return ns[i].label < ns[j].label } + +// tailSort pushes nodes with '/' as the tail to the end of the list for param nodes. +// The list order determines the traversal order. +func (ns nodes) tailSort() { + for i := len(ns) - 1; i >= 0; i-- { + if ns[i].typ > ntStatic && ns[i].tail == '/' { + ns.Swap(i, len(ns)-1) + return + } + } +} + +func (ns nodes) findEdge(label byte) *node { + num := len(ns) + idx := 0 + i, j := 0, num-1 + for i <= j { + idx = i + (j-i)/2 + if label > ns[idx].label { + i = idx + 1 + } else if label < ns[idx].label { + j = idx - 1 + } else { + i = num // breaks cond + } + } + if ns[idx].label != label { + return nil + } + return ns[idx] +} + +// Route describes the details of a routing handler. +// Handlers map key is an HTTP method +type Route struct { + SubRoutes Routes + Handlers map[string]http.Handler + Pattern string +} + +// WalkFunc is the type of the function called for each method and route visited by Walk. +type WalkFunc func(method string, route string, handler http.Handler, middlewares ...func(http.Handler) http.Handler) error + +// Walk walks any router tree that implements Routes interface. +func Walk(r Routes, walkFn WalkFunc) error { + return walk(r, walkFn, "") +} + +func walk(r Routes, walkFn WalkFunc, parentRoute string, parentMw ...func(http.Handler) http.Handler) error { + for _, route := range r.Routes() { + mws := make([]func(http.Handler) http.Handler, len(parentMw)) + copy(mws, parentMw) + mws = append(mws, r.Middlewares()...) + + if route.SubRoutes != nil { + if err := walk(route.SubRoutes, walkFn, parentRoute+route.Pattern, mws...); err != nil { + return err + } + continue + } + + for method, handler := range route.Handlers { + if method == "*" { + // Ignore a "catchAll" method, since we pass down all the specific methods for each route. + continue + } + + fullRoute := parentRoute + route.Pattern + fullRoute = strings.Replace(fullRoute, "/*/", "/", -1) + + if chain, ok := handler.(*ChainHandler); ok { + if err := walkFn(method, fullRoute, chain.Endpoint, append(mws, chain.Middlewares...)...); err != nil { + return err + } + } else { + if err := walkFn(method, fullRoute, handler, mws...); err != nil { + return err + } + } + } + } + + return nil +} diff --git a/vendor/github.com/rantav/go-grpc-channelz/.gitignore b/vendor/github.com/rantav/go-grpc-channelz/.gitignore new file mode 100644 index 00000000000..2bc2dfc9161 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/.gitignore @@ -0,0 +1,2 @@ +.tmp/ +bin/ diff --git a/vendor/github.com/rantav/go-grpc-channelz/LICENSE b/vendor/github.com/rantav/go-grpc-channelz/LICENSE new file mode 100644 index 00000000000..d2766e83863 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Ran Tavory + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/rantav/go-grpc-channelz/Makefile b/vendor/github.com/rantav/go-grpc-channelz/Makefile new file mode 100644 index 00000000000..570506eb7e2 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/Makefile @@ -0,0 +1,85 @@ +BIN_DIR := ./bin +GOLANGCI_LINT_VERSION := 1.21.0 +GOLANGCI_LINT := $(BIN_DIR)/golangci-lint +PROTOC_VERSION := 3.20.1 +RELEASE_OS := +PROTOC_DIR := .tmp/protoc-$(PROTOC_VERSION) +PROTOC_BIN := $(PROTOC_DIR)/bin/protoc + +ifeq ($(OS),Windows_NT) + echo "Windows not supported yet, sorry...." + exit 1 +else + UNAME_S := $(shell uname -s) + ifeq ($(UNAME_S),Linux) + RELEASE_OS = linux + endif + ifeq ($(UNAME_S),Darwin) + RELEASE_OS = osx + endif +endif + + +all: test lint + +tidy: + go mod tidy -v + +build: protoc + go build ./... + +test: build + go test -cover -race ./... + +test-coverage: + go test ./... -race -coverprofile=coverage.txt && go tool cover -html=coverage.txt + +ci-test: build + go test -race $$(go list ./...) -v -coverprofile coverage.txt -covermode=atomic + +setup: setup-git-hooks + +setup-git-hooks: + git config core.hooksPath .githooks + +lint: lint-install + # -D typecheck until golangci-lint gets it together to propery work with go1.13 + $(GOLANGCI_LINT) run --fast --enable-all -D gochecknoglobals -D dupl -D typecheck -D wsl + +lint-install: + # Check if golanglint-ci exists and is of the correct version, if not install + $(GOLANGCI_LINT) --version | grep $(GOLANGCI_LINT_VERSION) || \ + curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(BIN_DIR) v$(GOLANGCI_LINT_VERSION) + +guard-%: + @ if [ "${${*}}" = "" ]; then \ + echo "Environment variable $* not set"; \ + exit 1; \ + fi + + +$(PROTOC_BIN): + @echo "Installing unzip (if required)" + @which unzip || apt-get update || sudo apt-get update + @which unzip || apt-get install unzip || sudo apt-get install unzip + @echo Installing protoc + rm -rf $(PROTOC_DIR) + mkdir -p $(PROTOC_DIR) + cd $(PROTOC_DIR) &&\ + curl -OL https://github.com/google/protobuf/releases/download/v$(PROTOC_VERSION)/protoc-$(PROTOC_VERSION)-$(RELEASE_OS)-x86_64.zip &&\ + unzip protoc-$(PROTOC_VERSION)-$(RELEASE_OS)-x86_64.zip + chmod +x $(PROTOC_BIN) + @echo "Installing protoc-gen-go (if required)" + @which protoc-gen-go > /dev/null || go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + @echo "Installing protoc-gen-go-grpc (if required)" + @which protoc-gen-go-grpc > /dev/null || go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest + +run-demo-server: + go run internal/demo/server/main/main.go + +protoc: $(PROTOC_BIN) + mkdir -p internal/generated/service + $(PROTOC_BIN) --proto_path=internal/proto \ + --go_out=internal/generated/service --go_opt=paths=source_relative \ + --go-grpc_out=internal/generated/service --go-grpc_opt=paths=source_relative \ + internal/proto/*.proto diff --git a/vendor/github.com/rantav/go-grpc-channelz/README.md b/vendor/github.com/rantav/go-grpc-channelz/README.md new file mode 100644 index 00000000000..1f53051c7ae --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/README.md @@ -0,0 +1,98 @@ +# go-grpc-channelz + +An in-process Channelz UI for gRPC in Golang + +## What is Channelz? + +Channelz is a gRPC spec for introspection into gRPC channels. +Channels in gRPC represent connections and sockets. Channelz provides introspection into the current active grpc connections, including incoming and outgoing connections. +The full spec can be found [here](https://github.com/grpc/proposal/blob/master/A14-channelz.md) + +## What is `go-grpc-channelz`? + +`go-grpc-channelz` provides a web UI to view the current start of all gRPC channels. For each channel you'd be able to look into the remote peer, sub-channels, load balancing stategies, number of calls, socket activity and events and so on. + +You install go-grpc-channelz into your service and expose it's web page and that's it. All in all, about 2-5 lines of code. + +## Screenshots + +![Top Channels](doc/top-channels.png) + +![Channel](doc/channel.png) + +![Subchannel](doc/subchannel.png) + +![Socket](doc/socket.png) + +![Server](doc/server.png) + +## Usage + +Channelz is implemented as a gRPC service. This service is turned off by by default, so you have to turn it on as so: + +```go +import ( + channelzservice "google.golang.org/grpc/channelz/service" +) + +// Register the channelz gRPC service to grpcServer so that we can query it for this service. +channelzservice.RegisterChannelzServiceToServer(grpcServer) +``` + +In this example `grpcServer` is a grpc server that you create externally. In many cases this server already exists (you only need one) but if not then here's how to create it: + +```go +import "google.golang.org/grpc" + +grpcServer := grpc.NewServer() +``` + +Now you should register the channelz web handler: + +```go +import channelz "github.com/rantav/go-grpc-channelz" + +// Register the channelz handler and mount it to /foo. +// Resources will be available at /foo/channelz +http.Handle("/", channelz.CreateHandler("/foo", grpcBindAddress)) +``` + +Where `grpcBindAddress` is the address to which `grpcServer` is bound. This could be for example `":8080"` or `"localhost:8080"` etc. This address is required because the channelz web service accesses the channelz grpc service in order to query it. + +Lastly, launch that web listener in order to serve the web UI: + +```go +// Listen and serve HTTP for the default serve mux +adminListener, err := net.Listen("tcp", ":8081") +if err != nil { + log.Fatal(err) +} +go http.Serve(adminListener, nil) +``` + +Now the service will be available at `http://localhost:8081/foo/channelz` + +A complete example: + +```go +import ( + "google.golang.org/grpc" + channelzservice "google.golang.org/grpc/channelz/service" + channelz "github.com/rantav/go-grpc-channelz" +) + +grpcServer := grpc.NewServer() + +// Register the channelz handler +http.Handle("/", channelz.CreateHandler("/foo", grpcBindAddress)) + +// Register the channelz gRPC service to grpcServer so that we can query it for this service. +channelzservice.RegisterChannelzServiceToServer(grpcServer) + +// Listen and serve HTTP for the default serve mux +adminListener, err := net.Listen("tcp", ":8081") +if err != nil { + log.Fatal(err) +} +go http.Serve(adminListener, nil) +``` diff --git a/vendor/github.com/rantav/go-grpc-channelz/channel-page.go b/vendor/github.com/rantav/go-grpc-channelz/channel-page.go new file mode 100644 index 00000000000..16324ee2153 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/channel-page.go @@ -0,0 +1,113 @@ +package channelz + +import ( + "context" + "fmt" + "io" + + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" + log "google.golang.org/grpc/grpclog" +) + +// WriteChannelPage writes an HTML document to w containing per-channel RPC stats, including a header and a footer. +func (h *grpcChannelzHandler) WriteChannelPage(w io.Writer, channel int64) { + writeHeader(w, fmt.Sprintf("ChannelZ channel %d", channel)) + h.writeChannel(w, channel) + writeFooter(w) +} + +func (h *grpcChannelzHandler) writeChannel(w io.Writer, channel int64) { + if err := channelTemplate.Execute(w, h.getChannel(channel)); err != nil { + log.Errorf("channelz: executing template: %v", err) + } +} + +func (h *grpcChannelzHandler) getChannel(channelID int64) *channelzgrpc.GetChannelResponse { + client, err := h.connect() + if err != nil { + log.Errorf("Error creating channelz client %+v", err) + return nil + } + ctx := context.Background() + channel, err := client.GetChannel(ctx, &channelzgrpc.GetChannelRequest{ChannelId: channelID}) + if err != nil { + log.Errorf("Error querying GetChannel %+v", err) + return nil + } + return channel +} + +const channelTemplateHTML = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ChannelId{{.Channel.Ref.ChannelId}} +
Channel Name{{.Channel.Ref.Name}}
State{{.Channel.Data.State}}
Target{{.Channel.Data.Target}}
Subchannels + {{range .Channel.SubchannelRef}} + {{.SubchannelId}} {{.Name}}
+ {{end}} +
Child Channels + {{range .Channel.ChannelRef}} + {{.ChannelId}} {{.Name}}
+ {{end}} +
Sockets + {{range .Channel.SocketRef}} + {{.SocketId}} {{.Name}}
+ {{end}} +
CreationTimestamp{{.Channel.Data.Trace.CreationTimestamp | timestamp}}
CallsStarted{{.Channel.Data.CallsStarted}}
CallsSucceeded{{.Channel.Data.CallsSucceeded}}
CallsFailed{{.Channel.Data.CallsFailed}}
LastCallStartedTimestamp{{.Channel.Data.LastCallStartedTimestamp | timestamp}}
Events +
+			{{- range .Channel.Data.Trace.Events}}
+{{.Severity}} [{{.Timestamp | timestamp}}]: {{.Description}}
+			{{- end -}}
+			
+
+` diff --git a/vendor/github.com/rantav/go-grpc-channelz/channels-page.go b/vendor/github.com/rantav/go-grpc-channelz/channels-page.go new file mode 100644 index 00000000000..a48a5fa5887 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/channels-page.go @@ -0,0 +1,110 @@ +package channelz + +import ( + "context" + "io" + + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" + log "google.golang.org/grpc/grpclog" +) + +// WriteChannelsPage writes an HTML document to w containing per-channel RPC stats, including a header and a footer. +func (h *grpcChannelzHandler) WriteChannelsPage(w io.Writer, start int64) { + writeHeader(w, "Channels") + h.writeChannels(w, start) + writeFooter(w) +} + +// writeTopChannels writes HTML to w containing per-channel RPC stats. +// +// It includes neither a header nor footer, so you can embed this data in other pages. +func (h *grpcChannelzHandler) writeChannels(w io.Writer, start int64) { + if err := channelsTemplate.Execute(w, h.getTopChannels(start)); err != nil { + log.Errorf("channelz: executing template: %v", err) + } +} + +func (h *grpcChannelzHandler) getTopChannels(start int64) *channelzgrpc.GetTopChannelsResponse { + client, err := h.connect() + if err != nil { + log.Errorf("Error creating channelz client %+v", err) + return nil + } + ctx := context.Background() + channels, err := client.GetTopChannels(ctx, &channelzgrpc.GetTopChannelsRequest{ + StartChannelId: start, + }) + if err != nil { + log.Errorf("Error querying GetTopChannels %+v", err) + return nil + } + return channels +} + +const channelsTemplateHTML = ` +{{define "channel-header"}} + + Channel + State + Target + Subchannels + Child Channels + Sockets + CreationTimestamp + CallsStarted + CallsSucceeded + CallsFailed + LastCallStartedTimestamp + +{{end}} + +{{define "channel-body"}} + + {{.Ref.ChannelId}} {{.Ref.Name}} + {{.Data.State}} + {{.Data.Target}} + + {{range .SubchannelRef}} + {{.SubchannelId}} {{.Name}}
+ {{end}} + + + {{range .ChannelRef}} + {{.ChannelId}} {{.Name}}
+ {{end}} + + + {{range .SocketRef}} + {{.SocketId}} {{.Name}}
+ {{end}} + + {{.Data.Trace.CreationTimestamp | timestamp}} + {{.Data.CallsStarted}} + {{.Data.CallsSucceeded}} + {{.Data.CallsFailed}} + {{.Data.LastCallStartedTimestamp | timestamp}} + +{{end}} +

Clients

+ + + + + + {{template "channel-header"}} + {{$last := .Channel}} + {{range .Channel}} + {{template "channel-body" .}} + {{$last = .}} + {{end}} + {{if not .End}} + + + + {{end}} +
Top Channels: {{.Channel | len}}
+ Next > +
+
+
+` diff --git a/vendor/github.com/rantav/go-grpc-channelz/channelz.go b/vendor/github.com/rantav/go-grpc-channelz/channelz.go new file mode 100644 index 00000000000..2107c09afc1 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/channelz.go @@ -0,0 +1,4 @@ +package channelz + +// Package channelz provides a web UI for the channelz information +// defined at https://github.com/grpc/proposal/blob/master/A14-channelz.md diff --git a/vendor/github.com/rantav/go-grpc-channelz/client.go b/vendor/github.com/rantav/go-grpc-channelz/client.go new file mode 100644 index 00000000000..96e4e49a122 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/client.go @@ -0,0 +1,43 @@ +package channelz + +import ( + "fmt" + "strings" + + "github.com/pkg/errors" + "google.golang.org/grpc" + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" +) + +func (h *grpcChannelzHandler) connect() (channelzgrpc.ChannelzClient, error) { + if h.client != nil { + // Already connected + return h.client, nil + } + + host := getHostFromBindAddress(h.bindAddress) + h.mu.Lock() + defer h.mu.Unlock() + client, err := newChannelzClient(host, h.dialOpts...) + if err != nil { + return nil, err + } + h.client = client + return h.client, nil +} + +func newChannelzClient(dialString string, opts ...grpc.DialOption) (channelzgrpc.ChannelzClient, error) { + conn, err := grpc.Dial(dialString, opts...) + if err != nil { + return nil, errors.Wrapf(err, "error dialing to %s", dialString) + } + client := channelzgrpc.NewChannelzClient(conn) + return client, nil +} + +func getHostFromBindAddress(bindAddress string) string { + if strings.HasPrefix(bindAddress, ":") { + return fmt.Sprintf("localhost%s", bindAddress) + } + return bindAddress +} diff --git a/vendor/github.com/rantav/go-grpc-channelz/handler.go b/vendor/github.com/rantav/go-grpc-channelz/handler.go new file mode 100644 index 00000000000..b7b13fc5932 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/handler.go @@ -0,0 +1,69 @@ +package channelz + +import ( + "net/http" + "path" + "sync" + + "google.golang.org/grpc" + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" + "google.golang.org/grpc/credentials/insecure" +) + +// CreateHandler creates an http handler with the routes of channelz mounted to the provided prefix. +// pathPrefix is the prefix to which /channelz will be prepended +// grpcBindAddress is the TCP bind address for the gRPC service you'd like to monitor. +// grpcBindAddress is required since the channelz interface connects to this gRPC service. +// Typically you'd use the return value of CreateHandler as an argument to http.Handle +// For example: +// +// http.Handle("/", channelz.CreateHandler("/foo", grpcBindAddress)) +// +// grpc.Dial is called using grpc.WithTransportCredentials(insecure.NewCredentials()). +// If you need custom DialOptions like credentials, TLS or interceptors, please +// refer to CreateHandlerWithDialOpts(). +func CreateHandler(pathPrefix, grpcBindAddress string) http.Handler { + return CreateHandlerWithDialOpts( + pathPrefix, + grpcBindAddress, + grpc.WithTransportCredentials(insecure.NewCredentials()), + ) +} + +// CreateHandlerWithDialOpts is the same as CreateHandler but with custom []grpc.DialOption +// You need to provide all grpc.DialOption to be used for the internal call to grpc.Dial(). +// This typically includes some form of grpc.WithTransportCredentials(). +// Here's an example on how to use a bufconn instead of a real TCP listener: +// lis := bufconn.Listen(1024 * 1024) +// grpcserver.Serve(lis) +// http.Handle("/", channelzWeb.CreateHandlerWithDialOpts("/", "", +// +// []grpc.DialOption{ +// grpc.WithTransportCredentials(insecure.NewCredentials()), +// grpc.WithContextDialer(func(ctx context.Context, s string) (net.Conn, error) { +// return lis.DialContext(ctx) +// }), +// }..., +// +// )) +func CreateHandlerWithDialOpts(pathPrefix, grpcBindAddress string, dialOpts ...grpc.DialOption) http.Handler { + prefix := path.Join(pathPrefix, "channelz") + "/" + handler := &grpcChannelzHandler{ + bindAddress: grpcBindAddress, + dialOpts: dialOpts, + } + return createRouter(prefix, handler) +} + +type grpcChannelzHandler struct { + // the target server's bind address + bindAddress string + + // The client connection (lazily initialized) + client channelzgrpc.ChannelzClient + + // []grpc.DialOption to use for grpc.Dial + dialOpts []grpc.DialOption + + mu sync.Mutex +} diff --git a/vendor/github.com/rantav/go-grpc-channelz/routes.go b/vendor/github.com/rantav/go-grpc-channelz/routes.go new file mode 100644 index 00000000000..02f8e8e2cc0 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/routes.go @@ -0,0 +1,95 @@ +package channelz + +import ( + "io" + "net/http" + "path" + "strconv" + + "github.com/go-chi/chi/v5" + log "google.golang.org/grpc/grpclog" +) + +type channelzHandler interface { + WriteTopChannelsPage(io.Writer) + WriteChannelsPage(io.Writer, int64) + WriteChannelPage(io.Writer, int64) + WriteSubchannelPage(io.Writer, int64) + WriteServerPage(io.Writer, int64) + WriteSocketPage(io.Writer, int64) +} + +var pathPrefix string + +func createRouter(prefix string, handler channelzHandler) *chi.Mux { + pathPrefix = prefix + router := chi.NewRouter() + router.Route(prefix, func(r chi.Router) { + r.Get("/", func(w http.ResponseWriter, r *http.Request) { + handler.WriteTopChannelsPage(w) + }) + r.Get("/channel/{channel}", func(w http.ResponseWriter, r *http.Request) { + channelStr := chi.URLParam(r, "channel") + channel, err := strconv.ParseInt(channelStr, 10, 0) + if err != nil { + log.Errorf("channelz: Unable to parse int for channel ID. %s", channelStr) + return + } + handler.WriteChannelPage(w, channel) + }) + r.Get("/channels", func(w http.ResponseWriter, r *http.Request) { + startStr := r.URL.Query().Get("start") + start, err := strconv.ParseInt(startStr, 10, 0) + if err != nil { + log.Errorf("channelz: Unable to parse int for start channel ID. %s", startStr) + return + } + handler.WriteChannelsPage(w, start) + }) + r.Get("/subchannel/{channel}", func(w http.ResponseWriter, r *http.Request) { + channelStr := chi.URLParam(r, "channel") + channel, err := strconv.ParseInt(channelStr, 10, 0) + if err != nil { + log.Errorf("channelz: Unable to parse int for sub-channel ID. %s", channelStr) + return + } + handler.WriteSubchannelPage(w, channel) + }) + r.Get("/server/{server}", func(w http.ResponseWriter, r *http.Request) { + serverStr := chi.URLParam(r, "server") + server, err := strconv.ParseInt(serverStr, 10, 0) + if err != nil { + log.Errorf("channelz: Unable to parse int for server ID. %s", serverStr) + return + } + handler.WriteServerPage(w, server) + }) + r.Get("/socket/{socket}", func(w http.ResponseWriter, r *http.Request) { + socketStr := chi.URLParam(r, "socket") + socket, err := strconv.ParseInt(socketStr, 10, 0) + if err != nil { + log.Errorf("channelz: Unable to parse int for socket ID. %s", socketStr) + return + } + handler.WriteSocketPage(w, socket) + }) + }) + return router +} + +func createHyperlink(parts ...interface{}) string { + asStrings := []string{"/" + pathPrefix} + for _, p := range parts { + switch t := p.(type) { + case string: + asStrings = append(asStrings, t) + case int: + s := strconv.Itoa(t) + asStrings = append(asStrings, s) + case int64: + s := strconv.FormatInt(t, 10) + asStrings = append(asStrings, s) + } + } + return path.Join(asStrings...) +} diff --git a/vendor/github.com/rantav/go-grpc-channelz/server-page.go b/vendor/github.com/rantav/go-grpc-channelz/server-page.go new file mode 100644 index 00000000000..4948aa0e8b1 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/server-page.go @@ -0,0 +1,93 @@ +package channelz + +import ( + "context" + "fmt" + "io" + + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" + log "google.golang.org/grpc/grpclog" +) + +func (h *grpcChannelzHandler) WriteServerPage(w io.Writer, server int64) { + writeHeader(w, fmt.Sprintf("ChannelZ server %d", server)) + h.writeServer(w, server) + writeFooter(w) +} + +// writeServer writes HTML to w containing RPC single server stats. +// +// It includes neither a header nor footer, so you can embed this data in other pages. +func (h *grpcChannelzHandler) writeServer(w io.Writer, server int64) { + if err := serverTemplate.Execute(w, h.getServer(server)); err != nil { + log.Errorf("channelz: executing template: %v", err) + } +} + +func (h *grpcChannelzHandler) getServer(serverID int64) *channelzgrpc.GetServerResponse { + client, err := h.connect() + if err != nil { + log.Errorf("Error creating channelz client %+v", err) + return nil + } + ctx := context.Background() + server, err := client.GetServer(ctx, &channelzgrpc.GetServerRequest{ServerId: serverID}) + if err != nil { + log.Errorf("Error querying GetServer %+v", err) + return nil + } + return server +} + +const serverTemplateHTML = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {{with .Server.Data.Trace}} + + + + + {{end}} +
ServerId{{.Server.Ref.ServerId}}
Server Name{{.Server.Ref.Name}}
CreationTimestamp{{with .Server.Data.Trace}} {{.CreationTimestamp | timestamp}} {{end}}
CallsStarted{{.Server.Data.CallsStarted}}
CallsSucceeded{{.Server.Data.CallsSucceeded}}
CallsFailed{{.Server.Data.CallsFailed}}
LastCallStartedTimestamp{{.Server.Data.LastCallStartedTimestamp | timestamp}}
Sockets + {{range .Server.ListenSocket}} + {{.SocketId}} {{.Name}}
+ {{end}} +
Events +
+				{{- range .Events}}
+{{.Severity}} [{{.Timestamp | timestamp}}]: {{.Description}}
+				{{- end -}}
+				
+
+` diff --git a/vendor/github.com/rantav/go-grpc-channelz/servers-page.go b/vendor/github.com/rantav/go-grpc-channelz/servers-page.go new file mode 100644 index 00000000000..cf56ba9da4a --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/servers-page.go @@ -0,0 +1,90 @@ +package channelz + +import ( + "context" + "io" + + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" + log "google.golang.org/grpc/grpclog" +) + +// writeServers writes HTML to w containing RPC servers stats. +// +// It includes neither a header nor footer, so you can embed this data in other pages. +func (h *grpcChannelzHandler) writeServers(w io.Writer) { + if err := serversTemplate.Execute(w, h.getServers()); err != nil { + log.Errorf("channelz: executing template: %v", err) + } +} + +func (h *grpcChannelzHandler) getServers() *channelzgrpc.GetServersResponse { + client, err := h.connect() + if err != nil { + log.Errorf("Error creating channelz client %+v", err) + return nil + } + ctx := context.Background() + servers, err := client.GetServers(ctx, &channelzgrpc.GetServersRequest{}) + if err != nil { + log.Errorf("Error querying GetServers %+v", err) + return nil + } + return servers +} + +const serversTemplateHTML = ` +{{define "server-header"}} + + Server + CreationTimestamp + CallsStarted + CallsSucceeded + CallsFailed + LastCallStartedTimestamp + Sockets + +{{end}} + +{{define "server-body"}} + + {{.Ref.ServerId}} {{.Ref.Name}} + {{with .Data.Trace}} {{.CreationTimestamp | timestamp}} {{end}} + {{.Data.CallsStarted}} + {{.Data.CallsSucceeded}} + {{.Data.CallsFailed}} + {{.Data.LastCallStartedTimestamp | timestamp}} + + {{range .ListenSocket}} + {{.SocketId}} {{.Name}}
+ {{end}} + + + {{with .Data.Trace}} + + Events + + +   + +
+				{{- range .Events}}
+{{.Severity}} [{{.Timestamp | timestamp}}]: {{.Description}}
+				{{- end -}}
+				
+ + + {{end}} +{{end}} + +

Servers

+ + + + + + {{template "server-header"}} + {{range .Server}} + {{template "server-body" .}} + {{end}} +
Servers: {{.Server | len}}
+` diff --git a/vendor/github.com/rantav/go-grpc-channelz/socket-page.go b/vendor/github.com/rantav/go-grpc-channelz/socket-page.go new file mode 100644 index 00000000000..0bd36ff1cff --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/socket-page.go @@ -0,0 +1,123 @@ +package channelz + +import ( + "context" + "fmt" + "io" + + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" + log "google.golang.org/grpc/grpclog" +) + +func (h *grpcChannelzHandler) WriteSocketPage(w io.Writer, socket int64) { + writeHeader(w, fmt.Sprintf("ChannelZ socket %d", socket)) + h.writeSocket(w, socket) + writeFooter(w) +} + +// writeSocket writes HTML to w containing RPC single socket stats. +// +// It includes neither a header nor footer, so you can embed this data in other pages. +func (h *grpcChannelzHandler) writeSocket(w io.Writer, socket int64) { + if err := socketTemplate.Execute(w, h.getSocket(socket)); err != nil { + log.Errorf("channelz: executing template: %v", err) + } +} + +func (h *grpcChannelzHandler) getSocket(socketID int64) *channelzgrpc.GetSocketResponse { + client, err := h.connect() + if err != nil { + log.Errorf("Error creating channelz client %+v", err) + return nil + } + ctx := context.Background() + socket, err := client.GetSocket(ctx, &channelzgrpc.GetSocketRequest{SocketId: socketID}) + if err != nil { + log.Errorf("Error querying GetSocket %+v", err) + return nil + } + return socket +} + +const socketTemplateHTML = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
SocketId + {{.Socket.Ref.SocketId}} +
Socket Name + {{.Socket.Ref.Name}} +
Socket Local -> Remote +
{{.Socket.Local}} -> {{.Socket.Remote}} {{with .Socket.RemoteName}}({{.}}){{end}}
+
StreamsStarted{{.Socket.Data.StreamsStarted}}
StreamsSucceeded{{.Socket.Data.StreamsSucceeded}}
StreamsFailed{{.Socket.Data.StreamsFailed}}
MessagesSent{{.Socket.Data.MessagesSent}}
MessagesReceived{{.Socket.Data.MessagesReceived}}
KeepAlivesSent{{.Socket.Data.KeepAlivesSent}}
LastLocalStreamCreated{{.Socket.Data.LastLocalStreamCreatedTimestamp | timestamp}}
LastRemoteStreamCreated{{.Socket.Data.LastRemoteStreamCreatedTimestamp | timestamp}}
LastMessageSent{{.Socket.Data.LastMessageSentTimestamp | timestamp}}
LastMessageReceived{{.Socket.Data.LastMessageReceivedTimestamp | timestamp}}
LocalFlowControlWindow{{.Socket.Data.LocalFlowControlWindow.Value}}
RemoteFlowControlWindow{{.Socket.Data.RemoteFlowControlWindow.Value}}
Options + {{range .Socket.Data.Option}} + {{.Name}}: {{.Value}} {{with .Additional}}({{.}}){{end}}
+ {{end}} +
Security{{.Socket.Security}}
+` diff --git a/vendor/github.com/rantav/go-grpc-channelz/sub-channel-page.go b/vendor/github.com/rantav/go-grpc-channelz/sub-channel-page.go new file mode 100644 index 00000000000..a789f827743 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/sub-channel-page.go @@ -0,0 +1,118 @@ +package channelz + +import ( + "context" + "fmt" + "io" + + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" + log "google.golang.org/grpc/grpclog" +) + +// WriteSubchannelsPage writes an HTML document to w containing per-channel RPC stats, including a header and a footer. +func (h *grpcChannelzHandler) WriteSubchannelPage(w io.Writer, subchannel int64) { + writeHeader(w, fmt.Sprintf("ChannelZ subchannel %d", subchannel)) + h.writeSubchannel(w, subchannel) + writeFooter(w) +} + +// writeSubchannel writes HTML to w containing sub-channel RPC stats. +// +// It includes neither a header nor footer, so you can embed this data in other pages. +func (h *grpcChannelzHandler) writeSubchannel(w io.Writer, subchannel int64) { + if err := subChannelTemplate.Execute(w, h.getSubchannel(subchannel)); err != nil { + log.Errorf("channelz: executing template: %v", err) + } +} + +func (h *grpcChannelzHandler) getSubchannel(subchannelID int64) *channelzgrpc.GetSubchannelResponse { + client, err := h.connect() + if err != nil { + log.Errorf("Error creating channelz client %+v", err) + return nil + } + ctx := context.Background() + subchannel, err := client.GetSubchannel(ctx, &channelzgrpc.GetSubchannelRequest{ + SubchannelId: subchannelID, + }) + if err != nil { + log.Errorf("Error querying GetSubchannel %+v", err) + return nil + } + return subchannel +} + +const subChannelsTemplateHTML = ` + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Subchannel + + {{.Subchannel.Ref.SubchannelId}} {{.Subchannel.Ref.Name}} + +
State{{.Subchannel.Data.State}}
Target{{.Subchannel.Data.Target}}
CreationTimestamp{{.Subchannel.Data.Trace.CreationTimestamp | timestamp}}
CallsStarted{{.Subchannel.Data.CallsStarted}}
CallsSucceeded{{.Subchannel.Data.CallsSucceeded}}
CallsFailed{{.Subchannel.Data.CallsFailed}}
LastCallStartedTimestamp{{.Subchannel.Data.LastCallStartedTimestamp | timestamp}}
Child Channels + {{range .Subchannel.ChannelRef}} + {{.ChannelId}} {{.Name}}
+ {{end}} +
Child Subchannels + {{range .Subchannel.SubchannelRef}} + {{.SubchannelId}} {{.Name}}
+ {{end}} +
Socket + {{range .Subchannel.SocketRef}} + {{.SocketId}} {{.Name}}
+ {{end}} +
Events +
+			{{- range .Subchannel.Data.Trace.Events}}
+{{.Severity}} [{{.Timestamp | timestamp}}]: {{.Description}}
+			{{- end -}}
+			
+
+` diff --git a/vendor/github.com/rantav/go-grpc-channelz/templates.go b/vendor/github.com/rantav/go-grpc-channelz/templates.go new file mode 100644 index 00000000000..2caac51726c --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/templates.go @@ -0,0 +1,104 @@ +package channelz + +import ( + "io" + "text/template" + "time" + + log "google.golang.org/grpc/grpclog" + "google.golang.org/protobuf/types/known/timestamppb" +) + +var ( + common *template.Template + headerTemplate = parseTemplate("header", headerTemplateHTML) + channelsTemplate = parseTemplate("channels", channelsTemplateHTML) + subChannelTemplate = parseTemplate("subchannel", subChannelsTemplateHTML) + channelTemplate = parseTemplate("channel", channelTemplateHTML) + serversTemplate = parseTemplate("servers", serversTemplateHTML) + serverTemplate = parseTemplate("server", serverTemplateHTML) + socketTemplate = parseTemplate("socket", socketTemplateHTML) + footerTemplate = parseTemplate("footer", footerTemplateHTML) +) + +func parseTemplate(name, html string) *template.Template { + if common == nil { + common = template.Must(template.New(name).Funcs(getFuncs()).Parse(html)) + return common + } + common = template.Must(common.New(name).Funcs(getFuncs()).Parse(html)) + return common +} + +func getFuncs() template.FuncMap { + return template.FuncMap{ + "timestamp": formatTimestamp, + "link": createHyperlink, + } +} + +func formatTimestamp(ts *timestamppb.Timestamp) string { + return ts.AsTime().Format(time.RFC3339) +} + +func writeHeader(w io.Writer, title string) { + if err := headerTemplate.Execute(w, headerData{Title: title}); err != nil { + log.Errorf("channelz: executing template: %v", err) + } +} + +func writeFooter(w io.Writer) { + if err := footerTemplate.Execute(w, nil); err != nil { + log.Errorf("channelz: executing template: %v", err) + } +} + +// headerData contains data for the header template. +type headerData struct { + Title string +} + +var ( + headerTemplateHTML = ` + + + + {{.Title}} + + + + + +

{{.Title}}

+` + + footerTemplateHTML = ` + + + +` +) diff --git a/vendor/github.com/rantav/go-grpc-channelz/top-channels-page.go b/vendor/github.com/rantav/go-grpc-channelz/top-channels-page.go new file mode 100644 index 00000000000..7dff859a0f7 --- /dev/null +++ b/vendor/github.com/rantav/go-grpc-channelz/top-channels-page.go @@ -0,0 +1,13 @@ +package channelz + +import ( + "io" +) + +// WriteTopChannelsPage writes an HTML document to w containing per-channel RPC stats, including a header and a footer. +func (h *grpcChannelzHandler) WriteTopChannelsPage(w io.Writer) { + writeHeader(w, "ChannelZ Stats") + h.writeChannels(w, 0) + h.writeServers(w) + writeFooter(w) +} diff --git a/vendor/github.com/weaveworks/common/server/server.go b/vendor/github.com/weaveworks/common/server/server.go index 5d4776a6893..0971c8f3a95 100644 --- a/vendor/github.com/weaveworks/common/server/server.go +++ b/vendor/github.com/weaveworks/common/server/server.go @@ -17,10 +17,12 @@ import ( "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/exporter-toolkit/web" + channelz "github.com/rantav/go-grpc-channelz" "github.com/soheilhy/cmux" "golang.org/x/net/context" "golang.org/x/net/netutil" "google.golang.org/grpc" + channelzservice "google.golang.org/grpc/channelz/service" "google.golang.org/grpc/credentials" "google.golang.org/grpc/keepalive" @@ -110,6 +112,8 @@ type Config struct { GRPCServerMinTimeBetweenPings time.Duration `yaml:"grpc_server_min_time_between_pings"` GRPCServerPingWithoutStreamAllowed bool `yaml:"grpc_server_ping_without_stream_allowed"` + EnableChannelz bool `yaml:"enable_channelz"` + LogFormat logging.Format `yaml:"log_format"` LogLevel logging.Level `yaml:"log_level"` Log logging.Interface `yaml:"-"` @@ -168,6 +172,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) { f.DurationVar(&cfg.GRPCServerTimeout, "server.grpc.keepalive.timeout", time.Second*20, "After having pinged for keepalive check, the duration after which an idle connection should be closed, Default: 20s") f.DurationVar(&cfg.GRPCServerMinTimeBetweenPings, "server.grpc.keepalive.min-time-between-pings", 5*time.Minute, "Minimum amount of time a client should wait before sending a keepalive ping. If client sends keepalive ping more often, server will send GOAWAY and close the connection.") f.BoolVar(&cfg.GRPCServerPingWithoutStreamAllowed, "server.grpc.keepalive.ping-without-stream-allowed", false, "If true, server allows keepalive pings even when there are no active streams(RPCs). If false, and client sends ping when there are no active streams, server will send GOAWAY and close the connection.") + f.BoolVar(&cfg.EnableChannelz, "server.enable-channelz", false, "Enable Channelz for gRPC server. A web UI will be also exposed on the HTTP server at /channelz") f.StringVar(&cfg.PathPrefix, "server.path-prefix", "", "Base path to serve all API routes from (e.g. /v1/)") cfg.LogFormat.RegisterFlags(f) cfg.LogLevel.RegisterFlags(f) @@ -376,6 +381,12 @@ func newServer(cfg Config, metrics *Metrics) (*Server, error) { grpcServer := grpc.NewServer(grpcOptions...) grpcOnHttpServer := grpc.NewServer(grpcOptions...) + // Register channelz service if enabled + if cfg.EnableChannelz { + channelzservice.RegisterChannelzServiceToServer(grpcServer) + channelzservice.RegisterChannelzServiceToServer(grpcOnHttpServer) + } + // Setup HTTP server var router *mux.Router if cfg.Router != nil { @@ -392,6 +403,13 @@ func newServer(cfg Config, metrics *Metrics) (*Server, error) { RegisterInstrumentationWithGatherer(router, gatherer) } + // Register channelz web UI if enabled + if cfg.EnableChannelz { + // Mount channelz handler at /channelz + grpcAddr := fmt.Sprintf("%s:%d", cfg.GRPCListenAddress, cfg.GRPCListenPort) + router.PathPrefix("/channelz").Handler(channelz.CreateHandler("/", grpcAddr)) + } + var sourceIPs *middleware.SourceIPExtractor if cfg.LogSourceIPs { sourceIPs, err = middleware.NewSourceIPs(cfg.LogSourceIPsHeader, cfg.LogSourceIPsRegex) diff --git a/vendor/google.golang.org/grpc/channelz/grpc_channelz_v1/channelz.pb.go b/vendor/google.golang.org/grpc/channelz/grpc_channelz_v1/channelz.pb.go new file mode 100644 index 00000000000..7ce1029cb55 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/grpc_channelz_v1/channelz.pb.go @@ -0,0 +1,3384 @@ +// Copyright 2018 The 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. + +// This file defines an interface for exporting monitoring information +// out of gRPC servers. See the full design at +// https://github.com/grpc/proposal/blob/master/A14-channelz.md +// +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/channelz/v1/channelz.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.6 +// protoc v5.27.1 +// source: grpc/channelz/v1/channelz.proto + +package grpc_channelz_v1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + anypb "google.golang.org/protobuf/types/known/anypb" + durationpb "google.golang.org/protobuf/types/known/durationpb" + timestamppb "google.golang.org/protobuf/types/known/timestamppb" + wrapperspb "google.golang.org/protobuf/types/known/wrapperspb" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type ChannelConnectivityState_State int32 + +const ( + ChannelConnectivityState_UNKNOWN ChannelConnectivityState_State = 0 + ChannelConnectivityState_IDLE ChannelConnectivityState_State = 1 + ChannelConnectivityState_CONNECTING ChannelConnectivityState_State = 2 + ChannelConnectivityState_READY ChannelConnectivityState_State = 3 + ChannelConnectivityState_TRANSIENT_FAILURE ChannelConnectivityState_State = 4 + ChannelConnectivityState_SHUTDOWN ChannelConnectivityState_State = 5 +) + +// Enum value maps for ChannelConnectivityState_State. +var ( + ChannelConnectivityState_State_name = map[int32]string{ + 0: "UNKNOWN", + 1: "IDLE", + 2: "CONNECTING", + 3: "READY", + 4: "TRANSIENT_FAILURE", + 5: "SHUTDOWN", + } + ChannelConnectivityState_State_value = map[string]int32{ + "UNKNOWN": 0, + "IDLE": 1, + "CONNECTING": 2, + "READY": 3, + "TRANSIENT_FAILURE": 4, + "SHUTDOWN": 5, + } +) + +func (x ChannelConnectivityState_State) Enum() *ChannelConnectivityState_State { + p := new(ChannelConnectivityState_State) + *p = x + return p +} + +func (x ChannelConnectivityState_State) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ChannelConnectivityState_State) Descriptor() protoreflect.EnumDescriptor { + return file_grpc_channelz_v1_channelz_proto_enumTypes[0].Descriptor() +} + +func (ChannelConnectivityState_State) Type() protoreflect.EnumType { + return &file_grpc_channelz_v1_channelz_proto_enumTypes[0] +} + +func (x ChannelConnectivityState_State) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ChannelConnectivityState_State.Descriptor instead. +func (ChannelConnectivityState_State) EnumDescriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{2, 0} +} + +// The supported severity levels of trace events. +type ChannelTraceEvent_Severity int32 + +const ( + ChannelTraceEvent_CT_UNKNOWN ChannelTraceEvent_Severity = 0 + ChannelTraceEvent_CT_INFO ChannelTraceEvent_Severity = 1 + ChannelTraceEvent_CT_WARNING ChannelTraceEvent_Severity = 2 + ChannelTraceEvent_CT_ERROR ChannelTraceEvent_Severity = 3 +) + +// Enum value maps for ChannelTraceEvent_Severity. +var ( + ChannelTraceEvent_Severity_name = map[int32]string{ + 0: "CT_UNKNOWN", + 1: "CT_INFO", + 2: "CT_WARNING", + 3: "CT_ERROR", + } + ChannelTraceEvent_Severity_value = map[string]int32{ + "CT_UNKNOWN": 0, + "CT_INFO": 1, + "CT_WARNING": 2, + "CT_ERROR": 3, + } +) + +func (x ChannelTraceEvent_Severity) Enum() *ChannelTraceEvent_Severity { + p := new(ChannelTraceEvent_Severity) + *p = x + return p +} + +func (x ChannelTraceEvent_Severity) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (ChannelTraceEvent_Severity) Descriptor() protoreflect.EnumDescriptor { + return file_grpc_channelz_v1_channelz_proto_enumTypes[1].Descriptor() +} + +func (ChannelTraceEvent_Severity) Type() protoreflect.EnumType { + return &file_grpc_channelz_v1_channelz_proto_enumTypes[1] +} + +func (x ChannelTraceEvent_Severity) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use ChannelTraceEvent_Severity.Descriptor instead. +func (ChannelTraceEvent_Severity) EnumDescriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{4, 0} +} + +// Channel is a logical grouping of channels, subchannels, and sockets. +type Channel struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The identifier for this channel. This should be set. + Ref *ChannelRef `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` + // Data specific to this channel. + Data *ChannelData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + // There are no ordering guarantees on the order of channel refs. + // There may not be cycles in the ref graph. + // A channel ref may be present in more than one channel or subchannel. + ChannelRef []*ChannelRef `protobuf:"bytes,3,rep,name=channel_ref,json=channelRef,proto3" json:"channel_ref,omitempty"` + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + // There are no ordering guarantees on the order of subchannel refs. + // There may not be cycles in the ref graph. + // A sub channel ref may be present in more than one channel or subchannel. + SubchannelRef []*SubchannelRef `protobuf:"bytes,4,rep,name=subchannel_ref,json=subchannelRef,proto3" json:"subchannel_ref,omitempty"` + // There are no ordering guarantees on the order of sockets. + SocketRef []*SocketRef `protobuf:"bytes,5,rep,name=socket_ref,json=socketRef,proto3" json:"socket_ref,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Channel) Reset() { + *x = Channel{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Channel) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Channel) ProtoMessage() {} + +func (x *Channel) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Channel.ProtoReflect.Descriptor instead. +func (*Channel) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{0} +} + +func (x *Channel) GetRef() *ChannelRef { + if x != nil { + return x.Ref + } + return nil +} + +func (x *Channel) GetData() *ChannelData { + if x != nil { + return x.Data + } + return nil +} + +func (x *Channel) GetChannelRef() []*ChannelRef { + if x != nil { + return x.ChannelRef + } + return nil +} + +func (x *Channel) GetSubchannelRef() []*SubchannelRef { + if x != nil { + return x.SubchannelRef + } + return nil +} + +func (x *Channel) GetSocketRef() []*SocketRef { + if x != nil { + return x.SocketRef + } + return nil +} + +// Subchannel is a logical grouping of channels, subchannels, and sockets. +// A subchannel is load balanced over by its ancestor +type Subchannel struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The identifier for this channel. + Ref *SubchannelRef `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` + // Data specific to this channel. + Data *ChannelData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + // There are no ordering guarantees on the order of channel refs. + // There may not be cycles in the ref graph. + // A channel ref may be present in more than one channel or subchannel. + ChannelRef []*ChannelRef `protobuf:"bytes,3,rep,name=channel_ref,json=channelRef,proto3" json:"channel_ref,omitempty"` + // At most one of 'channel_ref+subchannel_ref' and 'socket' is set. + // There are no ordering guarantees on the order of subchannel refs. + // There may not be cycles in the ref graph. + // A sub channel ref may be present in more than one channel or subchannel. + SubchannelRef []*SubchannelRef `protobuf:"bytes,4,rep,name=subchannel_ref,json=subchannelRef,proto3" json:"subchannel_ref,omitempty"` + // There are no ordering guarantees on the order of sockets. + SocketRef []*SocketRef `protobuf:"bytes,5,rep,name=socket_ref,json=socketRef,proto3" json:"socket_ref,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Subchannel) Reset() { + *x = Subchannel{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Subchannel) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Subchannel) ProtoMessage() {} + +func (x *Subchannel) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Subchannel.ProtoReflect.Descriptor instead. +func (*Subchannel) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{1} +} + +func (x *Subchannel) GetRef() *SubchannelRef { + if x != nil { + return x.Ref + } + return nil +} + +func (x *Subchannel) GetData() *ChannelData { + if x != nil { + return x.Data + } + return nil +} + +func (x *Subchannel) GetChannelRef() []*ChannelRef { + if x != nil { + return x.ChannelRef + } + return nil +} + +func (x *Subchannel) GetSubchannelRef() []*SubchannelRef { + if x != nil { + return x.SubchannelRef + } + return nil +} + +func (x *Subchannel) GetSocketRef() []*SocketRef { + if x != nil { + return x.SocketRef + } + return nil +} + +// These come from the specified states in this document: +// https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md +type ChannelConnectivityState struct { + state protoimpl.MessageState `protogen:"open.v1"` + State ChannelConnectivityState_State `protobuf:"varint,1,opt,name=state,proto3,enum=grpc.channelz.v1.ChannelConnectivityState_State" json:"state,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ChannelConnectivityState) Reset() { + *x = ChannelConnectivityState{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ChannelConnectivityState) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChannelConnectivityState) ProtoMessage() {} + +func (x *ChannelConnectivityState) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[2] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ChannelConnectivityState.ProtoReflect.Descriptor instead. +func (*ChannelConnectivityState) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{2} +} + +func (x *ChannelConnectivityState) GetState() ChannelConnectivityState_State { + if x != nil { + return x.State + } + return ChannelConnectivityState_UNKNOWN +} + +// Channel data is data related to a specific Channel or Subchannel. +type ChannelData struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The connectivity state of the channel or subchannel. Implementations + // should always set this. + State *ChannelConnectivityState `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"` + // The target this channel originally tried to connect to. May be absent + Target string `protobuf:"bytes,2,opt,name=target,proto3" json:"target,omitempty"` + // A trace of recent events on the channel. May be absent. + Trace *ChannelTrace `protobuf:"bytes,3,opt,name=trace,proto3" json:"trace,omitempty"` + // The number of calls started on the channel + CallsStarted int64 `protobuf:"varint,4,opt,name=calls_started,json=callsStarted,proto3" json:"calls_started,omitempty"` + // The number of calls that have completed with an OK status + CallsSucceeded int64 `protobuf:"varint,5,opt,name=calls_succeeded,json=callsSucceeded,proto3" json:"calls_succeeded,omitempty"` + // The number of calls that have completed with a non-OK status + CallsFailed int64 `protobuf:"varint,6,opt,name=calls_failed,json=callsFailed,proto3" json:"calls_failed,omitempty"` + // The last time a call was started on the channel. + LastCallStartedTimestamp *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=last_call_started_timestamp,json=lastCallStartedTimestamp,proto3" json:"last_call_started_timestamp,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ChannelData) Reset() { + *x = ChannelData{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ChannelData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChannelData) ProtoMessage() {} + +func (x *ChannelData) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[3] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ChannelData.ProtoReflect.Descriptor instead. +func (*ChannelData) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{3} +} + +func (x *ChannelData) GetState() *ChannelConnectivityState { + if x != nil { + return x.State + } + return nil +} + +func (x *ChannelData) GetTarget() string { + if x != nil { + return x.Target + } + return "" +} + +func (x *ChannelData) GetTrace() *ChannelTrace { + if x != nil { + return x.Trace + } + return nil +} + +func (x *ChannelData) GetCallsStarted() int64 { + if x != nil { + return x.CallsStarted + } + return 0 +} + +func (x *ChannelData) GetCallsSucceeded() int64 { + if x != nil { + return x.CallsSucceeded + } + return 0 +} + +func (x *ChannelData) GetCallsFailed() int64 { + if x != nil { + return x.CallsFailed + } + return 0 +} + +func (x *ChannelData) GetLastCallStartedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.LastCallStartedTimestamp + } + return nil +} + +// A trace event is an interesting thing that happened to a channel or +// subchannel, such as creation, address resolution, subchannel creation, etc. +type ChannelTraceEvent struct { + state protoimpl.MessageState `protogen:"open.v1"` + // High level description of the event. + Description string `protobuf:"bytes,1,opt,name=description,proto3" json:"description,omitempty"` + // the severity of the trace event + Severity ChannelTraceEvent_Severity `protobuf:"varint,2,opt,name=severity,proto3,enum=grpc.channelz.v1.ChannelTraceEvent_Severity" json:"severity,omitempty"` + // When this event occurred. + Timestamp *timestamppb.Timestamp `protobuf:"bytes,3,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // ref of referenced channel or subchannel. + // Optional, only present if this event refers to a child object. For example, + // this field would be filled if this trace event was for a subchannel being + // created. + // + // Types that are valid to be assigned to ChildRef: + // + // *ChannelTraceEvent_ChannelRef + // *ChannelTraceEvent_SubchannelRef + ChildRef isChannelTraceEvent_ChildRef `protobuf_oneof:"child_ref"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ChannelTraceEvent) Reset() { + *x = ChannelTraceEvent{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ChannelTraceEvent) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChannelTraceEvent) ProtoMessage() {} + +func (x *ChannelTraceEvent) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[4] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ChannelTraceEvent.ProtoReflect.Descriptor instead. +func (*ChannelTraceEvent) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{4} +} + +func (x *ChannelTraceEvent) GetDescription() string { + if x != nil { + return x.Description + } + return "" +} + +func (x *ChannelTraceEvent) GetSeverity() ChannelTraceEvent_Severity { + if x != nil { + return x.Severity + } + return ChannelTraceEvent_CT_UNKNOWN +} + +func (x *ChannelTraceEvent) GetTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.Timestamp + } + return nil +} + +func (x *ChannelTraceEvent) GetChildRef() isChannelTraceEvent_ChildRef { + if x != nil { + return x.ChildRef + } + return nil +} + +func (x *ChannelTraceEvent) GetChannelRef() *ChannelRef { + if x != nil { + if x, ok := x.ChildRef.(*ChannelTraceEvent_ChannelRef); ok { + return x.ChannelRef + } + } + return nil +} + +func (x *ChannelTraceEvent) GetSubchannelRef() *SubchannelRef { + if x != nil { + if x, ok := x.ChildRef.(*ChannelTraceEvent_SubchannelRef); ok { + return x.SubchannelRef + } + } + return nil +} + +type isChannelTraceEvent_ChildRef interface { + isChannelTraceEvent_ChildRef() +} + +type ChannelTraceEvent_ChannelRef struct { + ChannelRef *ChannelRef `protobuf:"bytes,4,opt,name=channel_ref,json=channelRef,proto3,oneof"` +} + +type ChannelTraceEvent_SubchannelRef struct { + SubchannelRef *SubchannelRef `protobuf:"bytes,5,opt,name=subchannel_ref,json=subchannelRef,proto3,oneof"` +} + +func (*ChannelTraceEvent_ChannelRef) isChannelTraceEvent_ChildRef() {} + +func (*ChannelTraceEvent_SubchannelRef) isChannelTraceEvent_ChildRef() {} + +// ChannelTrace represents the recent events that have occurred on the channel. +type ChannelTrace struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Number of events ever logged in this tracing object. This can differ from + // events.size() because events can be overwritten or garbage collected by + // implementations. + NumEventsLogged int64 `protobuf:"varint,1,opt,name=num_events_logged,json=numEventsLogged,proto3" json:"num_events_logged,omitempty"` + // Time that this channel was created. + CreationTimestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=creation_timestamp,json=creationTimestamp,proto3" json:"creation_timestamp,omitempty"` + // List of events that have occurred on this channel. + Events []*ChannelTraceEvent `protobuf:"bytes,3,rep,name=events,proto3" json:"events,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ChannelTrace) Reset() { + *x = ChannelTrace{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ChannelTrace) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChannelTrace) ProtoMessage() {} + +func (x *ChannelTrace) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[5] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ChannelTrace.ProtoReflect.Descriptor instead. +func (*ChannelTrace) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{5} +} + +func (x *ChannelTrace) GetNumEventsLogged() int64 { + if x != nil { + return x.NumEventsLogged + } + return 0 +} + +func (x *ChannelTrace) GetCreationTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.CreationTimestamp + } + return nil +} + +func (x *ChannelTrace) GetEvents() []*ChannelTraceEvent { + if x != nil { + return x.Events + } + return nil +} + +// ChannelRef is a reference to a Channel. +type ChannelRef struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The globally unique id for this channel. Must be a positive number. + ChannelId int64 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + // An optional name associated with the channel. + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ChannelRef) Reset() { + *x = ChannelRef{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ChannelRef) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ChannelRef) ProtoMessage() {} + +func (x *ChannelRef) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[6] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ChannelRef.ProtoReflect.Descriptor instead. +func (*ChannelRef) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{6} +} + +func (x *ChannelRef) GetChannelId() int64 { + if x != nil { + return x.ChannelId + } + return 0 +} + +func (x *ChannelRef) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// SubchannelRef is a reference to a Subchannel. +type SubchannelRef struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The globally unique id for this subchannel. Must be a positive number. + SubchannelId int64 `protobuf:"varint,7,opt,name=subchannel_id,json=subchannelId,proto3" json:"subchannel_id,omitempty"` + // An optional name associated with the subchannel. + Name string `protobuf:"bytes,8,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SubchannelRef) Reset() { + *x = SubchannelRef{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SubchannelRef) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SubchannelRef) ProtoMessage() {} + +func (x *SubchannelRef) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[7] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SubchannelRef.ProtoReflect.Descriptor instead. +func (*SubchannelRef) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{7} +} + +func (x *SubchannelRef) GetSubchannelId() int64 { + if x != nil { + return x.SubchannelId + } + return 0 +} + +func (x *SubchannelRef) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// SocketRef is a reference to a Socket. +type SocketRef struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The globally unique id for this socket. Must be a positive number. + SocketId int64 `protobuf:"varint,3,opt,name=socket_id,json=socketId,proto3" json:"socket_id,omitempty"` + // An optional name associated with the socket. + Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SocketRef) Reset() { + *x = SocketRef{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SocketRef) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SocketRef) ProtoMessage() {} + +func (x *SocketRef) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[8] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SocketRef.ProtoReflect.Descriptor instead. +func (*SocketRef) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{8} +} + +func (x *SocketRef) GetSocketId() int64 { + if x != nil { + return x.SocketId + } + return 0 +} + +func (x *SocketRef) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// ServerRef is a reference to a Server. +type ServerRef struct { + state protoimpl.MessageState `protogen:"open.v1"` + // A globally unique identifier for this server. Must be a positive number. + ServerId int64 `protobuf:"varint,5,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` + // An optional name associated with the server. + Name string `protobuf:"bytes,6,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServerRef) Reset() { + *x = ServerRef{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServerRef) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerRef) ProtoMessage() {} + +func (x *ServerRef) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[9] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerRef.ProtoReflect.Descriptor instead. +func (*ServerRef) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{9} +} + +func (x *ServerRef) GetServerId() int64 { + if x != nil { + return x.ServerId + } + return 0 +} + +func (x *ServerRef) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// Server represents a single server. There may be multiple servers in a single +// program. +type Server struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The identifier for a Server. This should be set. + Ref *ServerRef `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` + // The associated data of the Server. + Data *ServerData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + // The sockets that the server is listening on. There are no ordering + // guarantees. This may be absent. + ListenSocket []*SocketRef `protobuf:"bytes,3,rep,name=listen_socket,json=listenSocket,proto3" json:"listen_socket,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Server) Reset() { + *x = Server{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Server) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Server) ProtoMessage() {} + +func (x *Server) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Server.ProtoReflect.Descriptor instead. +func (*Server) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{10} +} + +func (x *Server) GetRef() *ServerRef { + if x != nil { + return x.Ref + } + return nil +} + +func (x *Server) GetData() *ServerData { + if x != nil { + return x.Data + } + return nil +} + +func (x *Server) GetListenSocket() []*SocketRef { + if x != nil { + return x.ListenSocket + } + return nil +} + +// ServerData is data for a specific Server. +type ServerData struct { + state protoimpl.MessageState `protogen:"open.v1"` + // A trace of recent events on the server. May be absent. + Trace *ChannelTrace `protobuf:"bytes,1,opt,name=trace,proto3" json:"trace,omitempty"` + // The number of incoming calls started on the server + CallsStarted int64 `protobuf:"varint,2,opt,name=calls_started,json=callsStarted,proto3" json:"calls_started,omitempty"` + // The number of incoming calls that have completed with an OK status + CallsSucceeded int64 `protobuf:"varint,3,opt,name=calls_succeeded,json=callsSucceeded,proto3" json:"calls_succeeded,omitempty"` + // The number of incoming calls that have a completed with a non-OK status + CallsFailed int64 `protobuf:"varint,4,opt,name=calls_failed,json=callsFailed,proto3" json:"calls_failed,omitempty"` + // The last time a call was started on the server. + LastCallStartedTimestamp *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=last_call_started_timestamp,json=lastCallStartedTimestamp,proto3" json:"last_call_started_timestamp,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ServerData) Reset() { + *x = ServerData{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ServerData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ServerData) ProtoMessage() {} + +func (x *ServerData) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ServerData.ProtoReflect.Descriptor instead. +func (*ServerData) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{11} +} + +func (x *ServerData) GetTrace() *ChannelTrace { + if x != nil { + return x.Trace + } + return nil +} + +func (x *ServerData) GetCallsStarted() int64 { + if x != nil { + return x.CallsStarted + } + return 0 +} + +func (x *ServerData) GetCallsSucceeded() int64 { + if x != nil { + return x.CallsSucceeded + } + return 0 +} + +func (x *ServerData) GetCallsFailed() int64 { + if x != nil { + return x.CallsFailed + } + return 0 +} + +func (x *ServerData) GetLastCallStartedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.LastCallStartedTimestamp + } + return nil +} + +// Information about an actual connection. Pronounced "sock-ay". +type Socket struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The identifier for the Socket. + Ref *SocketRef `protobuf:"bytes,1,opt,name=ref,proto3" json:"ref,omitempty"` + // Data specific to this Socket. + Data *SocketData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + // The locally bound address. + Local *Address `protobuf:"bytes,3,opt,name=local,proto3" json:"local,omitempty"` + // The remote bound address. May be absent. + Remote *Address `protobuf:"bytes,4,opt,name=remote,proto3" json:"remote,omitempty"` + // Security details for this socket. May be absent if not available, or + // there is no security on the socket. + Security *Security `protobuf:"bytes,5,opt,name=security,proto3" json:"security,omitempty"` + // Optional, represents the name of the remote endpoint, if different than + // the original target name. + RemoteName string `protobuf:"bytes,6,opt,name=remote_name,json=remoteName,proto3" json:"remote_name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Socket) Reset() { + *x = Socket{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Socket) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Socket) ProtoMessage() {} + +func (x *Socket) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Socket.ProtoReflect.Descriptor instead. +func (*Socket) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{12} +} + +func (x *Socket) GetRef() *SocketRef { + if x != nil { + return x.Ref + } + return nil +} + +func (x *Socket) GetData() *SocketData { + if x != nil { + return x.Data + } + return nil +} + +func (x *Socket) GetLocal() *Address { + if x != nil { + return x.Local + } + return nil +} + +func (x *Socket) GetRemote() *Address { + if x != nil { + return x.Remote + } + return nil +} + +func (x *Socket) GetSecurity() *Security { + if x != nil { + return x.Security + } + return nil +} + +func (x *Socket) GetRemoteName() string { + if x != nil { + return x.RemoteName + } + return "" +} + +// SocketData is data associated for a specific Socket. The fields present +// are specific to the implementation, so there may be minor differences in +// the semantics. (e.g. flow control windows) +type SocketData struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The number of streams that have been started. + StreamsStarted int64 `protobuf:"varint,1,opt,name=streams_started,json=streamsStarted,proto3" json:"streams_started,omitempty"` + // The number of streams that have ended successfully: + // On client side, received frame with eos bit set; + // On server side, sent frame with eos bit set. + StreamsSucceeded int64 `protobuf:"varint,2,opt,name=streams_succeeded,json=streamsSucceeded,proto3" json:"streams_succeeded,omitempty"` + // The number of streams that have ended unsuccessfully: + // On client side, ended without receiving frame with eos bit set; + // On server side, ended without sending frame with eos bit set. + StreamsFailed int64 `protobuf:"varint,3,opt,name=streams_failed,json=streamsFailed,proto3" json:"streams_failed,omitempty"` + // The number of grpc messages successfully sent on this socket. + MessagesSent int64 `protobuf:"varint,4,opt,name=messages_sent,json=messagesSent,proto3" json:"messages_sent,omitempty"` + // The number of grpc messages received on this socket. + MessagesReceived int64 `protobuf:"varint,5,opt,name=messages_received,json=messagesReceived,proto3" json:"messages_received,omitempty"` + // The number of keep alives sent. This is typically implemented with HTTP/2 + // ping messages. + KeepAlivesSent int64 `protobuf:"varint,6,opt,name=keep_alives_sent,json=keepAlivesSent,proto3" json:"keep_alives_sent,omitempty"` + // The last time a stream was created by this endpoint. Usually unset for + // servers. + LastLocalStreamCreatedTimestamp *timestamppb.Timestamp `protobuf:"bytes,7,opt,name=last_local_stream_created_timestamp,json=lastLocalStreamCreatedTimestamp,proto3" json:"last_local_stream_created_timestamp,omitempty"` + // The last time a stream was created by the remote endpoint. Usually unset + // for clients. + LastRemoteStreamCreatedTimestamp *timestamppb.Timestamp `protobuf:"bytes,8,opt,name=last_remote_stream_created_timestamp,json=lastRemoteStreamCreatedTimestamp,proto3" json:"last_remote_stream_created_timestamp,omitempty"` + // The last time a message was sent by this endpoint. + LastMessageSentTimestamp *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=last_message_sent_timestamp,json=lastMessageSentTimestamp,proto3" json:"last_message_sent_timestamp,omitempty"` + // The last time a message was received by this endpoint. + LastMessageReceivedTimestamp *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=last_message_received_timestamp,json=lastMessageReceivedTimestamp,proto3" json:"last_message_received_timestamp,omitempty"` + // 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 *wrapperspb.Int64Value `protobuf:"bytes,11,opt,name=local_flow_control_window,json=localFlowControlWindow,proto3" json:"local_flow_control_window,omitempty"` + // 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 *wrapperspb.Int64Value `protobuf:"bytes,12,opt,name=remote_flow_control_window,json=remoteFlowControlWindow,proto3" json:"remote_flow_control_window,omitempty"` + // Socket options set on this socket. May be absent if 'summary' is set + // on GetSocketRequest. + Option []*SocketOption `protobuf:"bytes,13,rep,name=option,proto3" json:"option,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SocketData) Reset() { + *x = SocketData{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SocketData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SocketData) ProtoMessage() {} + +func (x *SocketData) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[13] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SocketData.ProtoReflect.Descriptor instead. +func (*SocketData) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{13} +} + +func (x *SocketData) GetStreamsStarted() int64 { + if x != nil { + return x.StreamsStarted + } + return 0 +} + +func (x *SocketData) GetStreamsSucceeded() int64 { + if x != nil { + return x.StreamsSucceeded + } + return 0 +} + +func (x *SocketData) GetStreamsFailed() int64 { + if x != nil { + return x.StreamsFailed + } + return 0 +} + +func (x *SocketData) GetMessagesSent() int64 { + if x != nil { + return x.MessagesSent + } + return 0 +} + +func (x *SocketData) GetMessagesReceived() int64 { + if x != nil { + return x.MessagesReceived + } + return 0 +} + +func (x *SocketData) GetKeepAlivesSent() int64 { + if x != nil { + return x.KeepAlivesSent + } + return 0 +} + +func (x *SocketData) GetLastLocalStreamCreatedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.LastLocalStreamCreatedTimestamp + } + return nil +} + +func (x *SocketData) GetLastRemoteStreamCreatedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.LastRemoteStreamCreatedTimestamp + } + return nil +} + +func (x *SocketData) GetLastMessageSentTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.LastMessageSentTimestamp + } + return nil +} + +func (x *SocketData) GetLastMessageReceivedTimestamp() *timestamppb.Timestamp { + if x != nil { + return x.LastMessageReceivedTimestamp + } + return nil +} + +func (x *SocketData) GetLocalFlowControlWindow() *wrapperspb.Int64Value { + if x != nil { + return x.LocalFlowControlWindow + } + return nil +} + +func (x *SocketData) GetRemoteFlowControlWindow() *wrapperspb.Int64Value { + if x != nil { + return x.RemoteFlowControlWindow + } + return nil +} + +func (x *SocketData) GetOption() []*SocketOption { + if x != nil { + return x.Option + } + return nil +} + +// Address represents the address used to create the socket. +type Address struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Address: + // + // *Address_TcpipAddress + // *Address_UdsAddress_ + // *Address_OtherAddress_ + Address isAddress_Address `protobuf_oneof:"address"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Address) Reset() { + *x = Address{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Address) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Address) ProtoMessage() {} + +func (x *Address) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[14] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Address.ProtoReflect.Descriptor instead. +func (*Address) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{14} +} + +func (x *Address) GetAddress() isAddress_Address { + if x != nil { + return x.Address + } + return nil +} + +func (x *Address) GetTcpipAddress() *Address_TcpIpAddress { + if x != nil { + if x, ok := x.Address.(*Address_TcpipAddress); ok { + return x.TcpipAddress + } + } + return nil +} + +func (x *Address) GetUdsAddress() *Address_UdsAddress { + if x != nil { + if x, ok := x.Address.(*Address_UdsAddress_); ok { + return x.UdsAddress + } + } + return nil +} + +func (x *Address) GetOtherAddress() *Address_OtherAddress { + if x != nil { + if x, ok := x.Address.(*Address_OtherAddress_); ok { + return x.OtherAddress + } + } + return nil +} + +type isAddress_Address interface { + isAddress_Address() +} + +type Address_TcpipAddress struct { + TcpipAddress *Address_TcpIpAddress `protobuf:"bytes,1,opt,name=tcpip_address,json=tcpipAddress,proto3,oneof"` +} + +type Address_UdsAddress_ struct { + UdsAddress *Address_UdsAddress `protobuf:"bytes,2,opt,name=uds_address,json=udsAddress,proto3,oneof"` +} + +type Address_OtherAddress_ struct { + OtherAddress *Address_OtherAddress `protobuf:"bytes,3,opt,name=other_address,json=otherAddress,proto3,oneof"` +} + +func (*Address_TcpipAddress) isAddress_Address() {} + +func (*Address_UdsAddress_) isAddress_Address() {} + +func (*Address_OtherAddress_) isAddress_Address() {} + +// Security represents details about how secure the socket is. +type Security struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to Model: + // + // *Security_Tls_ + // *Security_Other + Model isSecurity_Model `protobuf_oneof:"model"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Security) Reset() { + *x = Security{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Security) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Security) ProtoMessage() {} + +func (x *Security) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[15] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Security.ProtoReflect.Descriptor instead. +func (*Security) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{15} +} + +func (x *Security) GetModel() isSecurity_Model { + if x != nil { + return x.Model + } + return nil +} + +func (x *Security) GetTls() *Security_Tls { + if x != nil { + if x, ok := x.Model.(*Security_Tls_); ok { + return x.Tls + } + } + return nil +} + +func (x *Security) GetOther() *Security_OtherSecurity { + if x != nil { + if x, ok := x.Model.(*Security_Other); ok { + return x.Other + } + } + return nil +} + +type isSecurity_Model interface { + isSecurity_Model() +} + +type Security_Tls_ struct { + Tls *Security_Tls `protobuf:"bytes,1,opt,name=tls,proto3,oneof"` +} + +type Security_Other struct { + Other *Security_OtherSecurity `protobuf:"bytes,2,opt,name=other,proto3,oneof"` +} + +func (*Security_Tls_) isSecurity_Model() {} + +func (*Security_Other) isSecurity_Model() {} + +// SocketOption represents socket options for a socket. Specifically, these +// are the options returned by getsockopt(). +type SocketOption struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The full name of the socket option. Typically this will be the upper case + // name, such as "SO_REUSEPORT". + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The human readable value of this socket option. At least one of value or + // additional will be set. + Value string `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + // Additional data associated with the socket option. At least one of value + // or additional will be set. + Additional *anypb.Any `protobuf:"bytes,3,opt,name=additional,proto3" json:"additional,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SocketOption) Reset() { + *x = SocketOption{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SocketOption) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SocketOption) ProtoMessage() {} + +func (x *SocketOption) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[16] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SocketOption.ProtoReflect.Descriptor instead. +func (*SocketOption) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{16} +} + +func (x *SocketOption) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *SocketOption) GetValue() string { + if x != nil { + return x.Value + } + return "" +} + +func (x *SocketOption) GetAdditional() *anypb.Any { + if x != nil { + return x.Additional + } + return nil +} + +// For use with SocketOption's additional field. This is primarily used for +// SO_RCVTIMEO and SO_SNDTIMEO +type SocketOptionTimeout struct { + state protoimpl.MessageState `protogen:"open.v1"` + Duration *durationpb.Duration `protobuf:"bytes,1,opt,name=duration,proto3" json:"duration,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SocketOptionTimeout) Reset() { + *x = SocketOptionTimeout{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SocketOptionTimeout) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SocketOptionTimeout) ProtoMessage() {} + +func (x *SocketOptionTimeout) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[17] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SocketOptionTimeout.ProtoReflect.Descriptor instead. +func (*SocketOptionTimeout) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{17} +} + +func (x *SocketOptionTimeout) GetDuration() *durationpb.Duration { + if x != nil { + return x.Duration + } + return nil +} + +// For use with SocketOption's additional field. This is primarily used for +// SO_LINGER. +type SocketOptionLinger struct { + state protoimpl.MessageState `protogen:"open.v1"` + // active maps to `struct linger.l_onoff` + Active bool `protobuf:"varint,1,opt,name=active,proto3" json:"active,omitempty"` + // duration maps to `struct linger.l_linger` + Duration *durationpb.Duration `protobuf:"bytes,2,opt,name=duration,proto3" json:"duration,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SocketOptionLinger) Reset() { + *x = SocketOptionLinger{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SocketOptionLinger) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SocketOptionLinger) ProtoMessage() {} + +func (x *SocketOptionLinger) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[18] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SocketOptionLinger.ProtoReflect.Descriptor instead. +func (*SocketOptionLinger) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{18} +} + +func (x *SocketOptionLinger) GetActive() bool { + if x != nil { + return x.Active + } + return false +} + +func (x *SocketOptionLinger) GetDuration() *durationpb.Duration { + if x != nil { + return x.Duration + } + return nil +} + +// For use with SocketOption's additional field. Tcp info for +// SOL_TCP and TCP_INFO. +type SocketOptionTcpInfo struct { + state protoimpl.MessageState `protogen:"open.v1"` + TcpiState uint32 `protobuf:"varint,1,opt,name=tcpi_state,json=tcpiState,proto3" json:"tcpi_state,omitempty"` + TcpiCaState uint32 `protobuf:"varint,2,opt,name=tcpi_ca_state,json=tcpiCaState,proto3" json:"tcpi_ca_state,omitempty"` + TcpiRetransmits uint32 `protobuf:"varint,3,opt,name=tcpi_retransmits,json=tcpiRetransmits,proto3" json:"tcpi_retransmits,omitempty"` + TcpiProbes uint32 `protobuf:"varint,4,opt,name=tcpi_probes,json=tcpiProbes,proto3" json:"tcpi_probes,omitempty"` + TcpiBackoff uint32 `protobuf:"varint,5,opt,name=tcpi_backoff,json=tcpiBackoff,proto3" json:"tcpi_backoff,omitempty"` + TcpiOptions uint32 `protobuf:"varint,6,opt,name=tcpi_options,json=tcpiOptions,proto3" json:"tcpi_options,omitempty"` + TcpiSndWscale uint32 `protobuf:"varint,7,opt,name=tcpi_snd_wscale,json=tcpiSndWscale,proto3" json:"tcpi_snd_wscale,omitempty"` + TcpiRcvWscale uint32 `protobuf:"varint,8,opt,name=tcpi_rcv_wscale,json=tcpiRcvWscale,proto3" json:"tcpi_rcv_wscale,omitempty"` + TcpiRto uint32 `protobuf:"varint,9,opt,name=tcpi_rto,json=tcpiRto,proto3" json:"tcpi_rto,omitempty"` + TcpiAto uint32 `protobuf:"varint,10,opt,name=tcpi_ato,json=tcpiAto,proto3" json:"tcpi_ato,omitempty"` + TcpiSndMss uint32 `protobuf:"varint,11,opt,name=tcpi_snd_mss,json=tcpiSndMss,proto3" json:"tcpi_snd_mss,omitempty"` + TcpiRcvMss uint32 `protobuf:"varint,12,opt,name=tcpi_rcv_mss,json=tcpiRcvMss,proto3" json:"tcpi_rcv_mss,omitempty"` + TcpiUnacked uint32 `protobuf:"varint,13,opt,name=tcpi_unacked,json=tcpiUnacked,proto3" json:"tcpi_unacked,omitempty"` + TcpiSacked uint32 `protobuf:"varint,14,opt,name=tcpi_sacked,json=tcpiSacked,proto3" json:"tcpi_sacked,omitempty"` + TcpiLost uint32 `protobuf:"varint,15,opt,name=tcpi_lost,json=tcpiLost,proto3" json:"tcpi_lost,omitempty"` + TcpiRetrans uint32 `protobuf:"varint,16,opt,name=tcpi_retrans,json=tcpiRetrans,proto3" json:"tcpi_retrans,omitempty"` + TcpiFackets uint32 `protobuf:"varint,17,opt,name=tcpi_fackets,json=tcpiFackets,proto3" json:"tcpi_fackets,omitempty"` + TcpiLastDataSent uint32 `protobuf:"varint,18,opt,name=tcpi_last_data_sent,json=tcpiLastDataSent,proto3" json:"tcpi_last_data_sent,omitempty"` + TcpiLastAckSent uint32 `protobuf:"varint,19,opt,name=tcpi_last_ack_sent,json=tcpiLastAckSent,proto3" json:"tcpi_last_ack_sent,omitempty"` + TcpiLastDataRecv uint32 `protobuf:"varint,20,opt,name=tcpi_last_data_recv,json=tcpiLastDataRecv,proto3" json:"tcpi_last_data_recv,omitempty"` + TcpiLastAckRecv uint32 `protobuf:"varint,21,opt,name=tcpi_last_ack_recv,json=tcpiLastAckRecv,proto3" json:"tcpi_last_ack_recv,omitempty"` + TcpiPmtu uint32 `protobuf:"varint,22,opt,name=tcpi_pmtu,json=tcpiPmtu,proto3" json:"tcpi_pmtu,omitempty"` + TcpiRcvSsthresh uint32 `protobuf:"varint,23,opt,name=tcpi_rcv_ssthresh,json=tcpiRcvSsthresh,proto3" json:"tcpi_rcv_ssthresh,omitempty"` + TcpiRtt uint32 `protobuf:"varint,24,opt,name=tcpi_rtt,json=tcpiRtt,proto3" json:"tcpi_rtt,omitempty"` + TcpiRttvar uint32 `protobuf:"varint,25,opt,name=tcpi_rttvar,json=tcpiRttvar,proto3" json:"tcpi_rttvar,omitempty"` + TcpiSndSsthresh uint32 `protobuf:"varint,26,opt,name=tcpi_snd_ssthresh,json=tcpiSndSsthresh,proto3" json:"tcpi_snd_ssthresh,omitempty"` + TcpiSndCwnd uint32 `protobuf:"varint,27,opt,name=tcpi_snd_cwnd,json=tcpiSndCwnd,proto3" json:"tcpi_snd_cwnd,omitempty"` + TcpiAdvmss uint32 `protobuf:"varint,28,opt,name=tcpi_advmss,json=tcpiAdvmss,proto3" json:"tcpi_advmss,omitempty"` + TcpiReordering uint32 `protobuf:"varint,29,opt,name=tcpi_reordering,json=tcpiReordering,proto3" json:"tcpi_reordering,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *SocketOptionTcpInfo) Reset() { + *x = SocketOptionTcpInfo{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *SocketOptionTcpInfo) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*SocketOptionTcpInfo) ProtoMessage() {} + +func (x *SocketOptionTcpInfo) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[19] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use SocketOptionTcpInfo.ProtoReflect.Descriptor instead. +func (*SocketOptionTcpInfo) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{19} +} + +func (x *SocketOptionTcpInfo) GetTcpiState() uint32 { + if x != nil { + return x.TcpiState + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiCaState() uint32 { + if x != nil { + return x.TcpiCaState + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiRetransmits() uint32 { + if x != nil { + return x.TcpiRetransmits + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiProbes() uint32 { + if x != nil { + return x.TcpiProbes + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiBackoff() uint32 { + if x != nil { + return x.TcpiBackoff + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiOptions() uint32 { + if x != nil { + return x.TcpiOptions + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiSndWscale() uint32 { + if x != nil { + return x.TcpiSndWscale + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiRcvWscale() uint32 { + if x != nil { + return x.TcpiRcvWscale + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiRto() uint32 { + if x != nil { + return x.TcpiRto + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiAto() uint32 { + if x != nil { + return x.TcpiAto + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiSndMss() uint32 { + if x != nil { + return x.TcpiSndMss + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiRcvMss() uint32 { + if x != nil { + return x.TcpiRcvMss + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiUnacked() uint32 { + if x != nil { + return x.TcpiUnacked + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiSacked() uint32 { + if x != nil { + return x.TcpiSacked + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiLost() uint32 { + if x != nil { + return x.TcpiLost + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiRetrans() uint32 { + if x != nil { + return x.TcpiRetrans + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiFackets() uint32 { + if x != nil { + return x.TcpiFackets + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiLastDataSent() uint32 { + if x != nil { + return x.TcpiLastDataSent + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiLastAckSent() uint32 { + if x != nil { + return x.TcpiLastAckSent + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiLastDataRecv() uint32 { + if x != nil { + return x.TcpiLastDataRecv + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiLastAckRecv() uint32 { + if x != nil { + return x.TcpiLastAckRecv + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiPmtu() uint32 { + if x != nil { + return x.TcpiPmtu + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiRcvSsthresh() uint32 { + if x != nil { + return x.TcpiRcvSsthresh + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiRtt() uint32 { + if x != nil { + return x.TcpiRtt + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiRttvar() uint32 { + if x != nil { + return x.TcpiRttvar + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiSndSsthresh() uint32 { + if x != nil { + return x.TcpiSndSsthresh + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiSndCwnd() uint32 { + if x != nil { + return x.TcpiSndCwnd + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiAdvmss() uint32 { + if x != nil { + return x.TcpiAdvmss + } + return 0 +} + +func (x *SocketOptionTcpInfo) GetTcpiReordering() uint32 { + if x != nil { + return x.TcpiReordering + } + return 0 +} + +type GetTopChannelsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // start_channel_id indicates that only channels at or above this id should be + // included in the results. + // To request the first page, this should be set to 0. To request + // subsequent pages, the client generates this value by adding 1 to + // the highest seen result ID. + StartChannelId int64 `protobuf:"varint,1,opt,name=start_channel_id,json=startChannelId,proto3" json:"start_channel_id,omitempty"` + // If non-zero, the server will return a page of results containing + // at most this many items. If zero, the server will choose a + // reasonable page size. Must never be negative. + MaxResults int64 `protobuf:"varint,2,opt,name=max_results,json=maxResults,proto3" json:"max_results,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTopChannelsRequest) Reset() { + *x = GetTopChannelsRequest{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTopChannelsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTopChannelsRequest) ProtoMessage() {} + +func (x *GetTopChannelsRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[20] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTopChannelsRequest.ProtoReflect.Descriptor instead. +func (*GetTopChannelsRequest) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{20} +} + +func (x *GetTopChannelsRequest) GetStartChannelId() int64 { + if x != nil { + return x.StartChannelId + } + return 0 +} + +func (x *GetTopChannelsRequest) GetMaxResults() int64 { + if x != nil { + return x.MaxResults + } + return 0 +} + +type GetTopChannelsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // list of channels that the connection detail service knows about. Sorted in + // ascending channel_id order. + // Must contain at least 1 result, otherwise 'end' must be true. + Channel []*Channel `protobuf:"bytes,1,rep,name=channel,proto3" json:"channel,omitempty"` + // If set, indicates that the list of channels is the final list. Requesting + // more channels can only return more if they are created after this RPC + // completes. + End bool `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetTopChannelsResponse) Reset() { + *x = GetTopChannelsResponse{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetTopChannelsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetTopChannelsResponse) ProtoMessage() {} + +func (x *GetTopChannelsResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[21] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetTopChannelsResponse.ProtoReflect.Descriptor instead. +func (*GetTopChannelsResponse) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{21} +} + +func (x *GetTopChannelsResponse) GetChannel() []*Channel { + if x != nil { + return x.Channel + } + return nil +} + +func (x *GetTopChannelsResponse) GetEnd() bool { + if x != nil { + return x.End + } + return false +} + +type GetServersRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // start_server_id indicates that only servers at or above this id should be + // included in the results. + // To request the first page, this must be set to 0. To request + // subsequent pages, the client generates this value by adding 1 to + // the highest seen result ID. + StartServerId int64 `protobuf:"varint,1,opt,name=start_server_id,json=startServerId,proto3" json:"start_server_id,omitempty"` + // If non-zero, the server will return a page of results containing + // at most this many items. If zero, the server will choose a + // reasonable page size. Must never be negative. + MaxResults int64 `protobuf:"varint,2,opt,name=max_results,json=maxResults,proto3" json:"max_results,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetServersRequest) Reset() { + *x = GetServersRequest{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetServersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetServersRequest) ProtoMessage() {} + +func (x *GetServersRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[22] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetServersRequest.ProtoReflect.Descriptor instead. +func (*GetServersRequest) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{22} +} + +func (x *GetServersRequest) GetStartServerId() int64 { + if x != nil { + return x.StartServerId + } + return 0 +} + +func (x *GetServersRequest) GetMaxResults() int64 { + if x != nil { + return x.MaxResults + } + return 0 +} + +type GetServersResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // list of servers that the connection detail service knows about. Sorted in + // ascending server_id order. + // Must contain at least 1 result, otherwise 'end' must be true. + Server []*Server `protobuf:"bytes,1,rep,name=server,proto3" json:"server,omitempty"` + // If set, indicates that the list of servers is the final list. Requesting + // more servers will only return more if they are created after this RPC + // completes. + End bool `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetServersResponse) Reset() { + *x = GetServersResponse{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetServersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetServersResponse) ProtoMessage() {} + +func (x *GetServersResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[23] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetServersResponse.ProtoReflect.Descriptor instead. +func (*GetServersResponse) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{23} +} + +func (x *GetServersResponse) GetServer() []*Server { + if x != nil { + return x.Server + } + return nil +} + +func (x *GetServersResponse) GetEnd() bool { + if x != nil { + return x.End + } + return false +} + +type GetServerRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // server_id is the identifier of the specific server to get. + ServerId int64 `protobuf:"varint,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetServerRequest) Reset() { + *x = GetServerRequest{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[24] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetServerRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetServerRequest) ProtoMessage() {} + +func (x *GetServerRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[24] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetServerRequest.ProtoReflect.Descriptor instead. +func (*GetServerRequest) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{24} +} + +func (x *GetServerRequest) GetServerId() int64 { + if x != nil { + return x.ServerId + } + return 0 +} + +type GetServerResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The Server that corresponds to the requested server_id. This field + // should be set. + Server *Server `protobuf:"bytes,1,opt,name=server,proto3" json:"server,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetServerResponse) Reset() { + *x = GetServerResponse{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetServerResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetServerResponse) ProtoMessage() {} + +func (x *GetServerResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[25] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetServerResponse.ProtoReflect.Descriptor instead. +func (*GetServerResponse) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{25} +} + +func (x *GetServerResponse) GetServer() *Server { + if x != nil { + return x.Server + } + return nil +} + +type GetServerSocketsRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + ServerId int64 `protobuf:"varint,1,opt,name=server_id,json=serverId,proto3" json:"server_id,omitempty"` + // start_socket_id indicates that only sockets at or above this id should be + // included in the results. + // To request the first page, this must be set to 0. To request + // subsequent pages, the client generates this value by adding 1 to + // the highest seen result ID. + StartSocketId int64 `protobuf:"varint,2,opt,name=start_socket_id,json=startSocketId,proto3" json:"start_socket_id,omitempty"` + // If non-zero, the server will return a page of results containing + // at most this many items. If zero, the server will choose a + // reasonable page size. Must never be negative. + MaxResults int64 `protobuf:"varint,3,opt,name=max_results,json=maxResults,proto3" json:"max_results,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetServerSocketsRequest) Reset() { + *x = GetServerSocketsRequest{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetServerSocketsRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetServerSocketsRequest) ProtoMessage() {} + +func (x *GetServerSocketsRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[26] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetServerSocketsRequest.ProtoReflect.Descriptor instead. +func (*GetServerSocketsRequest) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{26} +} + +func (x *GetServerSocketsRequest) GetServerId() int64 { + if x != nil { + return x.ServerId + } + return 0 +} + +func (x *GetServerSocketsRequest) GetStartSocketId() int64 { + if x != nil { + return x.StartSocketId + } + return 0 +} + +func (x *GetServerSocketsRequest) GetMaxResults() int64 { + if x != nil { + return x.MaxResults + } + return 0 +} + +type GetServerSocketsResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // list of socket refs that the connection detail service knows about. Sorted in + // ascending socket_id order. + // Must contain at least 1 result, otherwise 'end' must be true. + SocketRef []*SocketRef `protobuf:"bytes,1,rep,name=socket_ref,json=socketRef,proto3" json:"socket_ref,omitempty"` + // If set, indicates that the list of sockets is the final list. Requesting + // more sockets will only return more if they are created after this RPC + // completes. + End bool `protobuf:"varint,2,opt,name=end,proto3" json:"end,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetServerSocketsResponse) Reset() { + *x = GetServerSocketsResponse{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[27] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetServerSocketsResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetServerSocketsResponse) ProtoMessage() {} + +func (x *GetServerSocketsResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[27] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetServerSocketsResponse.ProtoReflect.Descriptor instead. +func (*GetServerSocketsResponse) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{27} +} + +func (x *GetServerSocketsResponse) GetSocketRef() []*SocketRef { + if x != nil { + return x.SocketRef + } + return nil +} + +func (x *GetServerSocketsResponse) GetEnd() bool { + if x != nil { + return x.End + } + return false +} + +type GetChannelRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // channel_id is the identifier of the specific channel to get. + ChannelId int64 `protobuf:"varint,1,opt,name=channel_id,json=channelId,proto3" json:"channel_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetChannelRequest) Reset() { + *x = GetChannelRequest{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[28] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetChannelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetChannelRequest) ProtoMessage() {} + +func (x *GetChannelRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[28] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetChannelRequest.ProtoReflect.Descriptor instead. +func (*GetChannelRequest) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{28} +} + +func (x *GetChannelRequest) GetChannelId() int64 { + if x != nil { + return x.ChannelId + } + return 0 +} + +type GetChannelResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The Channel that corresponds to the requested channel_id. This field + // should be set. + Channel *Channel `protobuf:"bytes,1,opt,name=channel,proto3" json:"channel,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetChannelResponse) Reset() { + *x = GetChannelResponse{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[29] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetChannelResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetChannelResponse) ProtoMessage() {} + +func (x *GetChannelResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[29] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetChannelResponse.ProtoReflect.Descriptor instead. +func (*GetChannelResponse) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{29} +} + +func (x *GetChannelResponse) GetChannel() *Channel { + if x != nil { + return x.Channel + } + return nil +} + +type GetSubchannelRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // subchannel_id is the identifier of the specific subchannel to get. + SubchannelId int64 `protobuf:"varint,1,opt,name=subchannel_id,json=subchannelId,proto3" json:"subchannel_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSubchannelRequest) Reset() { + *x = GetSubchannelRequest{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSubchannelRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSubchannelRequest) ProtoMessage() {} + +func (x *GetSubchannelRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[30] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSubchannelRequest.ProtoReflect.Descriptor instead. +func (*GetSubchannelRequest) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{30} +} + +func (x *GetSubchannelRequest) GetSubchannelId() int64 { + if x != nil { + return x.SubchannelId + } + return 0 +} + +type GetSubchannelResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The Subchannel that corresponds to the requested subchannel_id. This + // field should be set. + Subchannel *Subchannel `protobuf:"bytes,1,opt,name=subchannel,proto3" json:"subchannel,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSubchannelResponse) Reset() { + *x = GetSubchannelResponse{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSubchannelResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSubchannelResponse) ProtoMessage() {} + +func (x *GetSubchannelResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[31] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSubchannelResponse.ProtoReflect.Descriptor instead. +func (*GetSubchannelResponse) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{31} +} + +func (x *GetSubchannelResponse) GetSubchannel() *Subchannel { + if x != nil { + return x.Subchannel + } + return nil +} + +type GetSocketRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + // socket_id is the identifier of the specific socket to get. + SocketId int64 `protobuf:"varint,1,opt,name=socket_id,json=socketId,proto3" json:"socket_id,omitempty"` + // If true, the response will contain only high level information + // that is inexpensive to obtain. Fields that may be omitted are + // documented. + Summary bool `protobuf:"varint,2,opt,name=summary,proto3" json:"summary,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSocketRequest) Reset() { + *x = GetSocketRequest{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[32] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSocketRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSocketRequest) ProtoMessage() {} + +func (x *GetSocketRequest) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[32] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSocketRequest.ProtoReflect.Descriptor instead. +func (*GetSocketRequest) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{32} +} + +func (x *GetSocketRequest) GetSocketId() int64 { + if x != nil { + return x.SocketId + } + return 0 +} + +func (x *GetSocketRequest) GetSummary() bool { + if x != nil { + return x.Summary + } + return false +} + +type GetSocketResponse struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The Socket that corresponds to the requested socket_id. This field + // should be set. + Socket *Socket `protobuf:"bytes,1,opt,name=socket,proto3" json:"socket,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GetSocketResponse) Reset() { + *x = GetSocketResponse{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[33] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GetSocketResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetSocketResponse) ProtoMessage() {} + +func (x *GetSocketResponse) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[33] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetSocketResponse.ProtoReflect.Descriptor instead. +func (*GetSocketResponse) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{33} +} + +func (x *GetSocketResponse) GetSocket() *Socket { + if x != nil { + return x.Socket + } + return nil +} + +type Address_TcpIpAddress struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Either the IPv4 or IPv6 address in bytes. Will be either 4 bytes or 16 + // bytes in length. + IpAddress []byte `protobuf:"bytes,1,opt,name=ip_address,json=ipAddress,proto3" json:"ip_address,omitempty"` + // 0-64k, or -1 if not appropriate. + Port int32 `protobuf:"varint,2,opt,name=port,proto3" json:"port,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Address_TcpIpAddress) Reset() { + *x = Address_TcpIpAddress{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[34] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Address_TcpIpAddress) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Address_TcpIpAddress) ProtoMessage() {} + +func (x *Address_TcpIpAddress) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[34] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Address_TcpIpAddress.ProtoReflect.Descriptor instead. +func (*Address_TcpIpAddress) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{14, 0} +} + +func (x *Address_TcpIpAddress) GetIpAddress() []byte { + if x != nil { + return x.IpAddress + } + return nil +} + +func (x *Address_TcpIpAddress) GetPort() int32 { + if x != nil { + return x.Port + } + return 0 +} + +// A Unix Domain Socket address. +type Address_UdsAddress struct { + state protoimpl.MessageState `protogen:"open.v1"` + Filename string `protobuf:"bytes,1,opt,name=filename,proto3" json:"filename,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Address_UdsAddress) Reset() { + *x = Address_UdsAddress{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[35] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Address_UdsAddress) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Address_UdsAddress) ProtoMessage() {} + +func (x *Address_UdsAddress) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[35] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Address_UdsAddress.ProtoReflect.Descriptor instead. +func (*Address_UdsAddress) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{14, 1} +} + +func (x *Address_UdsAddress) GetFilename() string { + if x != nil { + return x.Filename + } + return "" +} + +// An address type not included above. +type Address_OtherAddress struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The human readable version of the value. This value should be set. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The actual address message. + Value *anypb.Any `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Address_OtherAddress) Reset() { + *x = Address_OtherAddress{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[36] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Address_OtherAddress) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Address_OtherAddress) ProtoMessage() {} + +func (x *Address_OtherAddress) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[36] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Address_OtherAddress.ProtoReflect.Descriptor instead. +func (*Address_OtherAddress) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{14, 2} +} + +func (x *Address_OtherAddress) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Address_OtherAddress) GetValue() *anypb.Any { + if x != nil { + return x.Value + } + return nil +} + +type Security_Tls struct { + state protoimpl.MessageState `protogen:"open.v1"` + // Types that are valid to be assigned to CipherSuite: + // + // *Security_Tls_StandardName + // *Security_Tls_OtherName + CipherSuite isSecurity_Tls_CipherSuite `protobuf_oneof:"cipher_suite"` + // the certificate used by this endpoint. + LocalCertificate []byte `protobuf:"bytes,3,opt,name=local_certificate,json=localCertificate,proto3" json:"local_certificate,omitempty"` + // the certificate used by the remote endpoint. + RemoteCertificate []byte `protobuf:"bytes,4,opt,name=remote_certificate,json=remoteCertificate,proto3" json:"remote_certificate,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Security_Tls) Reset() { + *x = Security_Tls{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[37] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Security_Tls) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Security_Tls) ProtoMessage() {} + +func (x *Security_Tls) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[37] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Security_Tls.ProtoReflect.Descriptor instead. +func (*Security_Tls) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{15, 0} +} + +func (x *Security_Tls) GetCipherSuite() isSecurity_Tls_CipherSuite { + if x != nil { + return x.CipherSuite + } + return nil +} + +func (x *Security_Tls) GetStandardName() string { + if x != nil { + if x, ok := x.CipherSuite.(*Security_Tls_StandardName); ok { + return x.StandardName + } + } + return "" +} + +func (x *Security_Tls) GetOtherName() string { + if x != nil { + if x, ok := x.CipherSuite.(*Security_Tls_OtherName); ok { + return x.OtherName + } + } + return "" +} + +func (x *Security_Tls) GetLocalCertificate() []byte { + if x != nil { + return x.LocalCertificate + } + return nil +} + +func (x *Security_Tls) GetRemoteCertificate() []byte { + if x != nil { + return x.RemoteCertificate + } + return nil +} + +type isSecurity_Tls_CipherSuite interface { + isSecurity_Tls_CipherSuite() +} + +type Security_Tls_StandardName struct { + // The cipher suite name in the RFC 4346 format: + // https://tools.ietf.org/html/rfc4346#appendix-C + StandardName string `protobuf:"bytes,1,opt,name=standard_name,json=standardName,proto3,oneof"` +} + +type Security_Tls_OtherName struct { + // Some other way to describe the cipher suite if + // the RFC 4346 name is not available. + OtherName string `protobuf:"bytes,2,opt,name=other_name,json=otherName,proto3,oneof"` +} + +func (*Security_Tls_StandardName) isSecurity_Tls_CipherSuite() {} + +func (*Security_Tls_OtherName) isSecurity_Tls_CipherSuite() {} + +type Security_OtherSecurity struct { + state protoimpl.MessageState `protogen:"open.v1"` + // The human readable version of the value. + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + // The actual security details message. + Value *anypb.Any `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Security_OtherSecurity) Reset() { + *x = Security_OtherSecurity{} + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[38] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Security_OtherSecurity) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Security_OtherSecurity) ProtoMessage() {} + +func (x *Security_OtherSecurity) ProtoReflect() protoreflect.Message { + mi := &file_grpc_channelz_v1_channelz_proto_msgTypes[38] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Security_OtherSecurity.ProtoReflect.Descriptor instead. +func (*Security_OtherSecurity) Descriptor() ([]byte, []int) { + return file_grpc_channelz_v1_channelz_proto_rawDescGZIP(), []int{15, 1} +} + +func (x *Security_OtherSecurity) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *Security_OtherSecurity) GetValue() *anypb.Any { + if x != nil { + return x.Value + } + return nil +} + +var File_grpc_channelz_v1_channelz_proto protoreflect.FileDescriptor + +const file_grpc_channelz_v1_channelz_proto_rawDesc = "" + + "\n" + + "\x1fgrpc/channelz/v1/channelz.proto\x12\x10grpc.channelz.v1\x1a\x19google/protobuf/any.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1egoogle/protobuf/wrappers.proto\"\xaf\x02\n" + + "\aChannel\x12.\n" + + "\x03ref\x18\x01 \x01(\v2\x1c.grpc.channelz.v1.ChannelRefR\x03ref\x121\n" + + "\x04data\x18\x02 \x01(\v2\x1d.grpc.channelz.v1.ChannelDataR\x04data\x12=\n" + + "\vchannel_ref\x18\x03 \x03(\v2\x1c.grpc.channelz.v1.ChannelRefR\n" + + "channelRef\x12F\n" + + "\x0esubchannel_ref\x18\x04 \x03(\v2\x1f.grpc.channelz.v1.SubchannelRefR\rsubchannelRef\x12:\n" + + "\n" + + "socket_ref\x18\x05 \x03(\v2\x1b.grpc.channelz.v1.SocketRefR\tsocketRef\"\xb5\x02\n" + + "\n" + + "Subchannel\x121\n" + + "\x03ref\x18\x01 \x01(\v2\x1f.grpc.channelz.v1.SubchannelRefR\x03ref\x121\n" + + "\x04data\x18\x02 \x01(\v2\x1d.grpc.channelz.v1.ChannelDataR\x04data\x12=\n" + + "\vchannel_ref\x18\x03 \x03(\v2\x1c.grpc.channelz.v1.ChannelRefR\n" + + "channelRef\x12F\n" + + "\x0esubchannel_ref\x18\x04 \x03(\v2\x1f.grpc.channelz.v1.SubchannelRefR\rsubchannelRef\x12:\n" + + "\n" + + "socket_ref\x18\x05 \x03(\v2\x1b.grpc.channelz.v1.SocketRefR\tsocketRef\"\xc2\x01\n" + + "\x18ChannelConnectivityState\x12F\n" + + "\x05state\x18\x01 \x01(\x0e20.grpc.channelz.v1.ChannelConnectivityState.StateR\x05state\"^\n" + + "\x05State\x12\v\n" + + "\aUNKNOWN\x10\x00\x12\b\n" + + "\x04IDLE\x10\x01\x12\x0e\n" + + "\n" + + "CONNECTING\x10\x02\x12\t\n" + + "\x05READY\x10\x03\x12\x15\n" + + "\x11TRANSIENT_FAILURE\x10\x04\x12\f\n" + + "\bSHUTDOWN\x10\x05\"\xe9\x02\n" + + "\vChannelData\x12@\n" + + "\x05state\x18\x01 \x01(\v2*.grpc.channelz.v1.ChannelConnectivityStateR\x05state\x12\x16\n" + + "\x06target\x18\x02 \x01(\tR\x06target\x124\n" + + "\x05trace\x18\x03 \x01(\v2\x1e.grpc.channelz.v1.ChannelTraceR\x05trace\x12#\n" + + "\rcalls_started\x18\x04 \x01(\x03R\fcallsStarted\x12'\n" + + "\x0fcalls_succeeded\x18\x05 \x01(\x03R\x0ecallsSucceeded\x12!\n" + + "\fcalls_failed\x18\x06 \x01(\x03R\vcallsFailed\x12Y\n" + + "\x1blast_call_started_timestamp\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\x18lastCallStartedTimestamp\"\x98\x03\n" + + "\x11ChannelTraceEvent\x12 \n" + + "\vdescription\x18\x01 \x01(\tR\vdescription\x12H\n" + + "\bseverity\x18\x02 \x01(\x0e2,.grpc.channelz.v1.ChannelTraceEvent.SeverityR\bseverity\x128\n" + + "\ttimestamp\x18\x03 \x01(\v2\x1a.google.protobuf.TimestampR\ttimestamp\x12?\n" + + "\vchannel_ref\x18\x04 \x01(\v2\x1c.grpc.channelz.v1.ChannelRefH\x00R\n" + + "channelRef\x12H\n" + + "\x0esubchannel_ref\x18\x05 \x01(\v2\x1f.grpc.channelz.v1.SubchannelRefH\x00R\rsubchannelRef\"E\n" + + "\bSeverity\x12\x0e\n" + + "\n" + + "CT_UNKNOWN\x10\x00\x12\v\n" + + "\aCT_INFO\x10\x01\x12\x0e\n" + + "\n" + + "CT_WARNING\x10\x02\x12\f\n" + + "\bCT_ERROR\x10\x03B\v\n" + + "\tchild_ref\"\xc2\x01\n" + + "\fChannelTrace\x12*\n" + + "\x11num_events_logged\x18\x01 \x01(\x03R\x0fnumEventsLogged\x12I\n" + + "\x12creation_timestamp\x18\x02 \x01(\v2\x1a.google.protobuf.TimestampR\x11creationTimestamp\x12;\n" + + "\x06events\x18\x03 \x03(\v2#.grpc.channelz.v1.ChannelTraceEventR\x06events\"c\n" + + "\n" + + "ChannelRef\x12\x1d\n" + + "\n" + + "channel_id\x18\x01 \x01(\x03R\tchannelId\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04nameJ\x04\b\x03\x10\x04J\x04\b\x04\x10\x05J\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\a\x10\bJ\x04\b\b\x10\t\"l\n" + + "\rSubchannelRef\x12#\n" + + "\rsubchannel_id\x18\a \x01(\x03R\fsubchannelId\x12\x12\n" + + "\x04name\x18\b \x01(\tR\x04nameJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03J\x04\b\x03\x10\x04J\x04\b\x04\x10\x05J\x04\b\x05\x10\x06J\x04\b\x06\x10\a\"`\n" + + "\tSocketRef\x12\x1b\n" + + "\tsocket_id\x18\x03 \x01(\x03R\bsocketId\x12\x12\n" + + "\x04name\x18\x04 \x01(\tR\x04nameJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03J\x04\b\x05\x10\x06J\x04\b\x06\x10\aJ\x04\b\a\x10\bJ\x04\b\b\x10\t\"`\n" + + "\tServerRef\x12\x1b\n" + + "\tserver_id\x18\x05 \x01(\x03R\bserverId\x12\x12\n" + + "\x04name\x18\x06 \x01(\tR\x04nameJ\x04\b\x01\x10\x02J\x04\b\x02\x10\x03J\x04\b\x03\x10\x04J\x04\b\x04\x10\x05J\x04\b\a\x10\bJ\x04\b\b\x10\t\"\xab\x01\n" + + "\x06Server\x12-\n" + + "\x03ref\x18\x01 \x01(\v2\x1b.grpc.channelz.v1.ServerRefR\x03ref\x120\n" + + "\x04data\x18\x02 \x01(\v2\x1c.grpc.channelz.v1.ServerDataR\x04data\x12@\n" + + "\rlisten_socket\x18\x03 \x03(\v2\x1b.grpc.channelz.v1.SocketRefR\flistenSocket\"\x8e\x02\n" + + "\n" + + "ServerData\x124\n" + + "\x05trace\x18\x01 \x01(\v2\x1e.grpc.channelz.v1.ChannelTraceR\x05trace\x12#\n" + + "\rcalls_started\x18\x02 \x01(\x03R\fcallsStarted\x12'\n" + + "\x0fcalls_succeeded\x18\x03 \x01(\x03R\x0ecallsSucceeded\x12!\n" + + "\fcalls_failed\x18\x04 \x01(\x03R\vcallsFailed\x12Y\n" + + "\x1blast_call_started_timestamp\x18\x05 \x01(\v2\x1a.google.protobuf.TimestampR\x18lastCallStartedTimestamp\"\xa6\x02\n" + + "\x06Socket\x12-\n" + + "\x03ref\x18\x01 \x01(\v2\x1b.grpc.channelz.v1.SocketRefR\x03ref\x120\n" + + "\x04data\x18\x02 \x01(\v2\x1c.grpc.channelz.v1.SocketDataR\x04data\x12/\n" + + "\x05local\x18\x03 \x01(\v2\x19.grpc.channelz.v1.AddressR\x05local\x121\n" + + "\x06remote\x18\x04 \x01(\v2\x19.grpc.channelz.v1.AddressR\x06remote\x126\n" + + "\bsecurity\x18\x05 \x01(\v2\x1a.grpc.channelz.v1.SecurityR\bsecurity\x12\x1f\n" + + "\vremote_name\x18\x06 \x01(\tR\n" + + "remoteName\"\x83\a\n" + + "\n" + + "SocketData\x12'\n" + + "\x0fstreams_started\x18\x01 \x01(\x03R\x0estreamsStarted\x12+\n" + + "\x11streams_succeeded\x18\x02 \x01(\x03R\x10streamsSucceeded\x12%\n" + + "\x0estreams_failed\x18\x03 \x01(\x03R\rstreamsFailed\x12#\n" + + "\rmessages_sent\x18\x04 \x01(\x03R\fmessagesSent\x12+\n" + + "\x11messages_received\x18\x05 \x01(\x03R\x10messagesReceived\x12(\n" + + "\x10keep_alives_sent\x18\x06 \x01(\x03R\x0ekeepAlivesSent\x12h\n" + + "#last_local_stream_created_timestamp\x18\a \x01(\v2\x1a.google.protobuf.TimestampR\x1flastLocalStreamCreatedTimestamp\x12j\n" + + "$last_remote_stream_created_timestamp\x18\b \x01(\v2\x1a.google.protobuf.TimestampR lastRemoteStreamCreatedTimestamp\x12Y\n" + + "\x1blast_message_sent_timestamp\x18\t \x01(\v2\x1a.google.protobuf.TimestampR\x18lastMessageSentTimestamp\x12a\n" + + "\x1flast_message_received_timestamp\x18\n" + + " \x01(\v2\x1a.google.protobuf.TimestampR\x1clastMessageReceivedTimestamp\x12V\n" + + "\x19local_flow_control_window\x18\v \x01(\v2\x1b.google.protobuf.Int64ValueR\x16localFlowControlWindow\x12X\n" + + "\x1aremote_flow_control_window\x18\f \x01(\v2\x1b.google.protobuf.Int64ValueR\x17remoteFlowControlWindow\x126\n" + + "\x06option\x18\r \x03(\v2\x1e.grpc.channelz.v1.SocketOptionR\x06option\"\xb8\x03\n" + + "\aAddress\x12M\n" + + "\rtcpip_address\x18\x01 \x01(\v2&.grpc.channelz.v1.Address.TcpIpAddressH\x00R\ftcpipAddress\x12G\n" + + "\vuds_address\x18\x02 \x01(\v2$.grpc.channelz.v1.Address.UdsAddressH\x00R\n" + + "udsAddress\x12M\n" + + "\rother_address\x18\x03 \x01(\v2&.grpc.channelz.v1.Address.OtherAddressH\x00R\fotherAddress\x1aA\n" + + "\fTcpIpAddress\x12\x1d\n" + + "\n" + + "ip_address\x18\x01 \x01(\fR\tipAddress\x12\x12\n" + + "\x04port\x18\x02 \x01(\x05R\x04port\x1a(\n" + + "\n" + + "UdsAddress\x12\x1a\n" + + "\bfilename\x18\x01 \x01(\tR\bfilename\x1aN\n" + + "\fOtherAddress\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12*\n" + + "\x05value\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x05valueB\t\n" + + "\aaddress\"\x96\x03\n" + + "\bSecurity\x122\n" + + "\x03tls\x18\x01 \x01(\v2\x1e.grpc.channelz.v1.Security.TlsH\x00R\x03tls\x12@\n" + + "\x05other\x18\x02 \x01(\v2(.grpc.channelz.v1.Security.OtherSecurityH\x00R\x05other\x1a\xb9\x01\n" + + "\x03Tls\x12%\n" + + "\rstandard_name\x18\x01 \x01(\tH\x00R\fstandardName\x12\x1f\n" + + "\n" + + "other_name\x18\x02 \x01(\tH\x00R\totherName\x12+\n" + + "\x11local_certificate\x18\x03 \x01(\fR\x10localCertificate\x12-\n" + + "\x12remote_certificate\x18\x04 \x01(\fR\x11remoteCertificateB\x0e\n" + + "\fcipher_suite\x1aO\n" + + "\rOtherSecurity\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12*\n" + + "\x05value\x18\x02 \x01(\v2\x14.google.protobuf.AnyR\x05valueB\a\n" + + "\x05model\"n\n" + + "\fSocketOption\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\x12\x14\n" + + "\x05value\x18\x02 \x01(\tR\x05value\x124\n" + + "\n" + + "additional\x18\x03 \x01(\v2\x14.google.protobuf.AnyR\n" + + "additional\"L\n" + + "\x13SocketOptionTimeout\x125\n" + + "\bduration\x18\x01 \x01(\v2\x19.google.protobuf.DurationR\bduration\"c\n" + + "\x12SocketOptionLinger\x12\x16\n" + + "\x06active\x18\x01 \x01(\bR\x06active\x125\n" + + "\bduration\x18\x02 \x01(\v2\x19.google.protobuf.DurationR\bduration\"\xb2\b\n" + + "\x13SocketOptionTcpInfo\x12\x1d\n" + + "\n" + + "tcpi_state\x18\x01 \x01(\rR\ttcpiState\x12\"\n" + + "\rtcpi_ca_state\x18\x02 \x01(\rR\vtcpiCaState\x12)\n" + + "\x10tcpi_retransmits\x18\x03 \x01(\rR\x0ftcpiRetransmits\x12\x1f\n" + + "\vtcpi_probes\x18\x04 \x01(\rR\n" + + "tcpiProbes\x12!\n" + + "\ftcpi_backoff\x18\x05 \x01(\rR\vtcpiBackoff\x12!\n" + + "\ftcpi_options\x18\x06 \x01(\rR\vtcpiOptions\x12&\n" + + "\x0ftcpi_snd_wscale\x18\a \x01(\rR\rtcpiSndWscale\x12&\n" + + "\x0ftcpi_rcv_wscale\x18\b \x01(\rR\rtcpiRcvWscale\x12\x19\n" + + "\btcpi_rto\x18\t \x01(\rR\atcpiRto\x12\x19\n" + + "\btcpi_ato\x18\n" + + " \x01(\rR\atcpiAto\x12 \n" + + "\ftcpi_snd_mss\x18\v \x01(\rR\n" + + "tcpiSndMss\x12 \n" + + "\ftcpi_rcv_mss\x18\f \x01(\rR\n" + + "tcpiRcvMss\x12!\n" + + "\ftcpi_unacked\x18\r \x01(\rR\vtcpiUnacked\x12\x1f\n" + + "\vtcpi_sacked\x18\x0e \x01(\rR\n" + + "tcpiSacked\x12\x1b\n" + + "\ttcpi_lost\x18\x0f \x01(\rR\btcpiLost\x12!\n" + + "\ftcpi_retrans\x18\x10 \x01(\rR\vtcpiRetrans\x12!\n" + + "\ftcpi_fackets\x18\x11 \x01(\rR\vtcpiFackets\x12-\n" + + "\x13tcpi_last_data_sent\x18\x12 \x01(\rR\x10tcpiLastDataSent\x12+\n" + + "\x12tcpi_last_ack_sent\x18\x13 \x01(\rR\x0ftcpiLastAckSent\x12-\n" + + "\x13tcpi_last_data_recv\x18\x14 \x01(\rR\x10tcpiLastDataRecv\x12+\n" + + "\x12tcpi_last_ack_recv\x18\x15 \x01(\rR\x0ftcpiLastAckRecv\x12\x1b\n" + + "\ttcpi_pmtu\x18\x16 \x01(\rR\btcpiPmtu\x12*\n" + + "\x11tcpi_rcv_ssthresh\x18\x17 \x01(\rR\x0ftcpiRcvSsthresh\x12\x19\n" + + "\btcpi_rtt\x18\x18 \x01(\rR\atcpiRtt\x12\x1f\n" + + "\vtcpi_rttvar\x18\x19 \x01(\rR\n" + + "tcpiRttvar\x12*\n" + + "\x11tcpi_snd_ssthresh\x18\x1a \x01(\rR\x0ftcpiSndSsthresh\x12\"\n" + + "\rtcpi_snd_cwnd\x18\x1b \x01(\rR\vtcpiSndCwnd\x12\x1f\n" + + "\vtcpi_advmss\x18\x1c \x01(\rR\n" + + "tcpiAdvmss\x12'\n" + + "\x0ftcpi_reordering\x18\x1d \x01(\rR\x0etcpiReordering\"b\n" + + "\x15GetTopChannelsRequest\x12(\n" + + "\x10start_channel_id\x18\x01 \x01(\x03R\x0estartChannelId\x12\x1f\n" + + "\vmax_results\x18\x02 \x01(\x03R\n" + + "maxResults\"_\n" + + "\x16GetTopChannelsResponse\x123\n" + + "\achannel\x18\x01 \x03(\v2\x19.grpc.channelz.v1.ChannelR\achannel\x12\x10\n" + + "\x03end\x18\x02 \x01(\bR\x03end\"\\\n" + + "\x11GetServersRequest\x12&\n" + + "\x0fstart_server_id\x18\x01 \x01(\x03R\rstartServerId\x12\x1f\n" + + "\vmax_results\x18\x02 \x01(\x03R\n" + + "maxResults\"X\n" + + "\x12GetServersResponse\x120\n" + + "\x06server\x18\x01 \x03(\v2\x18.grpc.channelz.v1.ServerR\x06server\x12\x10\n" + + "\x03end\x18\x02 \x01(\bR\x03end\"/\n" + + "\x10GetServerRequest\x12\x1b\n" + + "\tserver_id\x18\x01 \x01(\x03R\bserverId\"E\n" + + "\x11GetServerResponse\x120\n" + + "\x06server\x18\x01 \x01(\v2\x18.grpc.channelz.v1.ServerR\x06server\"\x7f\n" + + "\x17GetServerSocketsRequest\x12\x1b\n" + + "\tserver_id\x18\x01 \x01(\x03R\bserverId\x12&\n" + + "\x0fstart_socket_id\x18\x02 \x01(\x03R\rstartSocketId\x12\x1f\n" + + "\vmax_results\x18\x03 \x01(\x03R\n" + + "maxResults\"h\n" + + "\x18GetServerSocketsResponse\x12:\n" + + "\n" + + "socket_ref\x18\x01 \x03(\v2\x1b.grpc.channelz.v1.SocketRefR\tsocketRef\x12\x10\n" + + "\x03end\x18\x02 \x01(\bR\x03end\"2\n" + + "\x11GetChannelRequest\x12\x1d\n" + + "\n" + + "channel_id\x18\x01 \x01(\x03R\tchannelId\"I\n" + + "\x12GetChannelResponse\x123\n" + + "\achannel\x18\x01 \x01(\v2\x19.grpc.channelz.v1.ChannelR\achannel\";\n" + + "\x14GetSubchannelRequest\x12#\n" + + "\rsubchannel_id\x18\x01 \x01(\x03R\fsubchannelId\"U\n" + + "\x15GetSubchannelResponse\x12<\n" + + "\n" + + "subchannel\x18\x01 \x01(\v2\x1c.grpc.channelz.v1.SubchannelR\n" + + "subchannel\"I\n" + + "\x10GetSocketRequest\x12\x1b\n" + + "\tsocket_id\x18\x01 \x01(\x03R\bsocketId\x12\x18\n" + + "\asummary\x18\x02 \x01(\bR\asummary\"E\n" + + "\x11GetSocketResponse\x120\n" + + "\x06socket\x18\x01 \x01(\v2\x18.grpc.channelz.v1.SocketR\x06socket2\x9a\x05\n" + + "\bChannelz\x12c\n" + + "\x0eGetTopChannels\x12'.grpc.channelz.v1.GetTopChannelsRequest\x1a(.grpc.channelz.v1.GetTopChannelsResponse\x12W\n" + + "\n" + + "GetServers\x12#.grpc.channelz.v1.GetServersRequest\x1a$.grpc.channelz.v1.GetServersResponse\x12T\n" + + "\tGetServer\x12\".grpc.channelz.v1.GetServerRequest\x1a#.grpc.channelz.v1.GetServerResponse\x12i\n" + + "\x10GetServerSockets\x12).grpc.channelz.v1.GetServerSocketsRequest\x1a*.grpc.channelz.v1.GetServerSocketsResponse\x12W\n" + + "\n" + + "GetChannel\x12#.grpc.channelz.v1.GetChannelRequest\x1a$.grpc.channelz.v1.GetChannelResponse\x12`\n" + + "\rGetSubchannel\x12&.grpc.channelz.v1.GetSubchannelRequest\x1a'.grpc.channelz.v1.GetSubchannelResponse\x12T\n" + + "\tGetSocket\x12\".grpc.channelz.v1.GetSocketRequest\x1a#.grpc.channelz.v1.GetSocketResponseBX\n" + + "\x13io.grpc.channelz.v1B\rChannelzProtoP\x01Z0google.golang.org/grpc/channelz/grpc_channelz_v1b\x06proto3" + +var ( + file_grpc_channelz_v1_channelz_proto_rawDescOnce sync.Once + file_grpc_channelz_v1_channelz_proto_rawDescData []byte +) + +func file_grpc_channelz_v1_channelz_proto_rawDescGZIP() []byte { + file_grpc_channelz_v1_channelz_proto_rawDescOnce.Do(func() { + file_grpc_channelz_v1_channelz_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_grpc_channelz_v1_channelz_proto_rawDesc), len(file_grpc_channelz_v1_channelz_proto_rawDesc))) + }) + return file_grpc_channelz_v1_channelz_proto_rawDescData +} + +var file_grpc_channelz_v1_channelz_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_grpc_channelz_v1_channelz_proto_msgTypes = make([]protoimpl.MessageInfo, 39) +var file_grpc_channelz_v1_channelz_proto_goTypes = []any{ + (ChannelConnectivityState_State)(0), // 0: grpc.channelz.v1.ChannelConnectivityState.State + (ChannelTraceEvent_Severity)(0), // 1: grpc.channelz.v1.ChannelTraceEvent.Severity + (*Channel)(nil), // 2: grpc.channelz.v1.Channel + (*Subchannel)(nil), // 3: grpc.channelz.v1.Subchannel + (*ChannelConnectivityState)(nil), // 4: grpc.channelz.v1.ChannelConnectivityState + (*ChannelData)(nil), // 5: grpc.channelz.v1.ChannelData + (*ChannelTraceEvent)(nil), // 6: grpc.channelz.v1.ChannelTraceEvent + (*ChannelTrace)(nil), // 7: grpc.channelz.v1.ChannelTrace + (*ChannelRef)(nil), // 8: grpc.channelz.v1.ChannelRef + (*SubchannelRef)(nil), // 9: grpc.channelz.v1.SubchannelRef + (*SocketRef)(nil), // 10: grpc.channelz.v1.SocketRef + (*ServerRef)(nil), // 11: grpc.channelz.v1.ServerRef + (*Server)(nil), // 12: grpc.channelz.v1.Server + (*ServerData)(nil), // 13: grpc.channelz.v1.ServerData + (*Socket)(nil), // 14: grpc.channelz.v1.Socket + (*SocketData)(nil), // 15: grpc.channelz.v1.SocketData + (*Address)(nil), // 16: grpc.channelz.v1.Address + (*Security)(nil), // 17: grpc.channelz.v1.Security + (*SocketOption)(nil), // 18: grpc.channelz.v1.SocketOption + (*SocketOptionTimeout)(nil), // 19: grpc.channelz.v1.SocketOptionTimeout + (*SocketOptionLinger)(nil), // 20: grpc.channelz.v1.SocketOptionLinger + (*SocketOptionTcpInfo)(nil), // 21: grpc.channelz.v1.SocketOptionTcpInfo + (*GetTopChannelsRequest)(nil), // 22: grpc.channelz.v1.GetTopChannelsRequest + (*GetTopChannelsResponse)(nil), // 23: grpc.channelz.v1.GetTopChannelsResponse + (*GetServersRequest)(nil), // 24: grpc.channelz.v1.GetServersRequest + (*GetServersResponse)(nil), // 25: grpc.channelz.v1.GetServersResponse + (*GetServerRequest)(nil), // 26: grpc.channelz.v1.GetServerRequest + (*GetServerResponse)(nil), // 27: grpc.channelz.v1.GetServerResponse + (*GetServerSocketsRequest)(nil), // 28: grpc.channelz.v1.GetServerSocketsRequest + (*GetServerSocketsResponse)(nil), // 29: grpc.channelz.v1.GetServerSocketsResponse + (*GetChannelRequest)(nil), // 30: grpc.channelz.v1.GetChannelRequest + (*GetChannelResponse)(nil), // 31: grpc.channelz.v1.GetChannelResponse + (*GetSubchannelRequest)(nil), // 32: grpc.channelz.v1.GetSubchannelRequest + (*GetSubchannelResponse)(nil), // 33: grpc.channelz.v1.GetSubchannelResponse + (*GetSocketRequest)(nil), // 34: grpc.channelz.v1.GetSocketRequest + (*GetSocketResponse)(nil), // 35: grpc.channelz.v1.GetSocketResponse + (*Address_TcpIpAddress)(nil), // 36: grpc.channelz.v1.Address.TcpIpAddress + (*Address_UdsAddress)(nil), // 37: grpc.channelz.v1.Address.UdsAddress + (*Address_OtherAddress)(nil), // 38: grpc.channelz.v1.Address.OtherAddress + (*Security_Tls)(nil), // 39: grpc.channelz.v1.Security.Tls + (*Security_OtherSecurity)(nil), // 40: grpc.channelz.v1.Security.OtherSecurity + (*timestamppb.Timestamp)(nil), // 41: google.protobuf.Timestamp + (*wrapperspb.Int64Value)(nil), // 42: google.protobuf.Int64Value + (*anypb.Any)(nil), // 43: google.protobuf.Any + (*durationpb.Duration)(nil), // 44: google.protobuf.Duration +} +var file_grpc_channelz_v1_channelz_proto_depIdxs = []int32{ + 8, // 0: grpc.channelz.v1.Channel.ref:type_name -> grpc.channelz.v1.ChannelRef + 5, // 1: grpc.channelz.v1.Channel.data:type_name -> grpc.channelz.v1.ChannelData + 8, // 2: grpc.channelz.v1.Channel.channel_ref:type_name -> grpc.channelz.v1.ChannelRef + 9, // 3: grpc.channelz.v1.Channel.subchannel_ref:type_name -> grpc.channelz.v1.SubchannelRef + 10, // 4: grpc.channelz.v1.Channel.socket_ref:type_name -> grpc.channelz.v1.SocketRef + 9, // 5: grpc.channelz.v1.Subchannel.ref:type_name -> grpc.channelz.v1.SubchannelRef + 5, // 6: grpc.channelz.v1.Subchannel.data:type_name -> grpc.channelz.v1.ChannelData + 8, // 7: grpc.channelz.v1.Subchannel.channel_ref:type_name -> grpc.channelz.v1.ChannelRef + 9, // 8: grpc.channelz.v1.Subchannel.subchannel_ref:type_name -> grpc.channelz.v1.SubchannelRef + 10, // 9: grpc.channelz.v1.Subchannel.socket_ref:type_name -> grpc.channelz.v1.SocketRef + 0, // 10: grpc.channelz.v1.ChannelConnectivityState.state:type_name -> grpc.channelz.v1.ChannelConnectivityState.State + 4, // 11: grpc.channelz.v1.ChannelData.state:type_name -> grpc.channelz.v1.ChannelConnectivityState + 7, // 12: grpc.channelz.v1.ChannelData.trace:type_name -> grpc.channelz.v1.ChannelTrace + 41, // 13: grpc.channelz.v1.ChannelData.last_call_started_timestamp:type_name -> google.protobuf.Timestamp + 1, // 14: grpc.channelz.v1.ChannelTraceEvent.severity:type_name -> grpc.channelz.v1.ChannelTraceEvent.Severity + 41, // 15: grpc.channelz.v1.ChannelTraceEvent.timestamp:type_name -> google.protobuf.Timestamp + 8, // 16: grpc.channelz.v1.ChannelTraceEvent.channel_ref:type_name -> grpc.channelz.v1.ChannelRef + 9, // 17: grpc.channelz.v1.ChannelTraceEvent.subchannel_ref:type_name -> grpc.channelz.v1.SubchannelRef + 41, // 18: grpc.channelz.v1.ChannelTrace.creation_timestamp:type_name -> google.protobuf.Timestamp + 6, // 19: grpc.channelz.v1.ChannelTrace.events:type_name -> grpc.channelz.v1.ChannelTraceEvent + 11, // 20: grpc.channelz.v1.Server.ref:type_name -> grpc.channelz.v1.ServerRef + 13, // 21: grpc.channelz.v1.Server.data:type_name -> grpc.channelz.v1.ServerData + 10, // 22: grpc.channelz.v1.Server.listen_socket:type_name -> grpc.channelz.v1.SocketRef + 7, // 23: grpc.channelz.v1.ServerData.trace:type_name -> grpc.channelz.v1.ChannelTrace + 41, // 24: grpc.channelz.v1.ServerData.last_call_started_timestamp:type_name -> google.protobuf.Timestamp + 10, // 25: grpc.channelz.v1.Socket.ref:type_name -> grpc.channelz.v1.SocketRef + 15, // 26: grpc.channelz.v1.Socket.data:type_name -> grpc.channelz.v1.SocketData + 16, // 27: grpc.channelz.v1.Socket.local:type_name -> grpc.channelz.v1.Address + 16, // 28: grpc.channelz.v1.Socket.remote:type_name -> grpc.channelz.v1.Address + 17, // 29: grpc.channelz.v1.Socket.security:type_name -> grpc.channelz.v1.Security + 41, // 30: grpc.channelz.v1.SocketData.last_local_stream_created_timestamp:type_name -> google.protobuf.Timestamp + 41, // 31: grpc.channelz.v1.SocketData.last_remote_stream_created_timestamp:type_name -> google.protobuf.Timestamp + 41, // 32: grpc.channelz.v1.SocketData.last_message_sent_timestamp:type_name -> google.protobuf.Timestamp + 41, // 33: grpc.channelz.v1.SocketData.last_message_received_timestamp:type_name -> google.protobuf.Timestamp + 42, // 34: grpc.channelz.v1.SocketData.local_flow_control_window:type_name -> google.protobuf.Int64Value + 42, // 35: grpc.channelz.v1.SocketData.remote_flow_control_window:type_name -> google.protobuf.Int64Value + 18, // 36: grpc.channelz.v1.SocketData.option:type_name -> grpc.channelz.v1.SocketOption + 36, // 37: grpc.channelz.v1.Address.tcpip_address:type_name -> grpc.channelz.v1.Address.TcpIpAddress + 37, // 38: grpc.channelz.v1.Address.uds_address:type_name -> grpc.channelz.v1.Address.UdsAddress + 38, // 39: grpc.channelz.v1.Address.other_address:type_name -> grpc.channelz.v1.Address.OtherAddress + 39, // 40: grpc.channelz.v1.Security.tls:type_name -> grpc.channelz.v1.Security.Tls + 40, // 41: grpc.channelz.v1.Security.other:type_name -> grpc.channelz.v1.Security.OtherSecurity + 43, // 42: grpc.channelz.v1.SocketOption.additional:type_name -> google.protobuf.Any + 44, // 43: grpc.channelz.v1.SocketOptionTimeout.duration:type_name -> google.protobuf.Duration + 44, // 44: grpc.channelz.v1.SocketOptionLinger.duration:type_name -> google.protobuf.Duration + 2, // 45: grpc.channelz.v1.GetTopChannelsResponse.channel:type_name -> grpc.channelz.v1.Channel + 12, // 46: grpc.channelz.v1.GetServersResponse.server:type_name -> grpc.channelz.v1.Server + 12, // 47: grpc.channelz.v1.GetServerResponse.server:type_name -> grpc.channelz.v1.Server + 10, // 48: grpc.channelz.v1.GetServerSocketsResponse.socket_ref:type_name -> grpc.channelz.v1.SocketRef + 2, // 49: grpc.channelz.v1.GetChannelResponse.channel:type_name -> grpc.channelz.v1.Channel + 3, // 50: grpc.channelz.v1.GetSubchannelResponse.subchannel:type_name -> grpc.channelz.v1.Subchannel + 14, // 51: grpc.channelz.v1.GetSocketResponse.socket:type_name -> grpc.channelz.v1.Socket + 43, // 52: grpc.channelz.v1.Address.OtherAddress.value:type_name -> google.protobuf.Any + 43, // 53: grpc.channelz.v1.Security.OtherSecurity.value:type_name -> google.protobuf.Any + 22, // 54: grpc.channelz.v1.Channelz.GetTopChannels:input_type -> grpc.channelz.v1.GetTopChannelsRequest + 24, // 55: grpc.channelz.v1.Channelz.GetServers:input_type -> grpc.channelz.v1.GetServersRequest + 26, // 56: grpc.channelz.v1.Channelz.GetServer:input_type -> grpc.channelz.v1.GetServerRequest + 28, // 57: grpc.channelz.v1.Channelz.GetServerSockets:input_type -> grpc.channelz.v1.GetServerSocketsRequest + 30, // 58: grpc.channelz.v1.Channelz.GetChannel:input_type -> grpc.channelz.v1.GetChannelRequest + 32, // 59: grpc.channelz.v1.Channelz.GetSubchannel:input_type -> grpc.channelz.v1.GetSubchannelRequest + 34, // 60: grpc.channelz.v1.Channelz.GetSocket:input_type -> grpc.channelz.v1.GetSocketRequest + 23, // 61: grpc.channelz.v1.Channelz.GetTopChannels:output_type -> grpc.channelz.v1.GetTopChannelsResponse + 25, // 62: grpc.channelz.v1.Channelz.GetServers:output_type -> grpc.channelz.v1.GetServersResponse + 27, // 63: grpc.channelz.v1.Channelz.GetServer:output_type -> grpc.channelz.v1.GetServerResponse + 29, // 64: grpc.channelz.v1.Channelz.GetServerSockets:output_type -> grpc.channelz.v1.GetServerSocketsResponse + 31, // 65: grpc.channelz.v1.Channelz.GetChannel:output_type -> grpc.channelz.v1.GetChannelResponse + 33, // 66: grpc.channelz.v1.Channelz.GetSubchannel:output_type -> grpc.channelz.v1.GetSubchannelResponse + 35, // 67: grpc.channelz.v1.Channelz.GetSocket:output_type -> grpc.channelz.v1.GetSocketResponse + 61, // [61:68] is the sub-list for method output_type + 54, // [54:61] is the sub-list for method input_type + 54, // [54:54] is the sub-list for extension type_name + 54, // [54:54] is the sub-list for extension extendee + 0, // [0:54] is the sub-list for field type_name +} + +func init() { file_grpc_channelz_v1_channelz_proto_init() } +func file_grpc_channelz_v1_channelz_proto_init() { + if File_grpc_channelz_v1_channelz_proto != nil { + return + } + file_grpc_channelz_v1_channelz_proto_msgTypes[4].OneofWrappers = []any{ + (*ChannelTraceEvent_ChannelRef)(nil), + (*ChannelTraceEvent_SubchannelRef)(nil), + } + file_grpc_channelz_v1_channelz_proto_msgTypes[14].OneofWrappers = []any{ + (*Address_TcpipAddress)(nil), + (*Address_UdsAddress_)(nil), + (*Address_OtherAddress_)(nil), + } + file_grpc_channelz_v1_channelz_proto_msgTypes[15].OneofWrappers = []any{ + (*Security_Tls_)(nil), + (*Security_Other)(nil), + } + file_grpc_channelz_v1_channelz_proto_msgTypes[37].OneofWrappers = []any{ + (*Security_Tls_StandardName)(nil), + (*Security_Tls_OtherName)(nil), + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_grpc_channelz_v1_channelz_proto_rawDesc), len(file_grpc_channelz_v1_channelz_proto_rawDesc)), + NumEnums: 2, + NumMessages: 39, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_grpc_channelz_v1_channelz_proto_goTypes, + DependencyIndexes: file_grpc_channelz_v1_channelz_proto_depIdxs, + EnumInfos: file_grpc_channelz_v1_channelz_proto_enumTypes, + MessageInfos: file_grpc_channelz_v1_channelz_proto_msgTypes, + }.Build() + File_grpc_channelz_v1_channelz_proto = out.File + file_grpc_channelz_v1_channelz_proto_goTypes = nil + file_grpc_channelz_v1_channelz_proto_depIdxs = nil +} diff --git a/vendor/google.golang.org/grpc/channelz/grpc_channelz_v1/channelz_grpc.pb.go b/vendor/google.golang.org/grpc/channelz/grpc_channelz_v1/channelz_grpc.pb.go new file mode 100644 index 00000000000..4587b484f61 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/grpc_channelz_v1/channelz_grpc.pb.go @@ -0,0 +1,390 @@ +// Copyright 2018 The 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. + +// This file defines an interface for exporting monitoring information +// out of gRPC servers. See the full design at +// https://github.com/grpc/proposal/blob/master/A14-channelz.md +// +// The canonical version of this proto can be found at +// https://github.com/grpc/grpc-proto/blob/master/grpc/channelz/v1/channelz.proto + +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.5.1 +// - protoc v5.27.1 +// source: grpc/channelz/v1/channelz.proto + +package grpc_channelz_v1 + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.64.0 or later. +const _ = grpc.SupportPackageIsVersion9 + +const ( + Channelz_GetTopChannels_FullMethodName = "/grpc.channelz.v1.Channelz/GetTopChannels" + Channelz_GetServers_FullMethodName = "/grpc.channelz.v1.Channelz/GetServers" + Channelz_GetServer_FullMethodName = "/grpc.channelz.v1.Channelz/GetServer" + Channelz_GetServerSockets_FullMethodName = "/grpc.channelz.v1.Channelz/GetServerSockets" + Channelz_GetChannel_FullMethodName = "/grpc.channelz.v1.Channelz/GetChannel" + Channelz_GetSubchannel_FullMethodName = "/grpc.channelz.v1.Channelz/GetSubchannel" + Channelz_GetSocket_FullMethodName = "/grpc.channelz.v1.Channelz/GetSocket" +) + +// ChannelzClient is the client API for Channelz service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +// +// Channelz is a service exposed by gRPC servers that provides detailed debug +// information. +type ChannelzClient interface { + // Gets all root channels (i.e. channels the application has directly + // created). This does not include subchannels nor non-top level channels. + GetTopChannels(ctx context.Context, in *GetTopChannelsRequest, opts ...grpc.CallOption) (*GetTopChannelsResponse, error) + // Gets all servers that exist in the process. + GetServers(ctx context.Context, in *GetServersRequest, opts ...grpc.CallOption) (*GetServersResponse, error) + // Returns a single Server, or else a NOT_FOUND code. + GetServer(ctx context.Context, in *GetServerRequest, opts ...grpc.CallOption) (*GetServerResponse, error) + // Gets all server sockets that exist in the process. + GetServerSockets(ctx context.Context, in *GetServerSocketsRequest, opts ...grpc.CallOption) (*GetServerSocketsResponse, error) + // Returns a single Channel, or else a NOT_FOUND code. + GetChannel(ctx context.Context, in *GetChannelRequest, opts ...grpc.CallOption) (*GetChannelResponse, error) + // Returns a single Subchannel, or else a NOT_FOUND code. + GetSubchannel(ctx context.Context, in *GetSubchannelRequest, opts ...grpc.CallOption) (*GetSubchannelResponse, error) + // Returns a single Socket or else a NOT_FOUND code. + GetSocket(ctx context.Context, in *GetSocketRequest, opts ...grpc.CallOption) (*GetSocketResponse, error) +} + +type channelzClient struct { + cc grpc.ClientConnInterface +} + +func NewChannelzClient(cc grpc.ClientConnInterface) ChannelzClient { + return &channelzClient{cc} +} + +func (c *channelzClient) GetTopChannels(ctx context.Context, in *GetTopChannelsRequest, opts ...grpc.CallOption) (*GetTopChannelsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetTopChannelsResponse) + err := c.cc.Invoke(ctx, Channelz_GetTopChannels_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *channelzClient) GetServers(ctx context.Context, in *GetServersRequest, opts ...grpc.CallOption) (*GetServersResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetServersResponse) + err := c.cc.Invoke(ctx, Channelz_GetServers_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *channelzClient) GetServer(ctx context.Context, in *GetServerRequest, opts ...grpc.CallOption) (*GetServerResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetServerResponse) + err := c.cc.Invoke(ctx, Channelz_GetServer_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *channelzClient) GetServerSockets(ctx context.Context, in *GetServerSocketsRequest, opts ...grpc.CallOption) (*GetServerSocketsResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetServerSocketsResponse) + err := c.cc.Invoke(ctx, Channelz_GetServerSockets_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *channelzClient) GetChannel(ctx context.Context, in *GetChannelRequest, opts ...grpc.CallOption) (*GetChannelResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetChannelResponse) + err := c.cc.Invoke(ctx, Channelz_GetChannel_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *channelzClient) GetSubchannel(ctx context.Context, in *GetSubchannelRequest, opts ...grpc.CallOption) (*GetSubchannelResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetSubchannelResponse) + err := c.cc.Invoke(ctx, Channelz_GetSubchannel_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *channelzClient) GetSocket(ctx context.Context, in *GetSocketRequest, opts ...grpc.CallOption) (*GetSocketResponse, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(GetSocketResponse) + err := c.cc.Invoke(ctx, Channelz_GetSocket_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ChannelzServer is the server API for Channelz service. +// All implementations should embed UnimplementedChannelzServer +// for forward compatibility. +// +// Channelz is a service exposed by gRPC servers that provides detailed debug +// information. +type ChannelzServer interface { + // Gets all root channels (i.e. channels the application has directly + // created). This does not include subchannels nor non-top level channels. + GetTopChannels(context.Context, *GetTopChannelsRequest) (*GetTopChannelsResponse, error) + // Gets all servers that exist in the process. + GetServers(context.Context, *GetServersRequest) (*GetServersResponse, error) + // Returns a single Server, or else a NOT_FOUND code. + GetServer(context.Context, *GetServerRequest) (*GetServerResponse, error) + // Gets all server sockets that exist in the process. + GetServerSockets(context.Context, *GetServerSocketsRequest) (*GetServerSocketsResponse, error) + // Returns a single Channel, or else a NOT_FOUND code. + GetChannel(context.Context, *GetChannelRequest) (*GetChannelResponse, error) + // Returns a single Subchannel, or else a NOT_FOUND code. + GetSubchannel(context.Context, *GetSubchannelRequest) (*GetSubchannelResponse, error) + // Returns a single Socket or else a NOT_FOUND code. + GetSocket(context.Context, *GetSocketRequest) (*GetSocketResponse, error) +} + +// UnimplementedChannelzServer should be embedded to have +// forward compatible implementations. +// +// NOTE: this should be embedded by value instead of pointer to avoid a nil +// pointer dereference when methods are called. +type UnimplementedChannelzServer struct{} + +func (UnimplementedChannelzServer) GetTopChannels(context.Context, *GetTopChannelsRequest) (*GetTopChannelsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTopChannels not implemented") +} +func (UnimplementedChannelzServer) GetServers(context.Context, *GetServersRequest) (*GetServersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetServers not implemented") +} +func (UnimplementedChannelzServer) GetServer(context.Context, *GetServerRequest) (*GetServerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetServer not implemented") +} +func (UnimplementedChannelzServer) GetServerSockets(context.Context, *GetServerSocketsRequest) (*GetServerSocketsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetServerSockets not implemented") +} +func (UnimplementedChannelzServer) GetChannel(context.Context, *GetChannelRequest) (*GetChannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetChannel not implemented") +} +func (UnimplementedChannelzServer) GetSubchannel(context.Context, *GetSubchannelRequest) (*GetSubchannelResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSubchannel not implemented") +} +func (UnimplementedChannelzServer) GetSocket(context.Context, *GetSocketRequest) (*GetSocketResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetSocket not implemented") +} +func (UnimplementedChannelzServer) testEmbeddedByValue() {} + +// UnsafeChannelzServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ChannelzServer will +// result in compilation errors. +type UnsafeChannelzServer interface { + mustEmbedUnimplementedChannelzServer() +} + +func RegisterChannelzServer(s grpc.ServiceRegistrar, srv ChannelzServer) { + // If the following call panics, it indicates UnimplementedChannelzServer was + // embedded by pointer and is nil. This will cause panics if an + // unimplemented method is ever invoked, so we test this at initialization + // time to prevent it from happening at runtime later due to I/O. + if t, ok := srv.(interface{ testEmbeddedByValue() }); ok { + t.testEmbeddedByValue() + } + s.RegisterService(&Channelz_ServiceDesc, srv) +} + +func _Channelz_GetTopChannels_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetTopChannelsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChannelzServer).GetTopChannels(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Channelz_GetTopChannels_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChannelzServer).GetTopChannels(ctx, req.(*GetTopChannelsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Channelz_GetServers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetServersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChannelzServer).GetServers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Channelz_GetServers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChannelzServer).GetServers(ctx, req.(*GetServersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Channelz_GetServer_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetServerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChannelzServer).GetServer(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Channelz_GetServer_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChannelzServer).GetServer(ctx, req.(*GetServerRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Channelz_GetServerSockets_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetServerSocketsRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChannelzServer).GetServerSockets(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Channelz_GetServerSockets_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChannelzServer).GetServerSockets(ctx, req.(*GetServerSocketsRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Channelz_GetChannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetChannelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChannelzServer).GetChannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Channelz_GetChannel_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChannelzServer).GetChannel(ctx, req.(*GetChannelRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Channelz_GetSubchannel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetSubchannelRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChannelzServer).GetSubchannel(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Channelz_GetSubchannel_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChannelzServer).GetSubchannel(ctx, req.(*GetSubchannelRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Channelz_GetSocket_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetSocketRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ChannelzServer).GetSocket(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Channelz_GetSocket_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ChannelzServer).GetSocket(ctx, req.(*GetSocketRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Channelz_ServiceDesc is the grpc.ServiceDesc for Channelz service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Channelz_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "grpc.channelz.v1.Channelz", + HandlerType: (*ChannelzServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetTopChannels", + Handler: _Channelz_GetTopChannels_Handler, + }, + { + MethodName: "GetServers", + Handler: _Channelz_GetServers_Handler, + }, + { + MethodName: "GetServer", + Handler: _Channelz_GetServer_Handler, + }, + { + MethodName: "GetServerSockets", + Handler: _Channelz_GetServerSockets_Handler, + }, + { + MethodName: "GetChannel", + Handler: _Channelz_GetChannel_Handler, + }, + { + MethodName: "GetSubchannel", + Handler: _Channelz_GetSubchannel_Handler, + }, + { + MethodName: "GetSocket", + Handler: _Channelz_GetSocket_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "grpc/channelz/v1/channelz.proto", +} diff --git a/vendor/google.golang.org/grpc/channelz/internal/protoconv/channel.go b/vendor/google.golang.org/grpc/channelz/internal/protoconv/channel.go new file mode 100644 index 00000000000..751608b72d0 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/internal/protoconv/channel.go @@ -0,0 +1,136 @@ +/* + * + * 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 protoconv + +import ( + "time" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/connectivity" + "google.golang.org/grpc/internal/channelz" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" +) + +func connectivityStateToProto(s *connectivity.State) *channelzpb.ChannelConnectivityState { + if s == nil { + return &channelzpb.ChannelConnectivityState{State: channelzpb.ChannelConnectivityState_UNKNOWN} + } + switch *s { + case connectivity.Idle: + return &channelzpb.ChannelConnectivityState{State: channelzpb.ChannelConnectivityState_IDLE} + case connectivity.Connecting: + return &channelzpb.ChannelConnectivityState{State: channelzpb.ChannelConnectivityState_CONNECTING} + case connectivity.Ready: + return &channelzpb.ChannelConnectivityState{State: channelzpb.ChannelConnectivityState_READY} + case connectivity.TransientFailure: + return &channelzpb.ChannelConnectivityState{State: channelzpb.ChannelConnectivityState_TRANSIENT_FAILURE} + case connectivity.Shutdown: + return &channelzpb.ChannelConnectivityState{State: channelzpb.ChannelConnectivityState_SHUTDOWN} + default: + return &channelzpb.ChannelConnectivityState{State: channelzpb.ChannelConnectivityState_UNKNOWN} + } +} + +func channelTraceToProto(ct *channelz.ChannelTrace) *channelzpb.ChannelTrace { + pbt := &channelzpb.ChannelTrace{} + if ct == nil { + return pbt + } + pbt.NumEventsLogged = ct.EventNum + if ts := timestamppb.New(ct.CreationTime); ts.IsValid() { + pbt.CreationTimestamp = ts + } + events := make([]*channelzpb.ChannelTraceEvent, 0, len(ct.Events)) + for _, e := range ct.Events { + cte := &channelzpb.ChannelTraceEvent{ + Description: e.Desc, + Severity: channelzpb.ChannelTraceEvent_Severity(e.Severity), + } + if ts := timestamppb.New(e.Timestamp); ts.IsValid() { + cte.Timestamp = ts + } + if e.RefID != 0 { + switch e.RefType { + case channelz.RefChannel: + cte.ChildRef = &channelzpb.ChannelTraceEvent_ChannelRef{ChannelRef: &channelzpb.ChannelRef{ChannelId: e.RefID, Name: e.RefName}} + case channelz.RefSubChannel: + cte.ChildRef = &channelzpb.ChannelTraceEvent_SubchannelRef{SubchannelRef: &channelzpb.SubchannelRef{SubchannelId: e.RefID, Name: e.RefName}} + } + } + events = append(events, cte) + } + pbt.Events = events + return pbt +} + +func channelToProto(cm *channelz.Channel) *channelzpb.Channel { + c := &channelzpb.Channel{} + c.Ref = &channelzpb.ChannelRef{ChannelId: cm.ID, Name: cm.RefName} + + c.Data = &channelzpb.ChannelData{ + State: connectivityStateToProto(cm.ChannelMetrics.State.Load()), + Target: strFromPointer(cm.ChannelMetrics.Target.Load()), + CallsStarted: cm.ChannelMetrics.CallsStarted.Load(), + CallsSucceeded: cm.ChannelMetrics.CallsSucceeded.Load(), + CallsFailed: cm.ChannelMetrics.CallsFailed.Load(), + } + if ts := timestamppb.New(time.Unix(0, cm.ChannelMetrics.LastCallStartedTimestamp.Load())); ts.IsValid() { + c.Data.LastCallStartedTimestamp = ts + } + ncs := cm.NestedChans() + nestedChans := make([]*channelzpb.ChannelRef, 0, len(ncs)) + for id, ref := range ncs { + nestedChans = append(nestedChans, &channelzpb.ChannelRef{ChannelId: id, Name: ref}) + } + c.ChannelRef = nestedChans + + scs := cm.SubChans() + subChans := make([]*channelzpb.SubchannelRef, 0, len(scs)) + for id, ref := range scs { + subChans = append(subChans, &channelzpb.SubchannelRef{SubchannelId: id, Name: ref}) + } + c.SubchannelRef = subChans + + c.Data.Trace = channelTraceToProto(cm.Trace()) + return c +} + +// GetTopChannels returns the protobuf representation of the channels starting +// at startID (max of len), and returns end=true if no top channels exist with +// higher IDs. +func GetTopChannels(startID int64, len int) (channels []*channelzpb.Channel, end bool) { + chans, end := channelz.GetTopChannels(startID, len) + for _, ch := range chans { + channels = append(channels, channelToProto(ch)) + } + return channels, end +} + +// GetChannel returns the protobuf representation of the channel with the given +// ID. +func GetChannel(id int64) (*channelzpb.Channel, error) { + ch := channelz.GetChannel(id) + if ch == nil { + return nil, status.Errorf(codes.NotFound, "requested channel %d not found", id) + } + return channelToProto(ch), nil +} diff --git a/vendor/google.golang.org/grpc/channelz/internal/protoconv/server.go b/vendor/google.golang.org/grpc/channelz/internal/protoconv/server.go new file mode 100644 index 00000000000..af9ff36cb21 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/internal/protoconv/server.go @@ -0,0 +1,73 @@ +/* + * + * 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 protoconv + +import ( + "time" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/internal/channelz" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" +) + +func serverToProto(sm *channelz.Server) *channelzpb.Server { + s := &channelzpb.Server{} + s.Ref = &channelzpb.ServerRef{ServerId: sm.ID, Name: sm.RefName} + + s.Data = &channelzpb.ServerData{ + CallsStarted: sm.ServerMetrics.CallsStarted.Load(), + CallsSucceeded: sm.ServerMetrics.CallsSucceeded.Load(), + CallsFailed: sm.ServerMetrics.CallsFailed.Load(), + } + + if ts := timestamppb.New(time.Unix(0, sm.ServerMetrics.LastCallStartedTimestamp.Load())); ts.IsValid() { + s.Data.LastCallStartedTimestamp = ts + } + lss := sm.ListenSockets() + sockets := make([]*channelzpb.SocketRef, 0, len(lss)) + for id, ref := range lss { + sockets = append(sockets, &channelzpb.SocketRef{SocketId: id, Name: ref}) + } + s.ListenSocket = sockets + return s +} + +// GetServers returns the protobuf representation of the servers starting at +// startID (max of len), and returns end=true if no servers exist with higher +// IDs. +func GetServers(startID int64, len int) (servers []*channelzpb.Server, end bool) { + srvs, end := channelz.GetServers(startID, len) + for _, srv := range srvs { + servers = append(servers, serverToProto(srv)) + } + return servers, end +} + +// GetServer returns the protobuf representation of the server with the given +// ID. +func GetServer(id int64) (*channelzpb.Server, error) { + srv := channelz.GetServer(id) + if srv == nil { + return nil, status.Errorf(codes.NotFound, "requested server %d not found", id) + } + return serverToProto(srv), nil +} diff --git a/vendor/google.golang.org/grpc/channelz/internal/protoconv/socket.go b/vendor/google.golang.org/grpc/channelz/internal/protoconv/socket.go new file mode 100644 index 00000000000..0998f0a86e6 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/internal/protoconv/socket.go @@ -0,0 +1,136 @@ +/* + * + * 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 protoconv + +import ( + "net" + "time" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials" + "google.golang.org/grpc/internal/channelz" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/timestamppb" + "google.golang.org/protobuf/types/known/wrapperspb" + + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" +) + +func securityToProto(se credentials.ChannelzSecurityValue) *channelzpb.Security { + switch v := se.(type) { + case *credentials.TLSChannelzSecurityValue: + return &channelzpb.Security{Model: &channelzpb.Security_Tls_{Tls: &channelzpb.Security_Tls{ + CipherSuite: &channelzpb.Security_Tls_StandardName{StandardName: v.StandardName}, + LocalCertificate: v.LocalCertificate, + RemoteCertificate: v.RemoteCertificate, + }}} + case *credentials.OtherChannelzSecurityValue: + otherSecurity := &channelzpb.Security_OtherSecurity{ + Name: v.Name, + } + if anyval, err := anypb.New(v.Value); err == nil { + otherSecurity.Value = anyval + } + return &channelzpb.Security{Model: &channelzpb.Security_Other{Other: otherSecurity}} + } + return nil +} + +func addrToProto(a net.Addr) *channelzpb.Address { + if a == nil { + return nil + } + switch a.Network() { + case "udp": + // TODO: Address_OtherAddress{}. Need proto def for Value. + case "ip": + // Note zone info is discarded through the conversion. + return &channelzpb.Address{Address: &channelzpb.Address_TcpipAddress{TcpipAddress: &channelzpb.Address_TcpIpAddress{IpAddress: a.(*net.IPAddr).IP}}} + case "ip+net": + // Note mask info is discarded through the conversion. + return &channelzpb.Address{Address: &channelzpb.Address_TcpipAddress{TcpipAddress: &channelzpb.Address_TcpIpAddress{IpAddress: a.(*net.IPNet).IP}}} + case "tcp": + // Note zone info is discarded through the conversion. + return &channelzpb.Address{Address: &channelzpb.Address_TcpipAddress{TcpipAddress: &channelzpb.Address_TcpIpAddress{IpAddress: a.(*net.TCPAddr).IP, Port: int32(a.(*net.TCPAddr).Port)}}} + case "unix", "unixgram", "unixpacket": + return &channelzpb.Address{Address: &channelzpb.Address_UdsAddress_{UdsAddress: &channelzpb.Address_UdsAddress{Filename: a.String()}}} + default: + } + return &channelzpb.Address{} +} + +func socketToProto(skt *channelz.Socket) *channelzpb.Socket { + s := &channelzpb.Socket{} + s.Ref = &channelzpb.SocketRef{SocketId: skt.ID, Name: skt.RefName} + + s.Data = &channelzpb.SocketData{ + StreamsStarted: skt.SocketMetrics.StreamsStarted.Load(), + StreamsSucceeded: skt.SocketMetrics.StreamsSucceeded.Load(), + StreamsFailed: skt.SocketMetrics.StreamsFailed.Load(), + MessagesSent: skt.SocketMetrics.MessagesSent.Load(), + MessagesReceived: skt.SocketMetrics.MessagesReceived.Load(), + KeepAlivesSent: skt.SocketMetrics.KeepAlivesSent.Load(), + } + if ts := timestamppb.New(time.Unix(0, skt.SocketMetrics.LastLocalStreamCreatedTimestamp.Load())); ts.IsValid() { + s.Data.LastLocalStreamCreatedTimestamp = ts + } + if ts := timestamppb.New(time.Unix(0, skt.SocketMetrics.LastRemoteStreamCreatedTimestamp.Load())); ts.IsValid() { + s.Data.LastRemoteStreamCreatedTimestamp = ts + } + if ts := timestamppb.New(time.Unix(0, skt.SocketMetrics.LastMessageSentTimestamp.Load())); ts.IsValid() { + s.Data.LastMessageSentTimestamp = ts + } + if ts := timestamppb.New(time.Unix(0, skt.SocketMetrics.LastMessageReceivedTimestamp.Load())); ts.IsValid() { + s.Data.LastMessageReceivedTimestamp = ts + } + if skt.EphemeralMetrics != nil { + e := skt.EphemeralMetrics() + s.Data.LocalFlowControlWindow = wrapperspb.Int64(e.LocalFlowControlWindow) + s.Data.RemoteFlowControlWindow = wrapperspb.Int64(e.RemoteFlowControlWindow) + } + + s.Data.Option = sockoptToProto(skt.SocketOptions) + s.Security = securityToProto(skt.Security) + s.Local = addrToProto(skt.LocalAddr) + s.Remote = addrToProto(skt.RemoteAddr) + s.RemoteName = skt.RemoteName + return s +} + +// GetServerSockets returns the protobuf representation of the server (listen) +// sockets starting at startID (max of len), and returns end=true if no server +// sockets exist with higher IDs. +func GetServerSockets(serverID, startID int64, len int) (sockets []*channelzpb.SocketRef, end bool) { + skts, end := channelz.GetServerSockets(serverID, startID, len) + for _, m := range skts { + sockets = append(sockets, &channelzpb.SocketRef{SocketId: m.ID, Name: m.RefName}) + } + return sockets, end +} + +// GetSocket returns the protobuf representation of the socket with the given +// ID. +func GetSocket(id int64) (*channelzpb.Socket, error) { + skt := channelz.GetSocket(id) + if skt == nil { + return nil, status.Errorf(codes.NotFound, "requested socket %d not found", id) + } + return socketToProto(skt), nil +} diff --git a/vendor/google.golang.org/grpc/channelz/internal/protoconv/sockopt_linux.go b/vendor/google.golang.org/grpc/channelz/internal/protoconv/sockopt_linux.go new file mode 100644 index 00000000000..5b627735ad7 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/internal/protoconv/sockopt_linux.go @@ -0,0 +1,125 @@ +/* + * + * 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 protoconv + +import ( + "time" + + "google.golang.org/grpc/grpclog" + "google.golang.org/grpc/internal/channelz" + + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" + "google.golang.org/protobuf/types/known/anypb" + "google.golang.org/protobuf/types/known/durationpb" +) + +var logger = grpclog.Component("channelz") + +func convertToPbDuration(sec int64, usec int64) *durationpb.Duration { + return durationpb.New(time.Duration(sec*1e9 + usec*1e3)) +} + +func sockoptToProto(skopts *channelz.SocketOptionData) []*channelzpb.SocketOption { + if skopts == nil { + return nil + } + var opts []*channelzpb.SocketOption + if skopts.Linger != nil { + additional, err := anypb.New(&channelzpb.SocketOptionLinger{ + Active: skopts.Linger.Onoff != 0, + Duration: convertToPbDuration(int64(skopts.Linger.Linger), 0), + }) + if err == nil { + opts = append(opts, &channelzpb.SocketOption{ + Name: "SO_LINGER", + Additional: additional, + }) + } else { + logger.Warningf("Failed to marshal socket options linger %+v: %v", skopts.Linger, err) + } + } + if skopts.RecvTimeout != nil { + additional, err := anypb.New(&channelzpb.SocketOptionTimeout{ + Duration: convertToPbDuration(int64(skopts.RecvTimeout.Sec), int64(skopts.RecvTimeout.Usec)), + }) + if err == nil { + opts = append(opts, &channelzpb.SocketOption{ + Name: "SO_RCVTIMEO", + Additional: additional, + }) + } else { + logger.Warningf("Failed to marshal socket options receive timeout %+v: %v", skopts.RecvTimeout, err) + } + } + if skopts.SendTimeout != nil { + additional, err := anypb.New(&channelzpb.SocketOptionTimeout{ + Duration: convertToPbDuration(int64(skopts.SendTimeout.Sec), int64(skopts.SendTimeout.Usec)), + }) + if err == nil { + opts = append(opts, &channelzpb.SocketOption{ + Name: "SO_SNDTIMEO", + Additional: additional, + }) + } else { + logger.Warningf("Failed to marshal socket options send timeout %+v: %v", skopts.SendTimeout, err) + } + } + if skopts.TCPInfo != nil { + additional, err := anypb.New(&channelzpb.SocketOptionTcpInfo{ + TcpiState: uint32(skopts.TCPInfo.State), + TcpiCaState: uint32(skopts.TCPInfo.Ca_state), + TcpiRetransmits: uint32(skopts.TCPInfo.Retransmits), + TcpiProbes: uint32(skopts.TCPInfo.Probes), + TcpiBackoff: uint32(skopts.TCPInfo.Backoff), + TcpiOptions: uint32(skopts.TCPInfo.Options), + // https://golang.org/pkg/syscall/#TCPInfo + // TCPInfo struct does not contain info about TcpiSndWscale and TcpiRcvWscale. + TcpiRto: skopts.TCPInfo.Rto, + TcpiAto: skopts.TCPInfo.Ato, + TcpiSndMss: skopts.TCPInfo.Snd_mss, + TcpiRcvMss: skopts.TCPInfo.Rcv_mss, + TcpiUnacked: skopts.TCPInfo.Unacked, + TcpiSacked: skopts.TCPInfo.Sacked, + TcpiLost: skopts.TCPInfo.Lost, + TcpiRetrans: skopts.TCPInfo.Retrans, + TcpiFackets: skopts.TCPInfo.Fackets, + TcpiLastDataSent: skopts.TCPInfo.Last_data_sent, + TcpiLastAckSent: skopts.TCPInfo.Last_ack_sent, + TcpiLastDataRecv: skopts.TCPInfo.Last_data_recv, + TcpiLastAckRecv: skopts.TCPInfo.Last_ack_recv, + TcpiPmtu: skopts.TCPInfo.Pmtu, + TcpiRcvSsthresh: skopts.TCPInfo.Rcv_ssthresh, + TcpiRtt: skopts.TCPInfo.Rtt, + TcpiRttvar: skopts.TCPInfo.Rttvar, + TcpiSndSsthresh: skopts.TCPInfo.Snd_ssthresh, + TcpiSndCwnd: skopts.TCPInfo.Snd_cwnd, + TcpiAdvmss: skopts.TCPInfo.Advmss, + TcpiReordering: skopts.TCPInfo.Reordering, + }) + if err == nil { + opts = append(opts, &channelzpb.SocketOption{ + Name: "TCP_INFO", + Additional: additional, + }) + } else { + logger.Warningf("Failed to marshal socket options TCP info %+v: %v", skopts.TCPInfo, err) + } + } + return opts +} diff --git a/vendor/google.golang.org/grpc/channelz/internal/protoconv/sockopt_nonlinux.go b/vendor/google.golang.org/grpc/channelz/internal/protoconv/sockopt_nonlinux.go new file mode 100644 index 00000000000..cf5d4ee09b2 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/internal/protoconv/sockopt_nonlinux.go @@ -0,0 +1,31 @@ +//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 protoconv + +import ( + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" + "google.golang.org/grpc/internal/channelz" +) + +func sockoptToProto(_ *channelz.SocketOptionData) []*channelzpb.SocketOption { + return nil +} diff --git a/vendor/google.golang.org/grpc/channelz/internal/protoconv/subchannel.go b/vendor/google.golang.org/grpc/channelz/internal/protoconv/subchannel.go new file mode 100644 index 00000000000..6b78105744e --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/internal/protoconv/subchannel.go @@ -0,0 +1,65 @@ +/* + * + * 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 protoconv + +import ( + "time" + + "google.golang.org/grpc/codes" + "google.golang.org/grpc/internal/channelz" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" + + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" +) + +func subChannelToProto(cm *channelz.SubChannel) *channelzpb.Subchannel { + sc := &channelzpb.Subchannel{} + sc.Ref = &channelzpb.SubchannelRef{SubchannelId: cm.ID, Name: cm.RefName} + + sc.Data = &channelzpb.ChannelData{ + State: connectivityStateToProto(cm.ChannelMetrics.State.Load()), + Target: strFromPointer(cm.ChannelMetrics.Target.Load()), + CallsStarted: cm.ChannelMetrics.CallsStarted.Load(), + CallsSucceeded: cm.ChannelMetrics.CallsSucceeded.Load(), + CallsFailed: cm.ChannelMetrics.CallsFailed.Load(), + } + if ts := timestamppb.New(time.Unix(0, cm.ChannelMetrics.LastCallStartedTimestamp.Load())); ts.IsValid() { + sc.Data.LastCallStartedTimestamp = ts + } + + skts := cm.Sockets() + sockets := make([]*channelzpb.SocketRef, 0, len(skts)) + for id, ref := range skts { + sockets = append(sockets, &channelzpb.SocketRef{SocketId: id, Name: ref}) + } + sc.SocketRef = sockets + sc.Data.Trace = channelTraceToProto(cm.Trace()) + return sc +} + +// GetSubChannel returns the protobuf representation of the subchannel with the +// given ID. +func GetSubChannel(id int64) (*channelzpb.Subchannel, error) { + subChan := channelz.GetSubChannel(id) + if subChan == nil { + return nil, status.Errorf(codes.NotFound, "requested sub channel %d not found", id) + } + return subChannelToProto(subChan), nil +} diff --git a/vendor/google.golang.org/grpc/channelz/internal/protoconv/util.go b/vendor/google.golang.org/grpc/channelz/internal/protoconv/util.go new file mode 100644 index 00000000000..a4c14ecb972 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/internal/protoconv/util.go @@ -0,0 +1,28 @@ +/* + * + * 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 protoconv supports converting between the internal channelz +// implementation and the protobuf representation of all the entities. +package protoconv + +func strFromPointer(s *string) string { + if s == nil { + return "" + } + return *s +} diff --git a/vendor/google.golang.org/grpc/channelz/service/service.go b/vendor/google.golang.org/grpc/channelz/service/service.go new file mode 100644 index 00000000000..3b1f6036d18 --- /dev/null +++ b/vendor/google.golang.org/grpc/channelz/service/service.go @@ -0,0 +1,102 @@ +/* + * + * 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 service provides an implementation for channelz service server. +package service + +import ( + "context" + + channelzgrpc "google.golang.org/grpc/channelz/grpc_channelz_v1" + channelzpb "google.golang.org/grpc/channelz/grpc_channelz_v1" + + "google.golang.org/grpc" + "google.golang.org/grpc/channelz/internal/protoconv" + "google.golang.org/grpc/internal/channelz" +) + +func init() { + channelz.TurnOn() +} + +// RegisterChannelzServiceToServer registers the channelz service to the given server. +// +// Note: it is preferred to use the admin API +// (https://pkg.go.dev/google.golang.org/grpc/admin#Register) instead to +// register Channelz and other administrative services. +func RegisterChannelzServiceToServer(s grpc.ServiceRegistrar) { + channelzgrpc.RegisterChannelzServer(s, newCZServer()) +} + +func newCZServer() channelzgrpc.ChannelzServer { + return &serverImpl{} +} + +type serverImpl struct { + channelzgrpc.UnimplementedChannelzServer +} + +func (s *serverImpl) GetChannel(_ context.Context, req *channelzpb.GetChannelRequest) (*channelzpb.GetChannelResponse, error) { + ch, err := protoconv.GetChannel(req.GetChannelId()) + if err != nil { + return nil, err + } + return &channelzpb.GetChannelResponse{Channel: ch}, nil +} + +func (s *serverImpl) GetTopChannels(_ context.Context, req *channelzpb.GetTopChannelsRequest) (*channelzpb.GetTopChannelsResponse, error) { + resp := &channelzpb.GetTopChannelsResponse{} + resp.Channel, resp.End = protoconv.GetTopChannels(req.GetStartChannelId(), int(req.GetMaxResults())) + return resp, nil +} + +func (s *serverImpl) GetServer(_ context.Context, req *channelzpb.GetServerRequest) (*channelzpb.GetServerResponse, error) { + srv, err := protoconv.GetServer(req.GetServerId()) + if err != nil { + return nil, err + } + return &channelzpb.GetServerResponse{Server: srv}, nil +} + +func (s *serverImpl) GetServers(_ context.Context, req *channelzpb.GetServersRequest) (*channelzpb.GetServersResponse, error) { + resp := &channelzpb.GetServersResponse{} + resp.Server, resp.End = protoconv.GetServers(req.GetStartServerId(), int(req.GetMaxResults())) + return resp, nil +} + +func (s *serverImpl) GetSubchannel(_ context.Context, req *channelzpb.GetSubchannelRequest) (*channelzpb.GetSubchannelResponse, error) { + subChan, err := protoconv.GetSubChannel(req.GetSubchannelId()) + if err != nil { + return nil, err + } + return &channelzpb.GetSubchannelResponse{Subchannel: subChan}, nil +} + +func (s *serverImpl) GetServerSockets(_ context.Context, req *channelzpb.GetServerSocketsRequest) (*channelzpb.GetServerSocketsResponse, error) { + resp := &channelzpb.GetServerSocketsResponse{} + resp.SocketRef, resp.End = protoconv.GetServerSockets(req.GetServerId(), req.GetStartSocketId(), int(req.GetMaxResults())) + return resp, nil +} + +func (s *serverImpl) GetSocket(_ context.Context, req *channelzpb.GetSocketRequest) (*channelzpb.GetSocketResponse, error) { + socket, err := protoconv.GetSocket(req.GetSocketId()) + if err != nil { + return nil, err + } + return &channelzpb.GetSocketResponse{Socket: socket}, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 6755790bcc0..9e780f3efcd 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -448,6 +448,9 @@ github.com/felixge/httpsnoop ## explicit; go 1.17 github.com/fsnotify/fsnotify github.com/fsnotify/fsnotify/internal +# github.com/go-chi/chi/v5 v5.0.7 +## explicit; go 1.14 +github.com/go-chi/chi/v5 # github.com/go-ini/ini v1.67.0 ## explicit github.com/go-ini/ini @@ -1134,6 +1137,9 @@ github.com/prometheus/sigv4 # github.com/puzpuzpuz/xsync/v3 v3.5.1 ## explicit; go 1.18 github.com/puzpuzpuz/xsync/v3 +# github.com/rantav/go-grpc-channelz v0.0.4 +## explicit; go 1.18 +github.com/rantav/go-grpc-channelz # github.com/redis/rueidis v1.0.61 ## explicit; go 1.23.0 github.com/redis/rueidis @@ -1334,7 +1340,7 @@ github.com/vimeo/galaxycache/http github.com/vimeo/galaxycache/lru github.com/vimeo/galaxycache/promoter github.com/vimeo/galaxycache/singleflight -# github.com/weaveworks/common v0.0.0-20230728070032-dd9e68f319d5 => github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1 +# github.com/weaveworks/common v0.0.0-20230728070032-dd9e68f319d5 => github.com/cortexproject/weaveworks-common v0.0.0-20250806170222-876764c695f2 ## explicit; go 1.22 github.com/weaveworks/common/errors github.com/weaveworks/common/grpc @@ -1799,6 +1805,9 @@ google.golang.org/grpc/balancer/weightedtarget google.golang.org/grpc/balancer/weightedtarget/weightedaggregator google.golang.org/grpc/binarylog/grpc_binarylog_v1 google.golang.org/grpc/channelz +google.golang.org/grpc/channelz/grpc_channelz_v1 +google.golang.org/grpc/channelz/internal/protoconv +google.golang.org/grpc/channelz/service google.golang.org/grpc/codes google.golang.org/grpc/connectivity google.golang.org/grpc/credentials @@ -1994,7 +2003,7 @@ k8s.io/utils/clock # sigs.k8s.io/yaml v1.4.0 ## explicit; go 1.12 sigs.k8s.io/yaml/goyaml.v3 -# github.com/weaveworks/common => github.com/cortexproject/weaveworks-common v0.0.0-20241129212437-96019edf21f1 +# github.com/weaveworks/common => github.com/cortexproject/weaveworks-common v0.0.0-20250806170222-876764c695f2 # git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999 # github.com/gocql/gocql => github.com/grafana/gocql v0.0.0-20200605141915-ba5dc39ece85 # github.com/hashicorp/memberlist => github.com/grafana/memberlist v0.3.1-0.20220714140823-09ffed8adbbe