-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'v2' into keremcankabadayi/v2
# Conflicts: # consumer_base.go
- Loading branch information
Showing
19 changed files
with
538 additions
and
108 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
Oops, something went wrong.