diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2020-04-09 14:36:30 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2020-04-09 14:36:30 +0200 |
commit | 2c419b100f5f90c1215617d0fac81fa6749c4d6b (patch) | |
tree | fa04b14429396b17cec8c828c203995e4ef574e8 /proxy | |
parent | db87efa2ec1e91e81517236b164b279e57b8daa8 (diff) |
proxy: Unexport methods that do not satisfy rpc to remove warningv0.3.3
Change-Id: Icd4173edc55d83b1766f204184eb818b859e648e
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'proxy')
-rw-r--r-- | proxy/log.go | 11 | ||||
-rw-r--r-- | proxy/proxy.go | 8 | ||||
-rw-r--r-- | proxy/server.go | 14 |
3 files changed, 19 insertions, 14 deletions
diff --git a/proxy/log.go b/proxy/log.go index d53e532..2ab4704 100644 --- a/proxy/log.go +++ b/proxy/log.go @@ -1,6 +1,7 @@ package proxy import ( + "io" "os" "github.com/sirupsen/logrus" @@ -13,19 +14,23 @@ var ( ) func init() { - log.Out = os.Stdout if debug { log.Level = logrus.DebugLevel log.Debugf("govpp/proxy: debug mode enabled") } } -// SetLogger sets global logger to l. +// SetLogger sets logger. func SetLogger(l *logrus.Logger) { log = l } -// SetLogLevel sets global logger level to lvl. +// SetLogLevel sets log level for logger. func SetLogLevel(lvl logrus.Level) { log.Level = lvl } + +// SetOutput sets log output for logger. +func SetLogOutput(out io.Writer) { + log.Out = out +} diff --git a/proxy/proxy.go b/proxy/proxy.go index 6656ee5..49c650d 100644 --- a/proxy/proxy.go +++ b/proxy/proxy.go @@ -51,19 +51,19 @@ func NewServer() (*Server, error) { } func (p *Server) ConnectStats(stats adapter.StatsAPI) error { - return p.statsRPC.Connect(stats) + return p.statsRPC.connect(stats) } func (p *Server) DisconnectStats() { - p.statsRPC.Disconnect() + p.statsRPC.disconnect() } func (p *Server) ConnectBinapi(binapi adapter.VppAPI) error { - return p.binapiRPC.Connect(binapi) + return p.binapiRPC.connect(binapi) } func (p *Server) DisconnectBinapi() { - p.binapiRPC.Disconnect() + p.binapiRPC.disconnect() } func (p *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { diff --git a/proxy/server.go b/proxy/server.go index 472ad16..c2c4fe3 100644 --- a/proxy/server.go +++ b/proxy/server.go @@ -75,7 +75,7 @@ type StatsRPC struct { // proxying request to given api.StatsProvider. func NewStatsRPC(stats adapter.StatsAPI) (*StatsRPC, error) { rpc := new(StatsRPC) - if err := rpc.Connect(stats); err != nil { + if err := rpc.connect(stats); err != nil { return nil, err } return rpc, nil @@ -127,7 +127,7 @@ func (s *StatsRPC) watchConnection() { s.statsConn, err = core.ConnectStats(s.stats) if err == nil { atomic.StoreUint32(&s.available, 1) - log.Println("enabling statsRPC service") + log.Debugln("enabling statsRPC service") break } time.Sleep(5 * time.Second) @@ -144,7 +144,7 @@ func (s *StatsRPC) watchConnection() { } } -func (s *StatsRPC) Connect(stats adapter.StatsAPI) error { +func (s *StatsRPC) connect(stats adapter.StatsAPI) error { if atomic.LoadUint32(&s.isConnected) == 1 { return errors.New("connection already exists") } @@ -161,7 +161,7 @@ func (s *StatsRPC) Connect(stats adapter.StatsAPI) error { return nil } -func (s *StatsRPC) Disconnect() { +func (s *StatsRPC) disconnect() { if atomic.LoadUint32(&s.isConnected) == 1 { atomic.StoreUint32(&s.isConnected, 0) close(s.done) @@ -243,7 +243,7 @@ type BinapiRPC struct { // proxying request to given api.Channel. func NewBinapiRPC(binapi adapter.VppAPI) (*BinapiRPC, error) { rpc := new(BinapiRPC) - if err := rpc.Connect(binapi); err != nil { + if err := rpc.connect(binapi); err != nil { return nil, err } return rpc, nil @@ -290,7 +290,7 @@ func (s *BinapiRPC) watchConnection() { } } -func (s *BinapiRPC) Connect(binapi adapter.VppAPI) error { +func (s *BinapiRPC) connect(binapi adapter.VppAPI) error { if atomic.LoadUint32(&s.isConnected) == 1 { return errors.New("connection already exists") } @@ -307,7 +307,7 @@ func (s *BinapiRPC) Connect(binapi adapter.VppAPI) error { return nil } -func (s *BinapiRPC) Disconnect() { +func (s *BinapiRPC) disconnect() { if atomic.LoadUint32(&s.isConnected) == 1 { atomic.StoreUint32(&s.isConnected, 0) close(s.done) |