mirror of
https://github.com/fhmq/hmq.git
synced 2026-09-01 15:24:53 +00:00
Plugins support (#46)
* modify * update * add acl * add feature * update dockerfile * add deploy * update * update * plugins * plugins * update * update * update * fixed * remove * fixed * add log * update * fixed * update * fix config * add http api * add http api * resp * add config for work chan * update * fixed * update * disable trace * fixed * change acl * fixed * fixed res * dd * dd * ddd * dd * update * fixed * update * add * fixed * update key * add log * update * format * update * update auth * update * update readme * added * update * fixed * fixed * fix * upade * update * update
This commit is contained in:
+81
@@ -0,0 +1,81 @@
|
||||
package sarama
|
||||
|
||||
type MetadataRequest struct {
|
||||
Version int16
|
||||
Topics []string
|
||||
AllowAutoTopicCreation bool
|
||||
}
|
||||
|
||||
func (r *MetadataRequest) encode(pe packetEncoder) error {
|
||||
if r.Version < 0 || r.Version > 5 {
|
||||
return PacketEncodingError{"invalid or unsupported MetadataRequest version field"}
|
||||
}
|
||||
if r.Version == 0 || len(r.Topics) > 0 {
|
||||
err := pe.putArrayLength(len(r.Topics))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := range r.Topics {
|
||||
err = pe.putString(r.Topics[i])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
pe.putInt32(-1)
|
||||
}
|
||||
if r.Version > 3 {
|
||||
pe.putBool(r.AllowAutoTopicCreation)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *MetadataRequest) decode(pd packetDecoder, version int16) error {
|
||||
r.Version = version
|
||||
size, err := pd.getInt32()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if size > 0 {
|
||||
r.Topics = make([]string, size)
|
||||
for i := range r.Topics {
|
||||
topic, err := pd.getString()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.Topics[i] = topic
|
||||
}
|
||||
}
|
||||
if r.Version > 3 {
|
||||
autoCreation, err := pd.getBool()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r.AllowAutoTopicCreation = autoCreation
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *MetadataRequest) key() int16 {
|
||||
return 3
|
||||
}
|
||||
|
||||
func (r *MetadataRequest) version() int16 {
|
||||
return r.Version
|
||||
}
|
||||
|
||||
func (r *MetadataRequest) requiredVersion() KafkaVersion {
|
||||
switch r.Version {
|
||||
case 1:
|
||||
return V0_10_0_0
|
||||
case 2:
|
||||
return V0_10_1_0
|
||||
case 3, 4:
|
||||
return V0_11_0_0
|
||||
case 5:
|
||||
return V1_0_0_0
|
||||
default:
|
||||
return MinVersion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user