-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enable balancer support to the retry configuration (#123)
* feat: enable balancer support to the retry configuration * chore: add balancer tests --------- Co-authored-by: Abdulsametileri <sametileri07@gmail.com>
- Loading branch information
1 parent
f9bc1d6
commit ac1f317
Showing
8 changed files
with
108 additions
and
4 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
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,29 @@ | ||
package kafka | ||
|
||
import "github.com/segmentio/kafka-go" | ||
|
||
type Balancer kafka.Balancer | ||
|
||
func GetBalancerCRC32() Balancer { | ||
return &kafka.CRC32Balancer{} | ||
} | ||
|
||
func GetBalancerHash() Balancer { | ||
return &kafka.Hash{} | ||
} | ||
|
||
func GetBalancerLeastBytes() Balancer { | ||
return &kafka.LeastBytes{} | ||
} | ||
|
||
func GetBalancerMurmur2Balancer() Balancer { | ||
return &kafka.Murmur2Balancer{} | ||
} | ||
|
||
func GetBalancerReferenceHash() Balancer { | ||
return &kafka.ReferenceHash{} | ||
} | ||
|
||
func GetBalancerRoundRobin() Balancer { | ||
return &kafka.RoundRobin{} | ||
} |
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,66 @@ | ||
package kafka | ||
|
||
import ( | ||
"reflect" | ||
"testing" | ||
) | ||
|
||
func TestGetBalancerCRC32(t *testing.T) { | ||
balancer := GetBalancerCRC32() | ||
if balancer == nil { | ||
t.Error("Expected non-nil balancer, got nil") | ||
} | ||
if reflect.TypeOf(balancer).String() != "*kafka.CRC32Balancer" { | ||
t.Errorf("Expected *kafka.CRC32Balancer, got %s", reflect.TypeOf(balancer).String()) | ||
} | ||
} | ||
|
||
func TestGetBalancerHash(t *testing.T) { | ||
balancer := GetBalancerHash() | ||
if balancer == nil { | ||
t.Error("Expected non-nil balancer, got nil") | ||
} | ||
if reflect.TypeOf(balancer).String() != "*kafka.Hash" { | ||
t.Errorf("Expected *kafka.Hash, got %s", reflect.TypeOf(balancer).String()) | ||
} | ||
} | ||
|
||
func TestGetBalancerLeastBytes(t *testing.T) { | ||
balancer := GetBalancerLeastBytes() | ||
if balancer == nil { | ||
t.Error("Expected non-nil balancer, got nil") | ||
} | ||
if reflect.TypeOf(balancer).String() != "*kafka.LeastBytes" { | ||
t.Errorf("Expected *kafka.LeastBytes, got %s", reflect.TypeOf(balancer).String()) | ||
} | ||
} | ||
|
||
func TestGetBalancerMurmur2Balancer(t *testing.T) { | ||
balancer := GetBalancerMurmur2Balancer() | ||
if balancer == nil { | ||
t.Error("Expected non-nil balancer, got nil") | ||
} | ||
if reflect.TypeOf(balancer).String() != "*kafka.Murmur2Balancer" { | ||
t.Errorf("Expected *kafka.Murmur2Balancer, got %s", reflect.TypeOf(balancer).String()) | ||
} | ||
} | ||
|
||
func TestGetBalancerReferenceHash(t *testing.T) { | ||
balancer := GetBalancerReferenceHash() | ||
if balancer == nil { | ||
t.Error("Expected non-nil balancer, got nil") | ||
} | ||
if reflect.TypeOf(balancer).String() != "*kafka.ReferenceHash" { | ||
t.Errorf("Expected *kafka.ReferenceHash, got %s", reflect.TypeOf(balancer).String()) | ||
} | ||
} | ||
|
||
func TestGetBalancerRoundRobinh(t *testing.T) { | ||
balancer := GetBalancerRoundRobin() | ||
if balancer == nil { | ||
t.Error("Expected non-nil balancer, got nil") | ||
} | ||
if reflect.TypeOf(balancer).String() != "*kafka.RoundRobin" { | ||
t.Errorf("Expected *kafka.RoundRobin, got %s", reflect.TypeOf(balancer).String()) | ||
} | ||
} |
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