Forráskód Böngészése

Consistent error naming

Evan Huus 12 éve
szülő
commit
3d11ccb0db
9 módosított fájl, 27 hozzáadás és 27 törlés
  1. 0 19
      errors.go
  2. 19 0
      kError.go
  3. 1 1
      packetDecoder.go
  4. 1 1
      packetEncoder.go
  5. 1 1
      partitionMetadata.go
  6. 1 1
      prepEncoder.go
  7. 2 2
      realDecoder.go
  8. 1 1
      realEncoder.go
  9. 1 1
      topicMetadata.go

+ 0 - 19
errors.go

@@ -1,19 +0,0 @@
-package kafka
-
-type kafkaError int16
-
-const (
-	NO_ERROR                    kafkaError = 0
-	UNKNOWN                                = -1
-	OFFSET_OUT_OF_RANGE                    = 1
-	INVALID_MESSAGE                        = 2
-	UNKNOWN_TOPIC_OR_PARTITION             = 3
-	INVALID_MESSAGE_SIZE                   = 4
-	LEADER_NOT_AVAILABLE                   = 5
-	NOT_LEADER_FOR_PARTITION               = 6
-	REQUEST_TIMED_OUT                      = 7
-	BROKER_NOT_AVAILABLE                   = 8
-	REPLICA_NOT_AVAILABLE                  = 9
-	MESSAGE_SIZE_TOO_LARGE                 = 10
-	STALE_CONTROLLER_EPOCH_CODE            = 11
-)

+ 19 - 0
kError.go

@@ -0,0 +1,19 @@
+package kafka
+
+type kError int16
+
+const (
+	NO_ERROR                    kError = 0
+	UNKNOWN                            = -1
+	OFFSET_OUT_OF_RANGE                = 1
+	INVALID_MESSAGE                    = 2
+	UNKNOWN_TOPIC_OR_PARTITION         = 3
+	INVALID_MESSAGE_SIZE               = 4
+	LEADER_NOT_AVAILABLE               = 5
+	NOT_LEADER_FOR_PARTITION           = 6
+	REQUEST_TIMED_OUT                  = 7
+	BROKER_NOT_AVAILABLE               = 8
+	REPLICA_NOT_AVAILABLE              = 9
+	MESSAGE_SIZE_TOO_LARGE             = 10
+	STALE_CONTROLLER_EPOCH_CODE        = 11
+)

+ 1 - 1
packetDecoder.go

@@ -3,7 +3,7 @@ package kafka
 type packetDecoder interface {
 	getInt16() (int16, error)
 	getInt32() (int32, error)
-	getError() (kafkaError, error)
+	getError() (kError, error)
 	getString() (*string, error)
 	getBytes() (*[]byte, error)
 	getArrayCount() (int, error)

+ 1 - 1
packetEncoder.go

@@ -3,7 +3,7 @@ package kafka
 type packetEncoder interface {
 	putInt16(in int16)
 	putInt32(in int32)
-	putError(in kafkaError)
+	putError(in kError)
 	putString(in *string)
 	putBytes(in *[]byte)
 	putArrayCount(in int)

+ 1 - 1
partitionMetadata.go

@@ -1,7 +1,7 @@
 package kafka
 
 type partitionMetadata struct {
-	err      kafkaError
+	err      kError
 	id       int32
 	leader   int32
 	replicas []int32

+ 1 - 1
prepEncoder.go

@@ -15,7 +15,7 @@ func (pe *prepEncoder) putInt32(in int32) {
 	pe.length += 4
 }
 
-func (pe *prepEncoder) putError(in kafkaError) {
+func (pe *prepEncoder) putError(in kError) {
 	pe.length += 2
 }
 

+ 2 - 2
realDecoder.go

@@ -33,9 +33,9 @@ func (rd *realDecoder) getInt32() (int32, error) {
 	return tmp, nil
 }
 
-func (rd *realDecoder) getError() (kafkaError, error) {
+func (rd *realDecoder) getError() (kError, error) {
 	val, err := rd.getInt16()
-	return kafkaError(val), err
+	return kError(val), err
 }
 
 func (rd *realDecoder) getString() (*string, error) {

+ 1 - 1
realEncoder.go

@@ -17,7 +17,7 @@ func (re *realEncoder) putInt32(in int32) {
 	re.off += 4
 }
 
-func (re *realEncoder) putError(in kafkaError) {
+func (re *realEncoder) putError(in kError) {
 	re.putInt16(int16(in))
 }
 

+ 1 - 1
topicMetadata.go

@@ -1,7 +1,7 @@
 package kafka
 
 type topicMetadata struct {
-	err        kafkaError
+	err        kError
 	name       *string
 	partitions []partitionMetadata
 }