mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-10 15:07:24 +00:00
This is a very small change, but removes a method from the `service.Service` interface (a win!) and forces callers to explicitly pass loggers in to objects during construction rather than (later) injecting them. There's not a real need for this kind of lazy construction of loggers, and I think a decent potential for confusion for mutable loggers. The main concern I have is that this changes the constructor API for ABCI clients. I think this is fine, and I suspect that as we plumb contexts through, and make changes to the RPC services there'll be a number of similar sorts of changes to various (quasi) public interfaces, which I think we should welcome.
32 lines
710 B
Go
32 lines
710 B
Go
/*
|
|
Package server is used to start a new ABCI server.
|
|
|
|
It contains two server implementation:
|
|
* gRPC server
|
|
* socket server
|
|
|
|
*/
|
|
package server
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/tendermint/tendermint/abci/types"
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
"github.com/tendermint/tendermint/libs/service"
|
|
)
|
|
|
|
func NewServer(logger log.Logger, protoAddr, transport string, app types.Application) (service.Service, error) {
|
|
var s service.Service
|
|
var err error
|
|
switch transport {
|
|
case "socket":
|
|
s = NewSocketServer(logger, protoAddr, app)
|
|
case "grpc":
|
|
s = NewGRPCServer(logger, protoAddr, types.NewGRPCApplication(app))
|
|
default:
|
|
err = fmt.Errorf("unknown server type %s", transport)
|
|
}
|
|
return s, err
|
|
}
|