From f6fcfcb8fc18d2533328c095025a355b8add8121 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Thu, 30 Jan 2020 17:25:07 +0300 Subject: [PATCH 1/4] exponentialBackoff was changed from power function to exponential function --- client/backoff.go | 7 ++----- client/backoff_test.go | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/client/backoff.go b/client/backoff.go index 57407a06..4a7e3746 100644 --- a/client/backoff.go +++ b/client/backoff.go @@ -8,10 +8,7 @@ import ( type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error) -// exponential backoff +// exponential backoff multiplied by a factor of 0.1 second. func exponentialBackoff(ctx context.Context, req Request, attempts int) (time.Duration, error) { - if attempts == 0 { - return time.Duration(0), nil - } - return time.Duration(math.Pow(10, float64(attempts))) * time.Millisecond, nil + return time.Duration(math.Pow(float64(attempts), math.E)) * time.Millisecond * 100, nil } diff --git a/client/backoff_test.go b/client/backoff_test.go index 60ae19aa..a6d39dee 100644 --- a/client/backoff_test.go +++ b/client/backoff_test.go @@ -22,6 +22,6 @@ func TestBackoff(t *testing.T) { t.Fatalf("Expected greater than %v, got %v", delta, d) } - delta = time.Millisecond * time.Duration(math.Pow(10, float64(i+1))) + delta = time.Millisecond * 100 * time.Duration(math.Pow(math.E, float64(i))) } } From ffb9da0230d3d1df677504466126570c39ef2bec Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Thu, 30 Jan 2020 19:43:03 +0300 Subject: [PATCH 2/4] fix test and description --- client/backoff.go | 2 +- client/backoff_test.go | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/client/backoff.go b/client/backoff.go index 4a7e3746..70070da2 100644 --- a/client/backoff.go +++ b/client/backoff.go @@ -8,7 +8,7 @@ import ( type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error) -// exponential backoff multiplied by a factor of 0.1 second. +// exponential backoff is a function x^e multiplied by a factor of 0.1 second. func exponentialBackoff(ctx context.Context, req Request, attempts int) (time.Duration, error) { return time.Duration(math.Pow(float64(attempts), math.E)) * time.Millisecond * 100, nil } diff --git a/client/backoff_test.go b/client/backoff_test.go index a6d39dee..75963cbf 100644 --- a/client/backoff_test.go +++ b/client/backoff_test.go @@ -2,13 +2,12 @@ package client import ( "context" - "math" "testing" "time" ) func TestBackoff(t *testing.T) { - delta := time.Duration(0) + results := []time.Duration{0 * time.Second, 100 * time.Millisecond, 600 * time.Millisecond, 1900 * time.Millisecond, 4300 * time.Millisecond, 7900 * time.Millisecond} c := NewClient() @@ -18,10 +17,8 @@ func TestBackoff(t *testing.T) { t.Fatal(err) } - if d < delta { - t.Fatalf("Expected greater than %v, got %v", delta, d) + if d != results[i] { + t.Fatalf("Expected equal than %v, got %v", results[i], d) } - - delta = time.Millisecond * 100 * time.Duration(math.Pow(math.E, float64(i))) } } From 87753ad28953cc1635f734edaf61006f18442fe2 Mon Sep 17 00:00:00 2001 From: Evgeniy Date: Thu, 30 Jan 2020 20:08:03 +0300 Subject: [PATCH 3/4] format results in TestBacloff --- client/backoff_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/backoff_test.go b/client/backoff_test.go index 75963cbf..7e1e1990 100644 --- a/client/backoff_test.go +++ b/client/backoff_test.go @@ -7,7 +7,14 @@ import ( ) func TestBackoff(t *testing.T) { - results := []time.Duration{0 * time.Second, 100 * time.Millisecond, 600 * time.Millisecond, 1900 * time.Millisecond, 4300 * time.Millisecond, 7900 * time.Millisecond} + results := []time.Duration{ + 0 * time.Second, + 100 * time.Millisecond, + 600 * time.Millisecond, + 1900 * time.Millisecond, + 4300 * time.Millisecond, + 7900 * time.Millisecond, + } c := NewClient() From 98d55545fd31e78b8633a0248a0e7cb6c159f7b2 Mon Sep 17 00:00:00 2001 From: Lars Lehtonen Date: Thu, 30 Jan 2020 09:25:50 -0800 Subject: [PATCH 4/4] runtime/kubernetes: remove unused name variable --- runtime/kubernetes/kubernetes.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/runtime/kubernetes/kubernetes.go b/runtime/kubernetes/kubernetes.go index 3545967b..f24843b0 100644 --- a/runtime/kubernetes/kubernetes.go +++ b/runtime/kubernetes/kubernetes.go @@ -271,12 +271,6 @@ func (k *kubernetes) Create(s *runtime.Service, opts ...runtime.CreateOption) er options.Type = k.options.Type } - // quickly prevalidate the name and version - name := s.Name - if len(s.Version) > 0 { - name = name + "-" + s.Version - } - // create new kubernetes micro service service := newService(s, options)