1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-18 22:17:44 +02:00

fix: some linting issues (#2563)

This commit is contained in:
David Brouwer
2022-09-30 16:27:07 +02:00
committed by GitHub
parent 47e6a8d725
commit 85c0b0b8eb
221 changed files with 1025 additions and 1283 deletions

View File

@ -15,9 +15,9 @@ import (
signalutil "go-micro.dev/v4/util/signal"
)
// Server is a simple micro server abstraction
// Server is a simple micro server abstraction.
type Server interface {
// Initialise options
// Initialize options
Init(...Option) error
// Retrieve the options
Options() Options
@ -37,7 +37,7 @@ type Server interface {
String() string
}
// Router handle serving messages
// Router handle serving messages.
type Router interface {
// ProcessMessage processes a message
ProcessMessage(context.Context, Message) error
@ -45,7 +45,7 @@ type Router interface {
ServeRequest(context.Context, Request, Response) error
}
// Message is an async message interface
// Message is an async message interface.
type Message interface {
// Topic of the message
Topic() string
@ -61,7 +61,7 @@ type Message interface {
Codec() codec.Reader
}
// Request is a synchronous request interface
// Request is a synchronous request interface.
type Request interface {
// Service name requested
Service() string
@ -83,7 +83,7 @@ type Request interface {
Stream() bool
}
// Response is the response writer for unencoded messages
// Response is the response writer for unencoded messages.
type Response interface {
// Encoded writer
Codec() codec.Writer
@ -126,7 +126,7 @@ type Handler interface {
// Subscriber interface represents a subscription to a given topic using
// a specific subscriber function or object with endpoints. It mirrors
// the handler in its behaviour.
// the handler in its behavior.
type Subscriber interface {
Topic() string
Subscriber() interface{}
@ -147,16 +147,15 @@ var (
DefaultRegisterInterval = time.Second * 30
DefaultRegisterTTL = time.Second * 90
// NewServer creates a new server
// NewServer creates a new server.
NewServer func(...Option) Server = newRpcServer
)
// DefaultOptions returns config options for the default service
// DefaultOptions returns config options for the default service.
func DefaultOptions() Options {
return DefaultServer.Options()
}
// Init initialises the default server with options passed in
func Init(opt ...Option) {
if DefaultServer == nil {
DefaultServer = newRpcServer(opt...)
@ -164,13 +163,13 @@ func Init(opt ...Option) {
DefaultServer.Init(opt...)
}
// NewRouter returns a new router
// NewRouter returns a new router.
func NewRouter() *router {
return newRpcRouter()
}
// NewSubscriber creates a new subscriber interface with the given topic
// and handler using the default server
// and handler using the default server.
func NewSubscriber(topic string, h interface{}, opts ...SubscriberOption) Subscriber {
return DefaultServer.NewSubscriber(topic, h, opts...)
}
@ -189,19 +188,19 @@ func NewHandler(h interface{}, opts ...HandlerOption) Handler {
}
// Handle registers a handler interface with the default server to
// handle inbound requests
// handle inbound requests.
func Handle(h Handler) error {
return DefaultServer.Handle(h)
}
// Subscribe registers a subscriber interface with the default server
// which subscribes to specified topic with the broker
// which subscribes to specified topic with the broker.
func Subscribe(s Subscriber) error {
return DefaultServer.Subscribe(s)
}
// Run starts the default server and waits for a kill
// signal before exiting. Also registers/deregisters the server
// signal before exiting. Also registers/deregisters the server.
func Run() error {
if err := Start(); err != nil {
return err
@ -214,20 +213,20 @@ func Run() error {
return Stop()
}
// Start starts the default server
// Start starts the default server.
func Start() error {
config := DefaultServer.Options()
config.Logger.Logf(log.InfoLevel, "Starting server %s id %s", config.Name, config.Id)
return DefaultServer.Start()
}
// Stop stops the default server
// Stop stops the default server.
func Stop() error {
DefaultServer.Options().Logger.Logf(log.InfoLevel, "Stopping server")
return DefaultServer.Stop()
}
// String returns name of Server implementation
// String returns name of Server implementation.
func String() string {
return DefaultServer.String()
}