Skip to content
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,14 @@ func Auth(secret string) (*Command, error) {
return &Command{[]byte("AUTH"), nil, []byte(secret)}, nil
}

// Register creates a new Command to add a topic/channel for the connected nsqd
func Register(topic string, channel string) *Command {
params := [][]byte{[]byte(topic)}
if len(channel) > 0 {
params = append(params, []byte(channel))
// Register creates a new Command to add a topic/channel with state for the connected nsqd
func Register(topic string, channel string, paused ...int) *Command {
params := [][]byte{[]byte(topic), []byte(channel)}
if len(paused) > 0 {
params = append(params, []byte(strconv.Itoa(paused[0]))) //topic isPaused
if len(paused) > 1 {
params = append(params, []byte(strconv.Itoa(paused[1]))) //channel isPaused
}
}
return &Command{[]byte("REGISTER"), params, nil}
}
Expand All @@ -121,6 +124,15 @@ func UnRegister(topic string, channel string) *Command {
return &Command{[]byte("UNREGISTER"), params, nil}
}

// SyncState creates a new Command to sync a topic/channel pause state changes.
func SyncState(topic string, channel string, state int) *Command {
params := [][]byte{[]byte(strconv.Itoa(state)), []byte(topic)}
if len(channel) > 0 {
params = append(params, []byte(channel))
}
return &Command{[]byte("SYNCSTATE"), params, nil}
}

// Ping creates a new Command to keep-alive the state of all the
// announced topic/channels for a given client
func Ping() *Command {
Expand Down