@@ -10,28 +10,28 @@ 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 // customStatus is a string that details a custom status of the
3737 // sub-server, if the the sub-server is in a custom state. This status
@@ -40,8 +40,8 @@ type SubServerStatus struct {
4040 // litrpc.SubServerStatus.
4141 customStatus string
4242
43- // Err will be a non-empty string if the sub-server failed to start.
44- Err string
43+ // err will be a non-empty string if the sub-server failed to start.
44+ err string
4545
4646 // isReadyOverride is a call back that, when set and only if `running`
4747 // is not yet true, will be used to determine if a system is ready for
@@ -53,10 +53,10 @@ type SubServerStatus struct {
5353 isReadyOverride func (string , string ) (bool , bool )
5454}
5555
56- // newSubServerStatus constructs a new SubServerStatus .
57- func newSubServerStatus (disabled bool ) * SubServerStatus {
58- return & SubServerStatus {
59- Disabled : disabled ,
56+ // newSubServer constructs a new subServer .
57+ func newSubServer (disabled bool ) * subServer {
58+ return & subServer {
59+ disabled : disabled ,
6060 }
6161}
6262
@@ -66,14 +66,14 @@ func newSubServerStatus(disabled bool) *SubServerStatus {
6666type Manager struct {
6767 litrpc.UnimplementedStatusServer
6868
69- subServers map [string ]* SubServerStatus
69+ subServers map [string ]* subServer
7070 mu sync.RWMutex
7171}
7272
7373// NewStatusManager constructs a new Manager.
7474func NewStatusManager () * Manager {
7575 return & Manager {
76- subServers : make (map [string ]* SubServerStatus ),
76+ subServers : make (map [string ]* subServer ),
7777 }
7878}
7979
@@ -91,14 +91,14 @@ func (s *Manager) IsSystemReady(name, req string) (bool, bool, error) {
9191 "name %s has not yet been registered" )
9292 }
9393
94- if server .Disabled {
94+ if server .disabled {
9595 return false , true , nil
9696 }
9797
9898 // If this system has an override check set, then we first check that
9999 // to see if it overrides the "ready" status of the system in case the
100100 // system isn't marked as running yet.
101- if server .isReadyOverride != nil && ! server .Running {
101+ if server .isReadyOverride != nil && ! server .running {
102102 isReady , handled := server .isReadyOverride (
103103 req , server .customStatus ,
104104 )
@@ -107,7 +107,7 @@ func (s *Manager) IsSystemReady(name, req string) (bool, bool, error) {
107107 }
108108 }
109109
110- return server .Running , false , nil
110+ return server .running , false , nil
111111}
112112
113113// SubServerStatus queries the current status of a given sub-server.
@@ -123,9 +123,9 @@ func (s *Manager) SubServerStatus(_ context.Context,
123123 resp := make (map [string ]* litrpc.SubServerStatus , len (s .subServers ))
124124 for server , status := range s .subServers {
125125 resp [server ] = & litrpc.SubServerStatus {
126- Disabled : status .Disabled ,
127- Running : status .Running ,
128- Error : status .Err ,
126+ Disabled : status .disabled ,
127+ Running : status .running ,
128+ Error : status .err ,
129129 CustomStatus : status .customStatus ,
130130 }
131131 }
@@ -158,7 +158,7 @@ func (s *Manager) RegisterAndEnableSubServer(name string,
158158func (s * Manager ) registerSubServerUnsafe (name string , disabled bool ,
159159 opts ... SubServerOption ) {
160160
161- ss := newSubServerStatus (disabled )
161+ ss := newSubServer (disabled )
162162
163163 for _ , o := range opts {
164164 o (ss )
@@ -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 .customStatus = ""
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 .customStatus = ""
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 .customStatus = ""
268268}
0 commit comments