Merge branch 'master' of ssh://github.com/micro/go-micro
This commit is contained in:
		| @@ -8,10 +8,7 @@ import ( | |||||||
|  |  | ||||||
| type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error) | type BackoffFunc func(ctx context.Context, req Request, attempts int) (time.Duration, error) | ||||||
|  |  | ||||||
| // exponential backoff | // 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) { | func exponentialBackoff(ctx context.Context, req Request, attempts int) (time.Duration, error) { | ||||||
| 	if attempts == 0 { | 	return time.Duration(math.Pow(float64(attempts), math.E)) * time.Millisecond * 100, nil | ||||||
| 		return time.Duration(0), nil |  | ||||||
| 	} |  | ||||||
| 	return time.Duration(math.Pow(10, float64(attempts))) * time.Millisecond, nil |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,13 +2,19 @@ package client | |||||||
|  |  | ||||||
| import ( | import ( | ||||||
| 	"context" | 	"context" | ||||||
| 	"math" |  | ||||||
| 	"testing" | 	"testing" | ||||||
| 	"time" | 	"time" | ||||||
| ) | ) | ||||||
|  |  | ||||||
| func TestBackoff(t *testing.T) { | 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() | 	c := NewClient() | ||||||
|  |  | ||||||
| @@ -18,10 +24,8 @@ func TestBackoff(t *testing.T) { | |||||||
| 			t.Fatal(err) | 			t.Fatal(err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if d < delta { | 		if d != results[i] { | ||||||
| 			t.Fatalf("Expected greater than %v, got %v", delta, d) | 			t.Fatalf("Expected equal than %v, got %v", results[i], d) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		delta = time.Millisecond * time.Duration(math.Pow(10, float64(i+1))) |  | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|   | |||||||
| @@ -271,12 +271,6 @@ func (k *kubernetes) Create(s *runtime.Service, opts ...runtime.CreateOption) er | |||||||
| 		options.Type = k.options.Type | 		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 | 	// create new kubernetes micro service | ||||||
| 	service := newService(s, options) | 	service := newService(s, options) | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user