-
-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
19 changed files
with
176 additions
and
29 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,25 @@ | ||
package protocol | ||
|
||
const ( | ||
ProduceKey = iota | ||
FetchKey | ||
OffsetsKey | ||
MetadataKey | ||
LeaderAndISRKey | ||
StopReplicaKey | ||
UpdateMetadataKey | ||
ControlledShutdownKey | ||
OffsetCommitKey | ||
OffsetFetchKey | ||
GroupCoordinatorKey | ||
JoinGroupKey | ||
HeartbeatKey | ||
LeaveGroupKey | ||
SyncGroupKey | ||
DescribeGroupsKey | ||
ListGroupsKey | ||
SaslHandshakeKey | ||
ApiVersionsKey | ||
CreateTopicsKey | ||
DeleteTopicsKey | ||
) |
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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,73 @@ | ||
package protocol | ||
|
||
type StopReplicaPartition struct { | ||
Topic string | ||
Partition int32 | ||
} | ||
|
||
type StopReplicaRequest struct { | ||
ControllerID int32 | ||
ControllerEpoch int32 | ||
DeletePartitions bool | ||
Partitions []*StopReplicaPartition | ||
} | ||
|
||
func (r *StopReplicaRequest) Encode(e PacketEncoder) (err error) { | ||
e.PutInt32(r.ControllerID) | ||
e.PutInt32(r.ControllerEpoch) | ||
if r.DeletePartitions { | ||
e.PutInt8(1) | ||
} else { | ||
e.PutInt8(0) | ||
} | ||
if err = e.PutArrayLength(len(r.Partitions)); err != nil { | ||
return | ||
} | ||
for _, partition := range r.Partitions { | ||
if err = e.PutString(partition.Topic); err != nil { | ||
return | ||
} | ||
e.PutInt32(partition.Partition) | ||
} | ||
return | ||
} | ||
|
||
func (r *StopReplicaRequest) Decode(d PacketDecoder) (err error) { | ||
if r.ControllerID, err = d.Int32(); err != nil { | ||
return | ||
} | ||
if r.ControllerEpoch, err = d.Int32(); err != nil { | ||
return | ||
} | ||
dp, err := d.Int8() | ||
if err != nil { | ||
return | ||
} else if dp == 1 { | ||
r.DeletePartitions = true | ||
} else { | ||
r.DeletePartitions = false | ||
} | ||
length, err := d.ArrayLength() | ||
if err != nil { | ||
return | ||
} | ||
r.Partitions = make([]*StopReplicaPartition, length) | ||
for index := range r.Partitions { | ||
r.Partitions[index] = new(StopReplicaPartition) | ||
if r.Partitions[index].Topic, err = d.String(); err != nil { | ||
return | ||
} | ||
if r.Partitions[index].Partition, err = d.Int32(); err != nil { | ||
return | ||
} | ||
} | ||
return nil | ||
} | ||
|
||
func (r *StopReplicaRequest) Key() int16 { | ||
return StopReplicaKey | ||
} | ||
|
||
func (r *StopReplicaRequest) 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,49 @@ | ||
package protocol | ||
|
||
type StopReplicaPartitionAndErrorCode struct { | ||
StopReplicaPartition | ||
ErrorCode int16 | ||
} | ||
|
||
type StopReplicaResponse struct { | ||
ErrorCode int16 | ||
Partitions []*StopReplicaPartitionAndErrorCode | ||
} | ||
|
||
func (r *StopReplicaResponse) Encode(e PacketEncoder) (err error) { | ||
e.PutInt16(r.ErrorCode) | ||
if err = e.PutArrayLength(len(r.Partitions)); err != nil { | ||
return | ||
} | ||
for _, partition := range r.Partitions { | ||
if err = e.PutString(partition.Topic); err != nil { | ||
return | ||
} | ||
e.PutInt32(partition.Partition) | ||
e.PutInt16(partition.ErrorCode) | ||
} | ||
return | ||
} | ||
|
||
func (r *StopReplicaResponse) Decode(d PacketDecoder) (err error) { | ||
if r.ErrorCode, err = d.Int16(); err != nil { | ||
return | ||
} | ||
length, err := d.ArrayLength() | ||
if err != nil { | ||
return | ||
} | ||
r.Partitions = make([]*StopReplicaPartitionAndErrorCode, length) | ||
for index := range r.Partitions { | ||
if r.Partitions[index].Topic, err = d.String(); err != nil { | ||
return | ||
} | ||
if r.Partitions[index].Partition, err = d.Int32(); err != nil { | ||
return | ||
} | ||
if r.Partitions[index].ErrorCode, err = d.Int16(); err != nil { | ||
return | ||
} | ||
} | ||
return | ||
} |
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
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