Skip to content

Commit 782d4b3

Browse files
authored
new doc: the format after gofmt (#512)
Signed-off-by: aimuz <[email protected]> Signed-off-by: aimuz <[email protected]>
1 parent cb54482 commit 782d4b3

File tree

13 files changed

+34
-22
lines changed

13 files changed

+34
-22
lines changed

doc.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// Licensed under the Apache License 2.0.
33

44
/*
5+
Package middleware
6+
57
`middleware` is a collection of gRPC middleware packages: interceptors, helpers and tools.
68
7-
Middleware
9+
# Middleware
810
911
gRPC is a fantastic RPC middleware, which sees a lot of adoption in the Golang world. However, the
1012
upstream gRPC codebase is relatively bare bones.
@@ -13,7 +15,7 @@ This package, and most of its child packages provides commonly needed middleware
1315
client-side interceptors for retires, server-side interceptors for input validation and auth,
1416
functions for chaining said interceptors, metadata convenience methods and more.
1517
16-
Chaining
18+
# Chaining
1719
1820
Simple way of turning a multiple interceptors into a single interceptor. Here's an example for
1921
server chaining:
@@ -39,7 +41,7 @@ These interceptors will be executed from left to right: monitoring and then retr
3941
4042
The retry interceptor will call every interceptor that follows it whenever when a retry happens.
4143
42-
Writing Your Own
44+
# Writing Your Own
4345
4446
Implementing your own interceptor is pretty trivial: there are interfaces for that. But the interesting
4547
bit exposing common data to handlers (and other middleware), similarly to HTTP Middleware design.

interceptors/auth/doc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// Licensed under the Apache License 2.0.
33

44
/*
5+
Package auth is a middleware that authenticates incoming gRPC requests.
6+
57
`auth` a generic server-side auth middleware for gRPC.
68
7-
Server Side Auth Middleware
9+
# Server Side Auth Middleware
810
911
It allows for easy assertion of `:authorization` headers in gRPC calls, be it HTTP Basic auth, or
1012
OAuth2 Bearer tokens.

interceptors/logging/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ All logging middleware will emit a final log statement. It is based on the error
1313
the gRPC status code, an error (if any) and it emits at a level controlled via `WithLevels`. You can control this behavior
1414
using `WithDecider`.
1515
16-
This parent package
16+
# This parent package
1717
1818
This particular package is intended for use by other middleware, logging or otherwise. It contains interfaces that other
1919
logging middlewares *could* share. This allows code to be shared between different implementations.
2020
21-
Field names
21+
# Field names
2222
2323
All field names of loggers follow the OpenTracing semantics definitions, with `grpc.` prefix if needed:
2424
https://github.com/opentracing/specification/blob/master/semantic_conventions.md

interceptors/ratelimit/doc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// Licensed under the Apache License 2.0.
33

44
/*
5+
Package ratelimit is a middleware that limits the rate of requests.
6+
57
`ratelimit` a generic server-side ratelimit middleware for gRPC.
68
7-
Server Side Ratelimit Middleware
9+
# Server Side Ratelimit Middleware
810
911
It allows to do grpc rate limit by your own rate limiter (e.g. token bucket, leaky bucket, etc.)
1012

interceptors/recovery/doc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
// See LICENSE for licensing terms.
66

77
/*
8+
Package recovery is a middleware that recovers from panics and logs the panic message.
9+
810
`recovery` are interceptors that recover from gRPC handler panics.
911
10-
Server Side Recovery Middleware
12+
# Server Side Recovery Middleware
1113
1214
By default a panic will be converted into a gRPC error with `code.Internal`.
1315

interceptors/retry/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
/*
55
Package retry provides client-side request retry logic for gRPC.
66
7-
Client-Side Request Retry Interceptor
7+
# Client-Side Request Retry Interceptor
88
99
It allows for automatic retry, inside the generated gRPC code of requests based on the gRPC status
1010
of the reply. It supports unary (1:1), and server stream (1:n) requests.
1111
1212
By default the interceptors *are disabled*, preventing accidental use of retries. You can easily
1313
override the number of retries (setting them to more than 0) with a `grpc.ClientOption`, e.g.:
1414
15-
myclient.Ping(ctx, goodPing, grpc_retry.WithMax(5))
15+
myclient.Ping(ctx, goodPing, grpc_retry.WithMax(5))
1616
1717
Other default options are: retry on `ResourceExhausted` and `Unavailable` gRPC codes, use a 50ms
1818
linear backoff with 10% jitter.

interceptors/skip/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Licensed under the Apache License 2.0.
33

44
/*
5+
Package skip
6+
57
`skip` allow users to skip interceptors in certain condition.
68
79
Users can use grpc type, service name, method name and metadata to determine whether to skip the interceptor.

interceptors/timeout/doc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// Licensed under the Apache License 2.0.
33

44
/*
5+
Package timeout is a middleware that responds with a timeout error after the given duration.
6+
57
`grpc_timeout` are interceptors that timeout for gRPC client calls.
68
7-
Client Side Timeout Middleware
9+
# Client Side Timeout Middleware
810
911
Please see examples for simple examples of use.
1012
*/

interceptors/validator/doc.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// Licensed under the Apache License 2.0.
33

44
/*
5+
Package validator
6+
57
`validator` is a generic request contents validator server-side middleware for gRPC.
68
7-
Request Validator Middleware
9+
# Request Validator Middleware
810
911
Validating input is important, and hard. It also causes a lot of boilerplate code. This middleware
1012
checks for the existence of a `Validate` method on each of the messages of a gRPC request. This
@@ -16,7 +18,6 @@ While it is generic, it was intended to be used with https://github.com/mwitkow/
1618
a Go protocol buffers codegen plugin that creates the `Validate` methods (including nested messages)
1719
based on declarative options in the `.proto` files themselves. For example:
1820
19-
2021
syntax = "proto3";
2122
package validator.examples;
2223
import "github.com/mwitkow/go-proto-validators/validator.proto";

providers/kit/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the Apache License 2.0.
33

44
/*
5-
`kit` provides a small adapter required to use go-kit/log in logging gRPC middlewares.
6-
Please see examples for examples of use.
5+
Package kit provides a small adapter required to use go-kit/log in logging gRPC middlewares.
6+
Please see examples for examples of use.
77
*/
88
package kit

0 commit comments

Comments
 (0)