ex172000 commented on code in PR #2737:
URL: https://github.com/apache/iggy/pull/2737#discussion_r2819254897


##########
foreign/go/contracts/consumer_groups.go:
##########
@@ -35,30 +35,103 @@ type ConsumerGroupMember struct {
        Partitions      []uint32
 }
 
-type CreateConsumerGroupRequest struct {
+type CreateConsumerGroup struct {
        StreamId Identifier `json:"streamId"`
        TopicId  Identifier `json:"topicId"`
        Name     string     `json:"name"`
 }
 
-type DeleteConsumerGroupRequest struct {
+func (c *CreateConsumerGroup) Code() CommandCode {
+       return CreateGroupCode
+}
+
+func (c *CreateConsumerGroup) MarshalBinary() ([]byte, error) {
+       streamIdBytes, err := c.StreamId.MarshalBinary()
+       if err != nil {
+               return nil, err
+       }
+       topicIdBytes, err := c.TopicId.MarshalBinary()
+       if err != nil {
+               return nil, err
+       }
+       offset := len(streamIdBytes) + len(topicIdBytes)
+       bytes := make([]byte, offset+1+len(c.Name))
+       copy(bytes[0:len(streamIdBytes)], streamIdBytes)
+       copy(bytes[len(streamIdBytes):offset], topicIdBytes)
+       bytes[offset] = byte(len(c.Name))
+       copy(bytes[offset+1:], c.Name)
+       return bytes, nil
+}
+
+type DeleteConsumerGroup struct {
        StreamId        Identifier `json:"streamId"`
        TopicId         Identifier `json:"topicId"`
        ConsumerGroupId Identifier `json:"consumerGroupId"`
 }
 
-type JoinConsumerGroupRequest struct {
+func (d *DeleteConsumerGroup) Code() CommandCode {
+       return DeleteGroupCode
+}
+
+func (d *DeleteConsumerGroup) MarshalBinary() ([]byte, error) {
+       return marshalIdentifiers(d.StreamId, d.TopicId, d.ConsumerGroupId)
+}
+
+type JoinConsumerGroup struct {
        StreamId        Identifier `json:"streamId"`
        TopicId         Identifier `json:"topicId"`
        ConsumerGroupId Identifier `json:"consumerGroupId"`
 }
 
-type LeaveConsumerGroupRequest struct {
+func (j *JoinConsumerGroup) Code() CommandCode {
+       return JoinGroupCode
+}
+
+func (j *JoinConsumerGroup) MarshalBinary() ([]byte, error) {
+       return marshalIdentifiers(j.StreamId, j.TopicId, j.ConsumerGroupId)
+}
+
+type LeaveConsumerGroup struct {
        StreamId        Identifier `json:"streamId"`
        TopicId         Identifier `json:"topicId"`
        ConsumerGroupId Identifier `json:"consumerGroupId"`
 }
 
+func (l *LeaveConsumerGroup) Code() CommandCode {
+       return LeaveGroupCode
+}
+
+func (l *LeaveConsumerGroup) MarshalBinary() ([]byte, error) {
+       return marshalIdentifiers(l.StreamId, l.TopicId, l.ConsumerGroupId)
+}
+
+type GetConsumerGroup struct {
+       StreamId Identifier
+       TopicId  Identifier
+       GroupId  Identifier

Review Comment:
   The name should be consistent with line 83, also do we want to have the JSON 
annotation?



##########
foreign/go/contracts/consumer_groups.go:
##########
@@ -35,30 +35,103 @@ type ConsumerGroupMember struct {
        Partitions      []uint32
 }
 
-type CreateConsumerGroupRequest struct {
+type CreateConsumerGroup struct {
        StreamId Identifier `json:"streamId"`
        TopicId  Identifier `json:"topicId"`
        Name     string     `json:"name"`
 }
 
-type DeleteConsumerGroupRequest struct {
+func (c *CreateConsumerGroup) Code() CommandCode {
+       return CreateGroupCode
+}
+
+func (c *CreateConsumerGroup) MarshalBinary() ([]byte, error) {
+       streamIdBytes, err := c.StreamId.MarshalBinary()
+       if err != nil {
+               return nil, err
+       }
+       topicIdBytes, err := c.TopicId.MarshalBinary()
+       if err != nil {
+               return nil, err
+       }
+       offset := len(streamIdBytes) + len(topicIdBytes)
+       bytes := make([]byte, offset+1+len(c.Name))
+       copy(bytes[0:len(streamIdBytes)], streamIdBytes)
+       copy(bytes[len(streamIdBytes):offset], topicIdBytes)
+       bytes[offset] = byte(len(c.Name))
+       copy(bytes[offset+1:], c.Name)
+       return bytes, nil
+}
+
+type DeleteConsumerGroup struct {
        StreamId        Identifier `json:"streamId"`
        TopicId         Identifier `json:"topicId"`
        ConsumerGroupId Identifier `json:"consumerGroupId"`
 }
 
-type JoinConsumerGroupRequest struct {
+func (d *DeleteConsumerGroup) Code() CommandCode {
+       return DeleteGroupCode
+}
+
+func (d *DeleteConsumerGroup) MarshalBinary() ([]byte, error) {
+       return marshalIdentifiers(d.StreamId, d.TopicId, d.ConsumerGroupId)
+}
+
+type JoinConsumerGroup struct {
        StreamId        Identifier `json:"streamId"`
        TopicId         Identifier `json:"topicId"`
        ConsumerGroupId Identifier `json:"consumerGroupId"`

Review Comment:
   This structure seems repeating for many CG operations, can we have a common 
struct ?



##########
foreign/go/contracts/create_user.go:
##########
@@ -0,0 +1,77 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package iggcon
+
+import "encoding/binary"
+
+type CreateUser struct {
+       Username    string       `json:"username"`
+       Password    string       `json:"Password"`
+       Status      UserStatus   `json:"Status"`
+       Permissions *Permissions `json:"Permissions,omitempty"`
+}
+
+func (c *CreateUser) Code() CommandCode {
+       return CreateUserCode
+}
+
+func (c *CreateUser) MarshalBinary() ([]byte, error) {

Review Comment:
   Same here, appreciated if we can have some test



##########
foreign/go/contracts/change_password.go:
##########
@@ -0,0 +1,52 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package iggcon
+
+type ChangePassword struct {
+       UserID          Identifier `json:"-"`
+       CurrentPassword string     `json:"CurrentPassword"`
+       NewPassword     string     `json:"NewPassword"`
+}
+
+func (c *ChangePassword) Code() CommandCode {
+       return ChangePasswordCode
+}
+
+func (c *ChangePassword) MarshalBinary() ([]byte, error) {

Review Comment:
   Looks quite some operations here, appreciate if we can add a test



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to