Skip to content

Commit aecdb0c

Browse files
committed
Adds master command to doorman_shell
1 parent ab90eeb commit aecdb0c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

go/client/doorman/client.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ type Option connection.Option
105105

106106
// getClientID returns a unique client id, consisting of a host:pid id plus a counter
107107
func getClientID() string {
108-
109108
hostname, err := os.Hostname()
110109

111110
if err != nil {
@@ -201,6 +200,15 @@ func NewWithID(addr string, id string, opts ...Option) (*Client, error) {
201200
return client, nil
202201
}
203202

203+
// GetMaster returns the address of the Doorman master we are connected to.
204+
func (client *Client) GetMaster() string {
205+
if client.conn == nil {
206+
return ""
207+
}
208+
209+
return client.conn.String()
210+
}
211+
204212
// run is the client's main loop. It takes care of requesting new
205213
// resources, and managing ones already claimed. This is the only
206214
// method that should be modifying the client's internal state and

go/cmd/doorman_shell/doorman_shell.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ show
7474
the asynchronous nature of the Doorman API you may not see the
7575
requested assignments immediately.
7676
77+
master
78+
79+
Shows the current Doorman master for each client.
80+
7781
help
7882
7983
Show this information.
@@ -223,7 +227,11 @@ func (client *Multiclient) Eval(command []string) error {
223227
}
224228
clientID, resourceID := tail[0], tail[1]
225229
return client.Release(clientID, resourceID)
226-
230+
case "master":
231+
for k, v := range client.clients {
232+
fmt.Printf("%s: %s\n", k, v.GetMaster())
233+
}
234+
return nil
227235
case "help":
228236
fmt.Fprintln(os.Stderr, help)
229237
return nil
@@ -232,7 +240,6 @@ func (client *Multiclient) Eval(command []string) error {
232240
default:
233241
return errors.New("unrecognized command")
234242
}
235-
236243
}
237244

238245
func (client *Multiclient) Close() {

0 commit comments

Comments
 (0)