fix: typo and grammatical errors (#2368)

* fix: grammar

* fix: grammar

* fix overrode

* translate to English

* translate to English
pull/2383/head
jesse.tang 2 years ago committed by GitHub
parent 7f2666be9f
commit 9737a3c5e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      .github/ISSUE_TEMPLATE/feature-request.md
  2. 8
      CONTRIBUTING.md
  3. 4
      cmd/protoc-gen-go-http/http.go
  4. 2
      contrib/config/etcd/README.md
  5. 2
      contrib/log/aliyun/aliyun.go
  6. 2
      contrib/metrics/datadog/options.go
  7. 2
      contrib/registry/consul/client.go
  8. 2
      contrib/registry/etcd/registry.go
  9. 6
      contrib/registry/eureka/eureka.go
  10. 2
      contrib/registry/kubernetes/registry.go
  11. 2
      encoding/encoding_test.go
  12. 10
      errors/types.go
  13. 2
      log/global_test.go
  14. 2
      log/helper_writer.go
  15. 4
      middleware/circuitbreaker/circuitbreaker.go
  16. 2
      middleware/logging/logging.go
  17. 2
      middleware/metadata/metadata_test.go
  18. 10
      middleware/tracing/span.go
  19. 2
      registry/registry.go
  20. 2
      selector/random/random.go
  21. 2
      selector/selector_test.go
  22. 2
      transport/grpc/balancer.go
  23. 2
      transport/http/client.go
  24. 2
      transport/http/filter.go
  25. 2
      transport/http/status/status.go

@ -43,7 +43,7 @@ example:
### Requirements description of the feature ### Requirements description of the feature
<!-- <!--
example: example:
The event interface should be added to Kratos. The interface should contain subscribers and publishers, and the message body should contain key value heade The event interface should be added to Kratos. The interface should contain subscribers and publishers, and the message body should contain key value head
--> -->
### References ### References
<!-- <!--

@ -1,7 +1,7 @@
The kratos community wants to be helped by a wide range of developers, so you'd like to take a few minutes to read this guide before you mention the problem or pull request. The kratos community wants to be helped by a wide range of developers, so you'd like to take a few minutes to read this guide before you mention the problem or pull request.
## Reportings Bug or Fixing Bugs ## Reporting Bug or Fixing Bugs
We use github issues to manage issues. If you want to submit , first make sure you've searched for existing issues, pull requests and read our [FAQ](https://go-kratos.dev/docs/intro/faq). We use GitHub issues to manage issues. If you want to submit , first make sure you've searched for existing issues, pull requests and read our [FAQ](https://go-kratos.dev/docs/intro/faq).
When submitting a bug report, use the issue template we provide to clearly describe the problems encountered and how to reproduce, and if convenient it is best to provide a minimal reproduce repository. When submitting a bug report, use the issue template we provide to clearly describe the problems encountered and how to reproduce, and if convenient it is best to provide a minimal reproduce repository.
@ -16,9 +16,9 @@ After the function is implemented, a merge request will be initiated to associat
After the merge is completed, Close all issues. After the merge is completed, Close all issues.
## How to submit code ## How to submit code
If you've never submitted code on github, follow these steps: If you've never submitted code on GitHub, follow these steps:
- First, please fork items to your github account - First, please fork items to your GitHub account
- Then create a new feature branch based on the main branch and name it features such as feature-log - Then create a new feature branch based on the main branch and name it features such as feature-log
- Write code - Write code
- Submit code to the far end branch - Submit code to the far end branch

@ -255,8 +255,8 @@ func camelCaseVars(s string) string {
// drop the underscore and convert the letter to upper case. // drop the underscore and convert the letter to upper case.
// There is a remote possibility of this rewrite causing a name collision, // There is a remote possibility of this rewrite causing a name collision,
// but it's so remote we're prepared to pretend it's nonexistent - since the // but it's so remote we're prepared to pretend it's nonexistent - since the
// C++ generator lowercases names, it's extremely unlikely to have two fields // C++ generator lowercase names, it's extremely unlikely to have two fields
// with different capitalizations. // with different capitalization.
// In short, _my_field_name_2 becomes XMyFieldName_2. // In short, _my_field_name_2 becomes XMyFieldName_2.
func camelCase(s string) string { func camelCase(s string) string {
if s == "" { if s == "" {

@ -10,7 +10,7 @@ import (
"google.golang.org/grpc" "google.golang.org/grpc"
) )
// create a etcd client // create an etcd client
client, err := clientv3.New(clientv3.Config{ client, err := clientv3.New(clientv3.Config{
Endpoints: []string{"127.0.0.1:2379"}, Endpoints: []string{"127.0.0.1:2379"},
DialTimeout: time.Second, DialTimeout: time.Second,

@ -11,7 +11,7 @@ import (
"google.golang.org/protobuf/proto" "google.golang.org/protobuf/proto"
) )
// Log see more detail https://github.com/aliyun/aliyun-log-go-sdk // Logger see more detail https://github.com/aliyun/aliyun-log-go-sdk
type Logger interface { type Logger interface {
log.Logger log.Logger
GetProducer() *producer.Producer GetProducer() *producer.Producer

@ -2,7 +2,7 @@ package datadog
import "github.com/DataDog/datadog-go/statsd" import "github.com/DataDog/datadog-go/statsd"
// Option is doatadog option. // Option is datadog option.
type Option func(*options) type Option func(*options)
type options struct { type options struct {

@ -173,7 +173,7 @@ func (c *Client) Register(_ context.Context, svc *registry.ServiceInstance, enab
return nil return nil
} }
// Deregister deregister service by service ID // Deregister service by service ID
func (c *Client) Deregister(_ context.Context, serviceID string) error { func (c *Client) Deregister(_ context.Context, serviceID string) error {
c.cancel() c.cancel()
return c.cli.Agent().ServiceDeregister(serviceID) return c.cli.Agent().ServiceDeregister(serviceID)

@ -153,7 +153,7 @@ func (r *Registry) heartBeat(ctx context.Context, leaseID clientv3.LeaseID, key
for { for {
if curLeaseID == 0 { if curLeaseID == 0 {
// try to registerWithKV // try to registerWithKV
retreat := []int{} var retreat []int
for retryCnt := 0; retryCnt < r.opts.maxRetry; retryCnt++ { for retryCnt := 0; retryCnt < r.opts.maxRetry; retryCnt++ {
if ctx.Err() != nil { if ctx.Err() != nil {
return return

@ -28,7 +28,7 @@ func NewAPI(ctx context.Context, client *Client, refreshInterval time.Duration)
refreshInterval: refreshInterval, refreshInterval: refreshInterval,
} }
// 首次广播一次 // it is required to broadcast for the first time
e.broadcast() e.broadcast()
go e.refresh(ctx) go e.refresh(ctx)
@ -93,7 +93,7 @@ func (e *API) Register(ctx context.Context, serviceName string, endpoints ...End
return nil return nil
} }
// Deregister 中的ctx 和 register ctx 是同一个 // Deregister ctx is the same as register ctx
func (e *API) Deregister(ctx context.Context, endpoints []Endpoint) error { func (e *API) Deregister(ctx context.Context, endpoints []Endpoint) error {
for _, ep := range endpoints { for _, ep := range endpoints {
if err := e.cli.Deregister(ctx, ep.AppID, ep.InstanceID); err != nil { if err := e.cli.Deregister(ctx, ep.AppID, ep.InstanceID); err != nil {
@ -121,7 +121,7 @@ func (e *API) GetService(ctx context.Context, serverName string) []Instance {
return ins return ins
} }
// 如果不再allinstances 中可以尝试再单独获取一次 // if not in allInstances of API, you can try to obtain it separately again
return e.cli.FetchAppUpInstances(ctx, appID) return e.cli.FetchAppUpInstances(ctx, appID)
} }

@ -299,7 +299,7 @@ func (iter *Iterator) Next() ([]*registry.ServiceInstance, error) {
} }
} }
// Close is used to close the iterator // Stop is used to close the iterator
func (iter *Iterator) Stop() error { func (iter *Iterator) Stop() error {
select { select {
case <-iter.stopCh: case <-iter.stopCh:

@ -63,7 +63,7 @@ func TestRegisterCodec(t *testing.T) {
} }
} }
// PanicTestFunc defines a func that should be passed to the assert.Panics and assert.NotPanics // PanicTestFunc defines a func that should be passed to assert.Panics and assert.NotPanics
// methods, and represents a simple func that takes no arguments, and returns nothing. // methods, and represents a simple func that takes no arguments, and returns nothing.
type PanicTestFunc func() type PanicTestFunc func()

@ -17,7 +17,7 @@ func Unauthorized(reason, message string) *Error {
return New(401, reason, message) return New(401, reason, message)
} }
// IsUnauthorized determines if err is an error which indicates a Unauthorized error. // IsUnauthorized determines if err is an error which indicates an Unauthorized error.
// It supports wrapped errors. // It supports wrapped errors.
func IsUnauthorized(err error) bool { func IsUnauthorized(err error) bool {
return Code(err) == 401 return Code(err) == 401
@ -67,18 +67,18 @@ func IsInternalServer(err error) bool {
return Code(err) == 500 return Code(err) == 500
} }
// ServiceUnavailable new ServiceUnavailable error that is mapped to a HTTP 503 response. // ServiceUnavailable new ServiceUnavailable error that is mapped to an HTTP 503 response.
func ServiceUnavailable(reason, message string) *Error { func ServiceUnavailable(reason, message string) *Error {
return New(503, reason, message) return New(503, reason, message)
} }
// IsServiceUnavailable determines if err is an error which indicates a Unavailable error. // IsServiceUnavailable determines if err is an error which indicates an Unavailable error.
// It supports wrapped errors. // It supports wrapped errors.
func IsServiceUnavailable(err error) bool { func IsServiceUnavailable(err error) bool {
return Code(err) == 503 return Code(err) == 503
} }
// GatewayTimeout new GatewayTimeout error that is mapped to a HTTP 504 response. // GatewayTimeout new GatewayTimeout error that is mapped to an HTTP 504 response.
func GatewayTimeout(reason, message string) *Error { func GatewayTimeout(reason, message string) *Error {
return New(504, reason, message) return New(504, reason, message)
} }
@ -89,7 +89,7 @@ func IsGatewayTimeout(err error) bool {
return Code(err) == 504 return Code(err) == 504
} }
// ClientClosed new ClientClosed error that is mapped to a HTTP 499 response. // ClientClosed new ClientClosed error that is mapped to an HTTP 499 response.
func ClientClosed(reason, message string) *Error { func ClientClosed(reason, message string) *Error {
return New(499, reason, message) return New(499, reason, message)
} }

@ -48,7 +48,7 @@ func TestGlobalLog(t *testing.T) {
}, },
} }
expected := []string{} var expected []string
for _, tc := range testCases { for _, tc := range testCases {
msg := fmt.Sprintf(tc.content[0].(string), tc.content[1:]...) msg := fmt.Sprintf(tc.content[0].(string), tc.content[1:]...)
switch tc.level { switch tc.level {

@ -9,7 +9,7 @@ type writerWrapper struct {
type WriterOptionFn func(w *writerWrapper) type WriterOptionFn func(w *writerWrapper)
// WithWriteLevel set writerWrapper level. // WithWriterLevel set writerWrapper level.
func WithWriterLevel(level Level) WriterOptionFn { func WithWriterLevel(level Level) WriterOptionFn {
return func(w *writerWrapper) { return func(w *writerWrapper) {
w.level = level w.level = level

@ -46,8 +46,8 @@ func Client(opts ...Option) middleware.Middleware {
breaker := opt.group.Get(info.Operation()).(circuitbreaker.CircuitBreaker) breaker := opt.group.Get(info.Operation()).(circuitbreaker.CircuitBreaker)
if err := breaker.Allow(); err != nil { if err := breaker.Allow(); err != nil {
// rejected // rejected
// NOTE: when client reject requets locally, // NOTE: when client reject requests locally,
// continue add counter let the drop ratio higher. // continue to add counter let the drop ratio higher.
breaker.MarkFailed() breaker.MarkFailed()
return nil, ErrNotAllowed return nil, ErrNotAllowed
} }

@ -47,7 +47,7 @@ func Server(logger log.Logger) middleware.Middleware {
} }
} }
// Client is an client logging middleware. // Client is a client logging middleware.
func Client(logger log.Logger) middleware.Middleware { func Client(logger log.Logger) middleware.Middleware {
return func(handler middleware.Handler) middleware.Handler { return func(handler middleware.Handler) middleware.Handler {
return func(ctx context.Context, req interface{}) (reply interface{}, err error) { return func(ctx context.Context, req interface{}) (reply interface{}, err error) {

@ -134,6 +134,6 @@ func Test_WithPropagatedPrefix(t *testing.T) {
WithPropagatedPrefix("something", "another")(o) WithPropagatedPrefix("something", "another")(o)
if len(o.prefix) != 2 { if len(o.prefix) != 2 {
t.Error("The prefix must be overrided.") t.Error("The prefix must be overridden.")
} }
} }

@ -18,10 +18,12 @@ import (
) )
func setClientSpan(ctx context.Context, span trace.Span, m interface{}) { func setClientSpan(ctx context.Context, span trace.Span, m interface{}) {
attrs := []attribute.KeyValue{} var (
var remote string attrs []attribute.KeyValue
var operation string remote string
var rpcKind string operation string
rpcKind string
)
tr, ok := transport.FromClientContext(ctx) tr, ok := transport.FromClientContext(ctx)
if ok { if ok {
operation = tr.Operation() operation = tr.Operation()

@ -39,7 +39,7 @@ type ServiceInstance struct {
Version string `json:"version"` Version string `json:"version"`
// Metadata is the kv pair metadata associated with the service instance. // Metadata is the kv pair metadata associated with the service instance.
Metadata map[string]string `json:"metadata"` Metadata map[string]string `json:"metadata"`
// Endpoints is endpoint addresses of the service instance. // Endpoints are endpoint addresses of the service instance.
// schema: // schema:
// http://127.0.0.1:8000?isSecure=false // http://127.0.0.1:8000?isSecure=false
// grpc://127.0.0.1:9000?isSecure=false // grpc://127.0.0.1:9000?isSecure=false

@ -24,7 +24,7 @@ type options struct{}
// Balancer is a random balancer. // Balancer is a random balancer.
type Balancer struct{} type Balancer struct{}
// New an random selector. // New a random selector.
func New(opts ...Option) selector.Selector { func New(opts ...Option) selector.Selector {
return NewBuilder(opts...).Build() return NewBuilder(opts...).Build()
} }

@ -277,7 +277,7 @@ func TestNoPick(t *testing.T) {
} }
} }
func TestGolobal(t *testing.T) { func TestGlobalSelector(t *testing.T) {
builder := DefaultBuilder{ builder := DefaultBuilder{
Node: &mockWeightedNodeBuilder{}, Node: &mockWeightedNodeBuilder{},
Balancer: &mockBalancerBuilder{}, Balancer: &mockBalancerBuilder{},

@ -87,7 +87,7 @@ func (p *balancerPicker) Pick(info balancer.PickInfo) (balancer.PickResult, erro
}, nil }, nil
} }
// Trailer is a grpc trailder MD. // Trailer is a grpc trailer MD.
type Trailer metadata.MD type Trailer metadata.MD
// Get get a grpc trailer value. // Get get a grpc trailer value.

@ -196,7 +196,7 @@ func NewClient(ctx context.Context, opts ...ClientOption) (*Client, error) {
}, nil }, nil
} }
// Invoke makes an rpc call procedure for remote service. // Invoke makes a rpc call procedure for remote service.
func (client *Client) Invoke(ctx context.Context, method, path string, args interface{}, reply interface{}, opts ...CallOption) error { func (client *Client) Invoke(ctx context.Context, method, path string, args interface{}, reply interface{}, opts ...CallOption) error {
var ( var (
contentType string contentType string

@ -2,7 +2,7 @@ package http
import "net/http" import "net/http"
// FilterFunc is a function which receives an http.Handler and returns another http.Handler. // FilterFunc is a function which receives a http.Handler and returns another http.Handler.
type FilterFunc func(http.Handler) http.Handler type FilterFunc func(http.Handler) http.Handler
// FilterChain returns a FilterFunc that specifies the chained handler for HTTP Router. // FilterChain returns a FilterFunc that specifies the chained handler for HTTP Router.

@ -27,7 +27,7 @@ type statusConverter struct{}
// DefaultConverter default converter. // DefaultConverter default converter.
var DefaultConverter Converter = statusConverter{} var DefaultConverter Converter = statusConverter{}
// ToGRPCCode converts a HTTP error code into the corresponding gRPC response status. // ToGRPCCode converts an HTTP error code into the corresponding gRPC response status.
// See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto // See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func (c statusConverter) ToGRPCCode(code int) codes.Code { func (c statusConverter) ToGRPCCode(code int) codes.Code {
switch code { switch code {

Loading…
Cancel
Save