-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add LeaveGroup request and response pair.
- Loading branch information
1 parent
b1d40bd
commit ccec1aa
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package sarama | ||
|
||
type LeaveGroupRequest struct { | ||
GroupId string | ||
MemberId string | ||
} | ||
|
||
func (r *LeaveGroupRequest) encode(pe packetEncoder) error { | ||
if err := pe.putString(r.GroupId); err != nil { | ||
return err | ||
} | ||
if err := pe.putString(r.MemberId); err != nil { | ||
return err | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *LeaveGroupRequest) decode(pd packetDecoder) (err error) { | ||
if r.GroupId, err = pd.getString(); err != nil { | ||
return | ||
} | ||
if r.MemberId, err = pd.getString(); err != nil { | ||
return | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func (r *LeaveGroupRequest) key() int16 { | ||
return 13 | ||
} | ||
|
||
func (r *LeaveGroupRequest) version() int16 { | ||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package sarama | ||
|
||
type LeaveGroupResponse struct { | ||
Err KError | ||
} | ||
|
||
func (r *LeaveGroupResponse) encode(pe packetEncoder) error { | ||
pe.putInt16(int16(r.Err)) | ||
return nil | ||
} | ||
|
||
func (r *LeaveGroupResponse) decode(pd packetDecoder) (err error) { | ||
if kerr, err := pd.getInt16(); err != nil { | ||
return err | ||
} else { | ||
r.Err = KError(kerr) | ||
} | ||
|
||
return nil | ||
} |