@@ -10,37 +10,37 @@ import (
1010)
1111
1212// SubServerOption defines a functional option that can be used to modify the
13- // values of a SubServerStatus 's fields.
14- type SubServerOption func (status * SubServerStatus )
13+ // values of a subServer 's fields.
14+ type SubServerOption func (status * subServer )
1515
1616// WithIsReadyOverride is a functional option that can be used to set a call
1717// back function that is used to check if a system is ready _iff_ the system
1818// running status is not yet true. The call-back will be passed the request URI
1919// along with any manual status that has been set for the subsystem.
2020func WithIsReadyOverride (fn func (string , string ) (bool , bool )) SubServerOption {
21- return func (status * SubServerStatus ) {
21+ return func (status * subServer ) {
2222 status .isReadyOverride = fn
2323 }
2424}
2525
26- // SubServerStatus represents the status of a sub-server.
27- type SubServerStatus struct {
28- // Disabled is true if the sub-server is available in the LiT bundle but
26+ // subServer represents the status of a sub-server.
27+ type subServer struct {
28+ // disabled is true if the sub-server is available in the LiT bundle but
2929 // has explicitly been disabled by the user.
30- Disabled bool
30+ disabled bool
3131
32- // Running is true if the sub-server is enabled and has successfully
32+ // running is true if the sub-server is enabled and has successfully
3333 // been started.
34- Running bool
34+ running bool
3535
3636 // manualStatus will be a non-empty string that details the current
3737 // status of the sub-server. This status can be set to a unique status
3838 // that only exists for the specific sub-server, and will be displayed
3939 // to the user with the litrpc.SubServerStatus.
4040 manualStatus string
4141
42- // Err will be a non-empty string if the sub-server failed to start.
43- Err string
42+ // err will be a non-empty string if the sub-server failed to start.
43+ err string
4444
4545 // isReadyOverride is a call back that, when set and only if `running`
4646 // is not yet true, will be used to determine if a system is ready for
@@ -52,10 +52,10 @@ type SubServerStatus struct {
5252 isReadyOverride func (string , string ) (bool , bool )
5353}
5454
55- // newSubServerStatus constructs a new SubServerStatus .
56- func newSubServerStatus (disabled bool ) * SubServerStatus {
57- return & SubServerStatus {
58- Disabled : disabled ,
55+ // newSubServer constructs a new subServer .
56+ func newSubServer (disabled bool ) * subServer {
57+ return & subServer {
58+ disabled : disabled ,
5959 }
6060}
6161
@@ -65,14 +65,14 @@ func newSubServerStatus(disabled bool) *SubServerStatus {
6565type Manager struct {
6666 litrpc.UnimplementedStatusServer
6767
68- subServers map [string ]* SubServerStatus
68+ subServers map [string ]* subServer
6969 mu sync.RWMutex
7070}
7171
7272// NewStatusManager constructs a new Manager.
7373func NewStatusManager () * Manager {
7474 return & Manager {
75- subServers : make (map [string ]* SubServerStatus ),
75+ subServers : make (map [string ]* subServer ),
7676 }
7777}
7878
@@ -90,14 +90,14 @@ func (s *Manager) IsSystemReady(name, req string) (bool, bool, error) {
9090 "name %s has not yet been registered" )
9191 }
9292
93- if server .Disabled {
93+ if server .disabled {
9494 return false , true , nil
9595 }
9696
9797 // If this system has an override check set, then we first check that
9898 // to see if it overrides the "ready" status of the system in case the
9999 // system isn't marked as running yet.
100- if server .isReadyOverride != nil && ! server .Running {
100+ if server .isReadyOverride != nil && ! server .running {
101101 isReady , handled := server .isReadyOverride (
102102 req , server .manualStatus ,
103103 )
@@ -106,7 +106,7 @@ func (s *Manager) IsSystemReady(name, req string) (bool, bool, error) {
106106 }
107107 }
108108
109- return server .Running , false , nil
109+ return server .running , false , nil
110110}
111111
112112// SubServerStatus queries the current status of a given sub-server.
@@ -122,9 +122,9 @@ func (s *Manager) SubServerStatus(_ context.Context,
122122 resp := make (map [string ]* litrpc.SubServerStatus , len (s .subServers ))
123123 for server , status := range s .subServers {
124124 resp [server ] = & litrpc.SubServerStatus {
125- Disabled : status .Disabled ,
126- Running : status .Running ,
127- Error : status .Err ,
125+ Disabled : status .disabled ,
126+ Running : status .running ,
127+ Error : status .err ,
128128 Status : status .manualStatus ,
129129 }
130130 }
@@ -157,7 +157,7 @@ func (s *Manager) RegisterAndEnableSubServer(name string,
157157func (s * Manager ) registerSubServerUnsafe (name string , disabled bool ,
158158 opts ... SubServerOption ) {
159159
160- ss := newSubServerStatus (disabled )
160+ ss := newSubServer (disabled )
161161 ss .manualStatus = "Registered"
162162
163163 for _ , o := range opts {
@@ -196,7 +196,7 @@ func (s *Manager) SetEnabled(name string) {
196196 return
197197 }
198198
199- ss .Disabled = false
199+ ss .disabled = false
200200}
201201
202202// SetRunning can be used to set the status of a sub-server as Running
@@ -215,8 +215,8 @@ func (s *Manager) SetRunning(name string) {
215215 return
216216 }
217217
218- ss .Running = true
219- ss .Err = ""
218+ ss .running = true
219+ ss .err = ""
220220 ss .manualStatus = "Running"
221221}
222222
@@ -236,8 +236,8 @@ func (s *Manager) SetStopped(name string) {
236236 return
237237 }
238238
239- ss .Running = false
240- ss .Err = ""
239+ ss .running = false
240+ ss .err = ""
241241 ss .manualStatus = "Stopped"
242242}
243243
@@ -262,7 +262,7 @@ func (s *Manager) SetErrored(name string, errStr string,
262262 err := fmt .Sprintf (errStr , params ... )
263263 log .Errorf ("could not start the %s sub-server: %s" , name , err )
264264
265- ss .Running = false
266- ss .Err = err
265+ ss .running = false
266+ ss .err = err
267267 ss .manualStatus = "Errored"
268268}
0 commit comments