Skip to content

Commit

Permalink
remove individual Locality properties.
Browse files Browse the repository at this point in the history
Signed-off-by: eapolinario <[email protected]>
  • Loading branch information
eapolinario committed Sep 11, 2020
1 parent 85ba9aa commit 3155439
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 47 deletions.
4 changes: 1 addition & 3 deletions internal/app/transport/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ type RequestVersion struct {
V3 *discoveryv3.DiscoveryRequest
}

// Locality is an interface to abstract the differences between the v2 and v3 Locality type
type Locality struct {
Region string
Zone string
Expand All @@ -28,9 +29,6 @@ type Request interface {
GetNodeMetadata() *structpb.Struct
GetCluster() string
GetError() *status.Status
GetRegion() string
GetZone() string
GetSubZone() string
GetLocality() *Locality
GetResponseNonce() string
GetRaw() *RequestVersion
Expand Down
16 changes: 2 additions & 14 deletions internal/app/transport/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,22 +103,10 @@ func TestGetError(t *testing.T) {
assert.Equal(t, requestv2.GetError(), requestv3.GetError())
}

func TestGetRegion(t *testing.T) {
func TestGetLocality(t *testing.T) {
requestv2 := NewRequestV2(&requestV2)
requestv3 := NewRequestV3(&requestV3)
assert.Equal(t, requestv2.GetRegion(), requestv3.GetRegion())
}

func TestGetZone(t *testing.T) {
requestv2 := NewRequestV2(&requestV2)
requestv3 := NewRequestV3(&requestV3)
assert.Equal(t, requestv2.GetZone(), requestv3.GetZone())
}

func TestGetSubZone(t *testing.T) {
requestv2 := NewRequestV2(&requestV2)
requestv3 := NewRequestV3(&requestV3)
assert.Equal(t, requestv2.GetSubZone(), requestv3.GetSubZone())
assert.Equal(t, requestv2.GetLocality(), requestv3.GetLocality())
}

func TestGetResponseNonce(t *testing.T) {
Expand Down
15 changes: 0 additions & 15 deletions internal/app/transport/requestv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,6 @@ func (r *RequestV2) GetTypeURL() string {
return r.r.GetTypeUrl()
}

// GetRegion gets the error details
func (r *RequestV2) GetRegion() string {
return r.r.GetNode().GetLocality().GetRegion()
}

// GetZone gets the error details
func (r *RequestV2) GetZone() string {
return r.r.GetNode().GetLocality().GetZone()
}

// GetSubZone gets the error details
func (r *RequestV2) GetSubZone() string {
return r.r.GetNode().GetLocality().GetSubZone()
}

// GetLocality gets the node locality
func (r *RequestV2) GetLocality() *Locality {
locality := r.r.GetNode().GetLocality()
Expand Down
15 changes: 0 additions & 15 deletions internal/app/transport/requestv3.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,6 @@ func (r *RequestV3) GetTypeURL() string {
return r.r.GetTypeUrl()
}

// GetRegion gets the error details
func (r *RequestV3) GetRegion() string {
return r.r.GetNode().GetLocality().GetRegion()
}

// GetZone gets the error details
func (r *RequestV3) GetZone() string {
return r.r.GetNode().GetLocality().GetZone()
}

// GetSubZone gets the error details
func (r *RequestV3) GetSubZone() string {
return r.r.GetNode().GetLocality().GetSubZone()
}

// GetLocality gets the node locality
func (r *RequestV3) GetLocality() *Locality {
locality := r.r.GetNode().GetLocality()
Expand Down

0 comments on commit 3155439

Please sign in to comment.