fix repocard issues #2

Merged
vtolstov merged 1 commits from repocard into master 2020-11-02 13:25:29 +03:00
11 changed files with 21 additions and 16 deletions
Showing only changes of commit f7037b4077 - Show all commits

View File

@ -8,8 +8,10 @@ import (
"github.com/unistack-org/micro/v3/api/server/acme"
)
// Option func
type Option func(o *Options)
// Options for api server
type Options struct {
EnableACME bool
EnableCORS bool

View File

@ -23,6 +23,7 @@ var (
ErrGatewayTimeout = &Error{Code: 504}
)
// Error tpye
type Error struct {
Id string
Code int32

View File

@ -4,11 +4,13 @@ import "context"
type loggerKey struct{}
// FromContext returns logger from passed context
func FromContext(ctx context.Context) (Logger, bool) {
l, ok := ctx.Value(loggerKey{}).(Logger)
return l, ok
}
// NewContext stores logger into passed context
func NewContext(ctx context.Context, l Logger) context.Context {
return context.WithValue(ctx, loggerKey{}, l)
}

View File

@ -1,8 +1,8 @@
// Package log provides a log interface
// Package logger provides a log interface
package logger
var (
// Default logger
// DefaultLogger variable
DefaultLogger Logger = NewHelper(NewLogger())
)
@ -24,22 +24,27 @@ type Logger interface {
String() string
}
// Init initialize logger
func Init(opts ...Option) error {
return DefaultLogger.Init(opts...)
}
// Fields create logger with specific fields
func Fields(fields map[string]interface{}) Logger {
return DefaultLogger.Fields(fields)
}
// Log writes log with specific level
func Log(level Level, v ...interface{}) {
DefaultLogger.Log(level, v...)
}
// Logf writes formatted log with specific level
func Logf(level Level, format string, v ...interface{}) {
DefaultLogger.Logf(level, format, v...)
}
// String return logger name
func String() string {
return DefaultLogger.String()
}

View File

@ -7,7 +7,7 @@ import "time"
type Tags map[string]string
var (
Defaultreporter Reporter
DefaultReporter Reporter
)
// Reporter is an interface for collecting and instrumenting metrics

View File

@ -71,10 +71,8 @@ type Event interface {
Publish(ctx context.Context, msg interface{}, opts ...client.PublishOption) error
}
// Type alias to satisfy the deprecation
type Publisher = Event
var (
// HeaderPrefix for all headers passed
HeaderPrefix = "Micro-"
)
@ -104,11 +102,6 @@ func NewEvent(topic string, c client.Client) Event {
return &event{c, topic}
}
// Deprecated: NewPublisher returns a new Publisher
func NewPublisher(topic string, c client.Client) Event {
return NewEvent(topic, c)
}
// RegisterHandler is syntactic sugar for registering a handler
func RegisterHandler(s server.Server, h interface{}, opts ...server.HandlerOption) error {
return s.Handle(s.NewHandler(h, opts...))

View File

@ -3,9 +3,9 @@ package network
import (
"github.com/google/uuid"
"github.com/unistack-org/micro/v3/logger"
"github.com/unistack-org/micro/v3/network/tunnel"
"github.com/unistack-org/micro/v3/proxy"
"github.com/unistack-org/micro/v3/router"
"github.com/unistack-org/micro/v3/network/tunnel"
)
type Option func(*Options)

View File

@ -9,7 +9,7 @@ type Resolver interface {
Resolve(name string) ([]*Record, error)
}
// A resolved record
// Record that resolved
type Record struct {
Address string `json:"address"`
Priority int64 `json:"priority"`

View File

@ -15,6 +15,7 @@ import (
"github.com/unistack-org/micro/v3/tracer"
)
// Options server struct
type Options struct {
Codecs map[string]codec.NewCodec
Broker broker.Broker
@ -56,6 +57,7 @@ type Options struct {
Context context.Context
}
// NewOptions returns new options struct with default or passed values
func NewOptions(opts ...Option) Options {
options := Options{
Auth: auth.DefaultAuth,
@ -104,7 +106,7 @@ func Logger(l logger.Logger) Option {
}
}
// Unique server id
// Id unique server id
func Id(id string) Option {
return func(o *Options) {
o.Id = id

View File

@ -10,12 +10,12 @@ import (
bmemory "github.com/unistack-org/micro/v3/broker/memory"
"github.com/unistack-org/micro/v3/client"
"github.com/unistack-org/micro/v3/client/grpc"
tmemory "github.com/unistack-org/micro/v3/network/transport/memory"
rmemory "github.com/unistack-org/micro/v3/registry/memory"
"github.com/unistack-org/micro/v3/router"
rtreg "github.com/unistack-org/micro/v3/router/registry"
"github.com/unistack-org/micro/v3/server"
grpcsrv "github.com/unistack-org/micro/v3/server/grpc"
tmemory "github.com/unistack-org/micro/v3/network/transport/memory"
cw "github.com/unistack-org/micro/v3/util/client"
)

View File

@ -18,7 +18,7 @@ func (r *apiRouter) String() string {
return "api"
}
// Router is a hack for API routing
// New router is a hack for API routing
func New(srvs []*registry.Service) router.Router {
var routes []router.Route