Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command: register support topic/channel state #305

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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 {
maplessssy marked this conversation as resolved.
Show resolved Hide resolved
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 {
maplessssy marked this conversation as resolved.
Show resolved Hide resolved
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