Skip to content

Commit

Permalink
Merge pull request #260 from mreiferson/notification_260
Browse files Browse the repository at this point in the history
nsqadmin: notification for tombstone_topic_producer missing node data
  • Loading branch information
jehiah committed Aug 26, 2013
2 parents b798938 + dbb8e63 commit efb7609
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 8 additions & 8 deletions nsqadmin/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ func createTopicChannelHandler(w http.ResponseWriter, req *http.Request) {
}
}

NotifyAdminAction("create_topic", topicName, "", req)
NotifyAdminAction("create_topic", topicName, "", "", req)

if len(channelName) > 0 {
for _, addr := range lookupdHTTPAddrs {
Expand All @@ -327,7 +327,7 @@ func createTopicChannelHandler(w http.ResponseWriter, req *http.Request) {
continue
}
}
NotifyAdminAction("create_channel", topicName, channelName, req)
NotifyAdminAction("create_channel", topicName, channelName, "", req)
}

http.Redirect(w, req, "/lookup", 302)
Expand Down Expand Up @@ -377,7 +377,7 @@ func tombstoneTopicProducerHandler(w http.ResponseWriter, req *http.Request) {
log.Printf("ERROR: nsqd %s - %s", endpoint, err.Error())
}

NotifyAdminAction("tombstone_topic_producer", topicName, "", req)
NotifyAdminAction("tombstone_topic_producer", topicName, "", node, req)

http.Redirect(w, req, rd, 302)
}
Expand Down Expand Up @@ -427,7 +427,7 @@ func deleteTopicHandler(w http.ResponseWriter, req *http.Request) {
}
}

NotifyAdminAction("delete_topic", topicName, "", req)
NotifyAdminAction("delete_topic", topicName, "", "", req)

http.Redirect(w, req, rd, 302)
}
Expand Down Expand Up @@ -475,7 +475,7 @@ func deleteChannelHandler(w http.ResponseWriter, req *http.Request) {
}
}

NotifyAdminAction("delete_channel", topicName, channelName, req)
NotifyAdminAction("delete_channel", topicName, channelName, "", req)

http.Redirect(w, req, rd, 302)
}
Expand Down Expand Up @@ -506,7 +506,7 @@ func emptyTopicHandler(w http.ResponseWriter, req *http.Request) {
}
}

NotifyAdminAction("empty_topic", topicName, "", req)
NotifyAdminAction("empty_topic", topicName, "", "", req)

http.Redirect(w, req, fmt.Sprintf("/topic/%s", url.QueryEscape(topicName)), 302)
}
Expand Down Expand Up @@ -538,7 +538,7 @@ func emptyChannelHandler(w http.ResponseWriter, req *http.Request) {
}
}

NotifyAdminAction("empty_channel", topicName, channelName, req)
NotifyAdminAction("empty_channel", topicName, channelName, "", req)

http.Redirect(w, req, fmt.Sprintf("/topic/%s/%s", url.QueryEscape(topicName), url.QueryEscape(channelName)), 302)
}
Expand Down Expand Up @@ -570,7 +570,7 @@ func pauseChannelHandler(w http.ResponseWriter, req *http.Request) {
}
}

NotifyAdminAction(strings.TrimLeft(req.URL.Path, "/"), topicName, channelName, req)
NotifyAdminAction(strings.TrimLeft(req.URL.Path, "/"), topicName, channelName, "", req)

http.Redirect(w, req, fmt.Sprintf("/topic/%s/%s", url.QueryEscape(topicName), url.QueryEscape(channelName)), 302)
}
Expand Down
8 changes: 5 additions & 3 deletions nsqadmin/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import (
type AdminAction struct {
Action string `json:"action"`
Topic string `json:"topic"`
Channel string `json:"channel"`
Channel string `json:"channel,omitempty"`
Node string `json:"node,omitempty"`
Timestamp int64 `json:"timestamp"`
User string `json:"user"`
User string `json:"user,omitempty"`
RemoteIP string `json:"remote_ip"`
UserAgent string `json:"user_agent"`
}
Expand Down Expand Up @@ -52,14 +53,15 @@ func basicAuthUser(req *http.Request) string {
return pair[0]
}

func NotifyAdminAction(actionType string, topicName string, channelName string, req *http.Request) {
func NotifyAdminAction(actionType string, topicName string, channelName string, node string, req *http.Request) {
if *notificationHTTPEndpoint == "" {
return
}
action := &AdminAction{
actionType,
topicName,
channelName,
node,
time.Now().Unix(),
basicAuthUser(req),
req.RemoteAddr,
Expand Down

0 comments on commit efb7609

Please sign in to comment.