From 2c419b100f5f90c1215617d0fac81fa6749c4d6b Mon Sep 17 00:00:00 2001 From: Ondrej Fabry Date: Thu, 9 Apr 2020 14:36:30 +0200 Subject: proxy: Unexport methods that do not satisfy rpc to remove warning Change-Id: Icd4173edc55d83b1766f204184eb818b859e648e Signed-off-by: Ondrej Fabry --- CHANGELOG.md | 12 ++++++++++++ proxy/log.go | 11 ++++++++--- proxy/proxy.go | 8 ++++---- proxy/server.go | 14 +++++++------- 4 files changed, 31 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72c7a27..979c304 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,12 +11,24 @@ This file lists changes for the GoVPP releases. - --> +## 0.3.3 +> _9 April 2020_ + +### Fixes +- proxy: Unexport methods that do not satisfy rpc to remove warning + ## 0.3.2 > _20 March 2020_ ### Fixes - statsclient: Fix panic occurring with VPP 20.05-rc0 (master) +## 0.3.1 +> _18 March 2020_ + +### Fixes +- Fix import path in examples/binapi + ## 0.3.0 > _18 March 2020_ 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) -- cgit 1.2.3-korg