Skip to content

Commit

Permalink
Adds master command to doorman_shell
Browse files Browse the repository at this point in the history
  • Loading branch information
josvisser committed Apr 1, 2016
1 parent ab90eeb commit aecdb0c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 9 additions & 1 deletion go/client/doorman/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ type Option connection.Option

// getClientID returns a unique client id, consisting of a host:pid id plus a counter
func getClientID() string {

hostname, err := os.Hostname()

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

// GetMaster returns the address of the Doorman master we are connected to.
func (client *Client) GetMaster() string {
if client.conn == nil {
return ""
}

return client.conn.String()
}

// run is the client's main loop. It takes care of requesting new
// resources, and managing ones already claimed. This is the only
// method that should be modifying the client's internal state and
Expand Down
11 changes: 9 additions & 2 deletions go/cmd/doorman_shell/doorman_shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ show
the asynchronous nature of the Doorman API you may not see the
requested assignments immediately.
master
Shows the current Doorman master for each client.
help
Show this information.
Expand Down Expand Up @@ -223,7 +227,11 @@ func (client *Multiclient) Eval(command []string) error {
}
clientID, resourceID := tail[0], tail[1]
return client.Release(clientID, resourceID)

case "master":
for k, v := range client.clients {
fmt.Printf("%s: %s\n", k, v.GetMaster())
}
return nil
case "help":
fmt.Fprintln(os.Stderr, help)
return nil
Expand All @@ -232,7 +240,6 @@ func (client *Multiclient) Eval(command []string) error {
default:
return errors.New("unrecognized command")
}

}

func (client *Multiclient) Close() {
Expand Down

0 comments on commit aecdb0c

Please sign in to comment.