forked from IBM/sarama
-
Notifications
You must be signed in to change notification settings - Fork 0
/
acl_create_response.go
108 lines (85 loc) · 2.16 KB
/
acl_create_response.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package sarama
import "time"
// CreateAclsResponse is a an acl response creation type
type CreateAclsResponse struct {
Version int16
ThrottleTime time.Duration
AclCreationResponses []*AclCreationResponse
}
func (c *CreateAclsResponse) Encode(pe packetEncoder) error {
pe.putInt32(int32(c.ThrottleTime / time.Millisecond))
if err := pe.putArrayLength(len(c.AclCreationResponses)); err != nil {
return err
}
for _, aclCreationResponse := range c.AclCreationResponses {
if err := aclCreationResponse.Encode(pe); err != nil {
return err
}
}
return nil
}
func (c *CreateAclsResponse) Decode(pd packetDecoder, version int16) (err error) {
throttleTime, err := pd.getInt32()
if err != nil {
return err
}
c.ThrottleTime = time.Duration(throttleTime) * time.Millisecond
n, err := pd.getArrayLength()
if err != nil {
return err
}
c.AclCreationResponses = make([]*AclCreationResponse, n)
for i := 0; i < n; i++ {
c.AclCreationResponses[i] = new(AclCreationResponse)
if err := c.AclCreationResponses[i].Decode(pd, version); err != nil {
return err
}
}
return nil
}
func (c *CreateAclsResponse) APIKey() int16 {
return 30
}
func (c *CreateAclsResponse) APIVersion() int16 {
return c.Version
}
func (c *CreateAclsResponse) HeaderVersion() int16 {
return 0
}
func (c *CreateAclsResponse) IsValidVersion() bool {
return c.Version >= 0 && c.Version <= 1
}
func (c *CreateAclsResponse) RequiredVersion() KafkaVersion {
switch c.Version {
case 1:
return V2_0_0_0
default:
return V0_11_0_0
}
}
func (r *CreateAclsResponse) throttleTime() time.Duration {
return r.ThrottleTime
}
// AclCreationResponse is an acl creation response type
type AclCreationResponse struct {
Err KError
ErrMsg *string
}
func (a *AclCreationResponse) Encode(pe packetEncoder) error {
pe.putInt16(int16(a.Err))
if err := pe.putNullableString(a.ErrMsg); err != nil {
return err
}
return nil
}
func (a *AclCreationResponse) Decode(pd packetDecoder, version int16) (err error) {
kerr, err := pd.getInt16()
if err != nil {
return err
}
a.Err = KError(kerr)
if a.ErrMsg, err = pd.getNullableString(); err != nil {
return err
}
return nil
}