godoc comments

This commit is contained in:
Anton Kaliaev 2019-02-11 16:03:25 +04:00
parent c543699d15
commit 1a6eb2ef00
No known key found for this signature in database
GPG Key ID: 7B6881D965918214
3 changed files with 10 additions and 6 deletions

View File

@ -242,12 +242,14 @@ func (s *Server) UnsubscribeAll(ctx context.Context, clientID string) error {
} }
} }
// NumClients returns the number of clients.
func (s *Server) NumClients() int { func (s *Server) NumClients() int {
s.mtx.RLock() s.mtx.RLock()
defer s.mtx.RUnlock() defer s.mtx.RUnlock()
return len(s.subscriptions) return len(s.subscriptions)
} }
// NumClientSubscriptions returns the number of subscriptions the client has.
func (s *Server) NumClientSubscriptions(clientID string) int { func (s *Server) NumClientSubscriptions(clientID string) int {
s.mtx.RLock() s.mtx.RLock()
defer s.mtx.RUnlock() defer s.mtx.RUnlock()

View File

@ -272,6 +272,7 @@ func newWSEvents(cdc *amino.Codec, remote, endpoint string) *WSEvents {
return wsEvents return wsEvents
} }
// OnStart implements cmn.Service by starting WSClient and event loop.
func (w *WSEvents) OnStart() error { func (w *WSEvents) OnStart() error {
w.ws = rpcclient.NewWSClient(w.remote, w.endpoint, rpcclient.OnReconnect(func() { w.ws = rpcclient.NewWSClient(w.remote, w.endpoint, rpcclient.OnReconnect(func() {
w.redoSubscriptions() w.redoSubscriptions()
@ -287,12 +288,9 @@ func (w *WSEvents) OnStart() error {
return nil return nil
} }
// Stop wraps the BaseService/eventSwitch actions as Start does // OnStop implements cmn.Service by stopping WSClient.
func (w *WSEvents) OnStop() { func (w *WSEvents) OnStop() {
err := w.ws.Stop() _ = w.ws.Stop()
if err != nil {
w.Logger.Error("failed to stop WSClient", "err", err)
}
} }
// Subscribe implements EventsClient by using WSClient to subscribe given // Subscribe implements EventsClient by using WSClient to subscribe given

View File

@ -74,9 +74,13 @@ var (
logger log.Logger logger log.Logger
// XXX: godoc comment // config variables
// MaxSubscriptionClients mirrors RPCConfig.MaxSubscriptionClients
MaxSubscriptionClients int MaxSubscriptionClients int
// MaxSubscriptionsPerClient mirrors RPCConfig.MaxSubscriptionsPerClient
MaxSubscriptionsPerClient int MaxSubscriptionsPerClient int
// TimeoutBroadcastTxCommit mirrors RPCConfig.TimeoutBroadcastTxCommit
TimeoutBroadcastTxCommit time.Duration TimeoutBroadcastTxCommit time.Duration
) )