@@ -23,6 +23,13 @@ type SubServerStatus struct {
23
23
// been started.
24
24
Running bool
25
25
26
+ // customStatus is a string that details a custom status of the
27
+ // sub-server, if the the sub-server is in a custom state. This status
28
+ // can be set to a unique status that only exists for the specific
29
+ // sub-server, and will be displayed to the user with the
30
+ // litrpc.SubServerStatus.
31
+ customStatus string
32
+
26
33
// Err will be a non-empty string if the sub-server failed to start.
27
34
Err string
28
35
}
@@ -105,6 +112,20 @@ func (s *Manager) registerSubServerUnsafe(name string, disabled bool,
105
112
s .subServers [name ] = ss
106
113
}
107
114
115
+ // SetCustomStatus updates the custom status of the given sub-server to the
116
+ // passed status.
117
+ func (s * Manager ) SetCustomStatus (name , customStatus string ) {
118
+ s .mu .Lock ()
119
+ defer s .mu .Unlock ()
120
+
121
+ ss , ok := s .subServers [name ]
122
+ if ! ok {
123
+ return
124
+ }
125
+
126
+ ss .customStatus = customStatus
127
+ }
128
+
108
129
// GetStatus returns the current status of a given sub-server. This will
109
130
// silently fail if the referenced sub-server has not yet been registered.
110
131
func (s * Manager ) GetStatus (name string ) (* SubServerStatus , error ) {
@@ -155,6 +176,7 @@ func (s *Manager) SetRunning(name string) {
155
176
}
156
177
157
178
ss .Running = true
179
+ ss .customStatus = ""
158
180
}
159
181
160
182
// SetStopped can be used to set the status of a sub-server as not Running and
@@ -175,6 +197,7 @@ func (s *Manager) SetStopped(name string) {
175
197
176
198
ss .Running = false
177
199
ss .Err = ""
200
+ ss .customStatus = ""
178
201
}
179
202
180
203
// SetErrored can be used to set the status of a sub-server as not Running
@@ -201,4 +224,5 @@ func (s *Manager) SetErrored(name string, errStr string,
201
224
202
225
ss .Running = false
203
226
ss .Err = err
227
+ ss .customStatus = ""
204
228
}
0 commit comments