1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-14 02:33:03 +02:00

fix:(transport/http): fix unexpected overriding behavior when return an error (#1984)

* fix:(transport/http): fix unexpected overriding behavior when return an error

* fix:(transport/http): fix broken tests

Co-authored-by: pwli0755 <lipw0755@gmial.com>
This commit is contained in:
pwli 2022-05-19 22:43:53 +08:00 committed by GitHub
parent 0d9319b1ee
commit f0a058713f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 7 deletions

View File

@ -79,17 +79,17 @@ func newResolver(ctx context.Context, discovery registry.Discovery, target *Targ
select {
case err := <-done:
if err != nil {
err := watcher.Stop()
if err != nil {
r.logger.Errorf("failed to http client watch stop: %v", target)
stopErr := watcher.Stop()
if stopErr != nil {
r.logger.Errorf("failed to http client watch stop: %v, error: %+v", target, stopErr)
}
return nil, err
}
case <-ctx.Done():
r.logger.Errorf("http client watch service %v reaching context deadline!", target)
err := watcher.Stop()
if err != nil {
r.logger.Errorf("failed to http client watch stop: %v", target)
stopErr := watcher.Stop()
if stopErr != nil {
r.logger.Errorf("failed to http client watch stop: %v, error: %+v", target, stopErr)
}
return nil, ctx.Err()
}

View File

@ -77,10 +77,10 @@ type mockWatch struct {
}
func (m *mockWatch) Next() ([]*registry.ServiceInstance, error) {
m.count++
if m.count == 1 {
return nil, errors.New("mock test error")
}
m.count++
instance := &registry.ServiceInstance{
ID: "1",
Name: "kratos",