@@ -9,36 +9,36 @@ import (
99 "github.com/lightninglabs/lightning-terminal/litrpc"
1010)
1111
12- type SubServerOption func (status * SubServerStatus )
12+ type SubServerOption func (status * subServer )
1313
1414// WithIsReadyOverride is a functional option that can be used to set a call
1515// back function that is used to check if a system is ready _iff_ the system
1616// running status is not yet true. The call-back will be passed the request URI
1717// along with any manual status that has been set for the subsystem.
1818func WithIsReadyOverride (fn func (string , string ) (bool , bool )) SubServerOption {
19- return func (status * SubServerStatus ) {
19+ return func (status * subServer ) {
2020 status .isReadyOverride = fn
2121 }
2222}
2323
24- // SubServerStatus represents the status of a sub-server.
25- type SubServerStatus struct {
26- // Disabled is true if the sub-server is available in the LiT bundle but
24+ // subServer represents the status of a sub-server.
25+ type subServer struct {
26+ // disabled is true if the sub-server is available in the LiT bundle but
2727 // has explicitly been disabled by the user.
28- Disabled bool
28+ disabled bool
2929
30- // Running is true if the sub-server is enabled and has successfully
30+ // running is true if the sub-server is enabled and has successfully
3131 // been started.
32- Running bool
32+ running bool
3333
3434 // manualStatus will be a non-empty string that details the current
3535 // status of the sub-server. This status can be set to a unique status
3636 // that only exists for the specific sub-server, and will be displayed
3737 // to the user with the litrpc.SubServerStatus.
3838 manualStatus string
3939
40- // Err will be a non-empty string if the sub-server failed to start.
41- Err string
40+ // err will be a non-empty string if the sub-server failed to start.
41+ err string
4242
4343 // isReadyOverride is a call back that, when set and only if `running`
4444 // is not yet true, will be used to determine if a system is ready for
@@ -50,10 +50,10 @@ type SubServerStatus struct {
5050 isReadyOverride func (string , string ) (bool , bool )
5151}
5252
53- // newSubServerStatus constructs a new SubServerStatus .
54- func newSubServerStatus (disabled bool ) * SubServerStatus {
55- return & SubServerStatus {
56- Disabled : disabled ,
53+ // newSubServer constructs a new subServer .
54+ func newSubServer (disabled bool ) * subServer {
55+ return & subServer {
56+ disabled : disabled ,
5757 }
5858}
5959
@@ -63,14 +63,14 @@ func newSubServerStatus(disabled bool) *SubServerStatus {
6363type Manager struct {
6464 litrpc.UnimplementedStatusServer
6565
66- subServers map [string ]* SubServerStatus
66+ subServers map [string ]* subServer
6767 mu sync.RWMutex
6868}
6969
7070// NewStatusManager constructs a new Manager.
7171func NewStatusManager () * Manager {
7272 return & Manager {
73- subServers : make (map [string ]* SubServerStatus ),
73+ subServers : make (map [string ]* subServer ),
7474 }
7575}
7676
@@ -88,7 +88,7 @@ func (s *Manager) IsSystemReady(name, req string) (bool, bool, error) {
8888 "name %s has not yet been registered" )
8989 }
9090
91- if server .Disabled {
91+ if server .disabled {
9292 return false , true , nil
9393 }
9494
@@ -100,8 +100,8 @@ func (s *Manager) IsSystemReady(name, req string) (bool, bool, error) {
100100 )
101101 }
102102
103- if ! handled || server .Running {
104- return server .Running , false , nil
103+ if ! handled || server .running {
104+ return server .running , false , nil
105105 }
106106
107107 return isReady , false , nil
@@ -120,9 +120,9 @@ func (s *Manager) SubServerStatus(_ context.Context,
120120 resp := make (map [string ]* litrpc.SubServerStatus , len (s .subServers ))
121121 for server , status := range s .subServers {
122122 resp [server ] = & litrpc.SubServerStatus {
123- Disabled : status .Disabled ,
124- Running : status .Running ,
125- Error : status .Err ,
123+ Disabled : status .disabled ,
124+ Running : status .running ,
125+ Error : status .err ,
126126 Status : status .manualStatus ,
127127 }
128128 }
@@ -155,7 +155,7 @@ func (s *Manager) RegisterAndEnableSubServer(name string,
155155func (s * Manager ) registerSubServerUnsafe (name string , disabled bool ,
156156 opts ... SubServerOption ) {
157157
158- ss := newSubServerStatus (disabled )
158+ ss := newSubServer (disabled )
159159 ss .manualStatus = "Registered"
160160
161161 for _ , o := range opts {
@@ -194,7 +194,7 @@ func (s *Manager) SetEnabled(name string) {
194194 return
195195 }
196196
197- ss .Disabled = false
197+ ss .disabled = false
198198}
199199
200200// SetRunning can be used to set the status of a sub-server as Running
@@ -213,8 +213,8 @@ func (s *Manager) SetRunning(name string) {
213213 return
214214 }
215215
216- ss .Running = true
217- ss .Err = ""
216+ ss .running = true
217+ ss .err = ""
218218 ss .manualStatus = "Running"
219219}
220220
@@ -234,8 +234,8 @@ func (s *Manager) SetStopped(name string) {
234234 return
235235 }
236236
237- ss .Running = false
238- ss .Err = ""
237+ ss .running = false
238+ ss .err = ""
239239 ss .manualStatus = "Stopped"
240240}
241241
@@ -260,7 +260,7 @@ func (s *Manager) SetErrored(name string, errStr string,
260260 err := fmt .Sprintf (errStr , params ... )
261261 log .Errorf ("could not start the %s sub-server: %s" , name , err )
262262
263- ss .Running = false
264- ss .Err = err
263+ ss .running = false
264+ ss .err = err
265265 ss .manualStatus = "Errored"
266266}
0 commit comments