Skip to content

Commit

Permalink
fix misspelling in comment + lint (137)
Browse files Browse the repository at this point in the history
* Update server_interceptors.go

fix misspelling

* Update fieldextractor.go

fix misspelling

* Update options.go

fix misspelling

* Update options.go

fix comment

* Update server_interceptors.go

lint comment

* Update payload_interceptors.go

lint comment

* Update client_interceptors.go

lint comment

* Update payload_interceptors.go

lint comment

* update docs
  • Loading branch information
chemidy authored and domgreen committed Apr 17, 2018
1 parent b9ed6ae commit 781f815
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 54 deletions.
8 changes: 4 additions & 4 deletions logging/logrus/DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ DefaultDurationToField is the default implementation of converting request durat

``` go
var (
// JsonPBMarshaller is the marshaller used for serializing protobuf messages.
// JsonPbMarshaller is the marshaller used for serializing protobuf messages.
JsonPbMarshaller = &jsonpb.Marshaler{}
)
```
Expand Down Expand Up @@ -260,13 +260,13 @@ _ = func(ctx context.Context, ping *pb_testproto.PingRequest) (*pb_testproto.Pin
``` go
func PayloadStreamClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.StreamClientInterceptor
```
PayloadStreamServerInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
PayloadStreamClientInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.

## <a name="PayloadStreamServerInterceptor">func</a> [PayloadStreamServerInterceptor](./payload_interceptors.go#L45)
``` go
func PayloadStreamServerInterceptor(entry *logrus.Entry, decider grpc_logging.ServerPayloadLoggingDecider) grpc.StreamServerInterceptor
```
PayloadUnaryServerInterceptor returns a new server server interceptors that logs the payloads of requests.
PayloadStreamServerInterceptor returns a new server server interceptors that logs the payloads of requests.

This *only* works when placed *after* the `grpc_logrus.StreamServerInterceptor`. However, the logging can be done to a
separate instance of the logger.
Expand Down Expand Up @@ -315,7 +315,7 @@ UnaryClientInterceptor returns a new unary client interceptor that optionally lo
``` go
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor
```
PayloadUnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
UnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.

## <a name="CodeToLevel">type</a> [CodeToLevel](./options.go#L53)
``` go
Expand Down
6 changes: 3 additions & 3 deletions logging/logrus/payload_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

var (
// JsonPBMarshaller is the marshaller used for serializing protobuf messages.
// JsonPbMarshaller is the marshaller used for serializing protobuf messages.
JsonPbMarshaller = &jsonpb.Marshaler{}
)

Expand All @@ -38,7 +38,7 @@ func PayloadUnaryServerInterceptor(entry *logrus.Entry, decider grpc_logging.Ser
}
}

// PayloadUnaryServerInterceptor returns a new server server interceptors that logs the payloads of requests.
// PayloadStreamServerInterceptor returns a new server server interceptors that logs the payloads of requests.
//
// This *only* works when placed *after* the `grpc_logrus.StreamServerInterceptor`. However, the logging can be done to a
// separate instance of the logger.
Expand Down Expand Up @@ -70,7 +70,7 @@ func PayloadUnaryClientInterceptor(entry *logrus.Entry, decider grpc_logging.Cli
}
}

// PayloadStreamServerInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
// PayloadStreamClientInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
func PayloadStreamClientInterceptor(entry *logrus.Entry, decider grpc_logging.ClientPayloadLoggingDecider) grpc.StreamClientInterceptor {
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
if !decider(ctx, method) {
Expand Down
2 changes: 1 addition & 1 deletion logging/logrus/server_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var (
KindField = "span.kind"
)

// PayloadUnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
// UnaryServerInterceptor returns a new unary server interceptors that adds logrus.Entry to the context.
func UnaryServerInterceptor(entry *logrus.Entry, opts ...Option) grpc.UnaryServerInterceptor {
o := evaluateServerOpt(opts)
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) {
Expand Down
10 changes: 5 additions & 5 deletions logging/zap/DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ var (
// SystemField is used in every log statement made through grpc_zap. Can be overwritten before any initialization code.
SystemField = zap.String("system", "grpc")

// ServerField is used in every server-side log statment made through grpc_zap.Can be overwritten before initialization.
// ServerField is used in every server-side log statement made through grpc_zap.Can be overwritten before initialization.
ServerField = zap.String("span.kind", "server")
)
```
Expand All @@ -232,7 +232,7 @@ DefaultDurationToField is the default implementation of converting request durat

``` go
var (
// JsonPBMarshaller is the marshaller used for serializing protobuf messages.
// JsonPbMarshaller is the marshaller used for serializing protobuf messages.
JsonPbMarshaller = &jsonpb.Marshaler{}
)
```
Expand Down Expand Up @@ -300,13 +300,13 @@ _ = func(ctx context.Context, ping *pb_testproto.PingRequest) (*pb_testproto.Pin
``` go
func PayloadStreamClientInterceptor(logger *zap.Logger, decider grpc_logging.ClientPayloadLoggingDecider) grpc.StreamClientInterceptor
```
PayloadStreamServerInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
PayloadStreamClientInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.

## <a name="PayloadStreamServerInterceptor">func</a> [PayloadStreamServerInterceptor](./payload_interceptors.go#L46)
``` go
func PayloadStreamServerInterceptor(logger *zap.Logger, decider grpc_logging.ServerPayloadLoggingDecider) grpc.StreamServerInterceptor
```
PayloadUnaryServerInterceptor returns a new server server interceptors that logs the payloads of requests.
PayloadStreamServerInterceptor returns a new server server interceptors that logs the payloads of requests.

This *only* works when placed *after* the `grpc_zap.StreamServerInterceptor`. However, the logging can be done to a
separate instance of the logger.
Expand Down Expand Up @@ -337,7 +337,7 @@ This should be called *before* any other initialization, preferably from init()
``` go
func StreamClientInterceptor(logger *zap.Logger, opts ...Option) grpc.StreamClientInterceptor
```
StreamServerInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.
StreamClientInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.

## <a name="StreamServerInterceptor">func</a> [StreamServerInterceptor](./server_interceptors.go#L51)
``` go
Expand Down
2 changes: 1 addition & 1 deletion logging/zap/client_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func UnaryClientInterceptor(logger *zap.Logger, opts ...Option) grpc.UnaryClient
}
}

// StreamServerInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.
// StreamClientInterceptor returns a new streaming client interceptor that optionally logs the execution of external gRPC calls.
func StreamClientInterceptor(logger *zap.Logger, opts ...Option) grpc.StreamClientInterceptor {
o := evaluateClientOpt(opts)
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
Expand Down
6 changes: 3 additions & 3 deletions logging/zap/payload_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import (
)

var (
// JsonPBMarshaller is the marshaller used for serializing protobuf messages.
// JsonPbMarshaller is the marshaller used for serializing protobuf messages.
JsonPbMarshaller = &jsonpb.Marshaler{}
)

Expand All @@ -39,7 +39,7 @@ func PayloadUnaryServerInterceptor(logger *zap.Logger, decider grpc_logging.Serv
}
}

// PayloadUnaryServerInterceptor returns a new server server interceptors that logs the payloads of requests.
// PayloadStreamServerInterceptor returns a new server server interceptors that logs the payloads of requests.
//
// This *only* works when placed *after* the `grpc_zap.StreamServerInterceptor`. However, the logging can be done to a
// separate instance of the logger.
Expand Down Expand Up @@ -70,7 +70,7 @@ func PayloadUnaryClientInterceptor(logger *zap.Logger, decider grpc_logging.Clie
}
}

// PayloadStreamServerInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
// PayloadStreamClientInterceptor returns a new streaming client interceptor that logs the paylods of requests and responses.
func PayloadStreamClientInterceptor(logger *zap.Logger, decider grpc_logging.ClientPayloadLoggingDecider) grpc.StreamClientInterceptor {
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
if !decider(ctx, method) {
Expand Down
2 changes: 1 addition & 1 deletion logging/zap/server_interceptors.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var (
// SystemField is used in every log statement made through grpc_zap. Can be overwritten before any initialization code.
SystemField = zap.String("system", "grpc")

// ServerField is used in every server-side log statment made through grpc_zap.Can be overwritten before initialization.
// ServerField is used in every server-side log statement made through grpc_zap.Can be overwritten before initialization.
ServerField = zap.String("span.kind", "server")
)

Expand Down
4 changes: 2 additions & 2 deletions retry/DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ changed through options (e.g. WithMax) on creation of the interceptor or on call
``` go
type BackoffFunc func(attempt uint) time.Duration
```
BackoffFunc denotes a family of functions that controll the backoff duration between call retries.
BackoffFunc denotes a family of functions that control the backoff duration between call retries.

They are called with an identifier of the attempt, and should return a time the system client should
hold off for. If the time returned is longer than the `context.Context.Deadline` of the request
Expand Down Expand Up @@ -186,7 +186,7 @@ type CallOption struct {
// contains filtered or unexported fields
}
```
callOption is a grpc.CallOption that is local to grpc_retry.
CallOption is a grpc.CallOption that is local to grpc_retry.

### <a name="Disable">func</a> [Disable](./options.go#L40)
``` go
Expand Down
4 changes: 2 additions & 2 deletions retry/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var (
}
)

// BackoffFunc denotes a family of functions that controll the backoff duration between call retries.
// BackoffFunc denotes a family of functions that control the backoff duration between call retries.
//
// They are called with an identifier of the attempt, and should return a time the system client should
// hold off for. If the time returned is longer than the `context.Context.Deadline` of the request
Expand Down Expand Up @@ -90,7 +90,7 @@ type options struct {
backoffFunc BackoffFunc
}

// callOption is a grpc.CallOption that is local to grpc_retry.
// CallOption is a grpc.CallOption that is local to grpc_retry.
type CallOption struct {
grpc.EmptyCallOption // make sure we implement private after() and before() fields so we don't panic.
applyFunc func(opt *options)
Expand Down
56 changes: 25 additions & 31 deletions tags/DOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ _ = grpc.NewServer(
- [google.golang.org/grpc/peer](https://godoc.org/google.golang.org/grpc/peer)

## <a name="pkg-index">Index</a>
* [Variables](#pkg-variables)
* [func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{}](#CodeGenRequestFieldExtractor)
* [func StreamServerInterceptor(opts ...Option) grpc.StreamServerInterceptor](#StreamServerInterceptor)
* [func UnaryServerInterceptor(opts ...Option) grpc.UnaryServerInterceptor](#UnaryServerInterceptor)
Expand All @@ -77,10 +78,7 @@ _ = grpc.NewServer(
* [type RequestFieldExtractorFunc](#RequestFieldExtractorFunc)
* [func TagBasedRequestFieldExtractor(tagName string) RequestFieldExtractorFunc](#TagBasedRequestFieldExtractor)
* [type Tags](#Tags)
* [func Extract(ctx context.Context) \*Tags](#Extract)
* [func (t \*Tags) Has(key string) bool](#Tags.Has)
* [func (t \*Tags) Set(key string, value interface{}) \*Tags](#Tags.Set)
* [func (t \*Tags) Values() map[string]interface{}](#Tags.Values)
* [func Extract(ctx context.Context) Tags](#Extract)

#### <a name="pkg-examples">Examples</a>
* [Package (InitialisationWithOptions)](#example__initialisationWithOptions)
Expand All @@ -89,6 +87,15 @@ _ = grpc.NewServer(
#### <a name="pkg-files">Package files</a>
[context.go](./context.go) [doc.go](./doc.go) [fieldextractor.go](./fieldextractor.go) [interceptors.go](./interceptors.go) [options.go](./options.go)

## <a name="pkg-variables">Variables</a>
``` go
var (

// NoopTags is a trivial, minimum overhead implementation of Tags for which all operations are no-ops.
NoopTags = &noopTags{}
)
```

## <a name="CodeGenRequestFieldExtractor">func</a> [CodeGenRequestFieldExtractor](./fieldextractor.go#L23)
``` go
func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string]interface{}
Expand Down Expand Up @@ -141,48 +148,35 @@ Keys and values will be added to the context tags of the request. If there are n
func TagBasedRequestFieldExtractor(tagName string) RequestFieldExtractorFunc
```
TagBasedRequestFieldExtractor is a function that relies on Go struct tags to export log fields from requests.
These are usualy coming from a protoc-plugin, such as Gogo protobuf.
These are usually coming from a protoc-plugin, such as Gogo protobuf.

message Metadata {
repeated string tags = 1 [ (gogoproto.moretags) = "log_field:\"meta_tags\"" ];
}

The tagName is configurable using the tagName variable. Here it would be "log_field".

## <a name="Tags">type</a> [Tags](./context.go#L17-L19)
## <a name="Tags">type</a> [Tags](./context.go#L19-L27)
``` go
type Tags struct {
// contains filtered or unexported fields
type Tags interface {
// Set sets the given key in the metadata tags.
Set(key string, value interface{}) Tags
// Has checks if the given key exists.
Has(key string) bool
// Values returns a map of key to values.
// Do not modify the underlying map, please use Set instead.
Values() map[string]interface{}
}
```
Tags is the struct used for storing request tags between Context calls.
This object is *not* thread safe, and should be handled only in the context of the request.
Tags is the interface used for storing request tags between Context calls.
The default implementation is *not* thread safe, and should be handled only in the context of the request.

### <a name="Extract">func</a> [Extract](./context.go#L41)
### <a name="Extract">func</a> [Extract](./context.go#L63)
``` go
func Extract(ctx context.Context) *Tags
func Extract(ctx context.Context) Tags
```
Extracts returns a pre-existing Tags object in the Context.
If the context wasn't set in a tag interceptor, a no-op Tag storage is returned that will *not* be propagated in context.
### <a name="Tags.Has">func</a> (\*Tags) [Has](./context.go#L28)
``` go
func (t *Tags) Has(key string) bool
```
Has checks if the given key exists.
### <a name="Tags.Set">func</a> (\*Tags) [Set](./context.go#L22)
``` go
func (t *Tags) Set(key string, value interface{}) *Tags
```
Set sets the given key in the metadata tags.
### <a name="Tags.Values">func</a> (\*Tags) [Values](./context.go#L35)
``` go
func (t *Tags) Values() map[string]interface{}
```
Values returns a map of key to values.
Do not modify the underlying map, please use Set instead.
- - -
Generated by [godoc2ghmd](https://github.com/GandalfUK/godoc2ghmd)
2 changes: 1 addition & 1 deletion tags/fieldextractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func CodeGenRequestFieldExtractor(fullMethod string, req interface{}) map[string
}

// TagBasedRequestFieldExtractor is a function that relies on Go struct tags to export log fields from requests.
// These are usualy coming from a protoc-plugin, such as Gogo protobuf.
// These are usually coming from a protoc-plugin, such as Gogo protobuf.
//
// message Metadata {
// repeated string tags = 1 [ (gogoproto.moretags) = "log_field:\"meta_tags\"" ];
Expand Down

0 comments on commit 781f815

Please sign in to comment.