Skip to content

Commit

Permalink
Update README.md for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiyukiMineo committed Apr 30, 2024
1 parent 01b4fe0 commit 296b8f1
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,37 +95,28 @@ Example
-------

```go
import (
"fmt"
"io"
"log"
"net/http"

"github.com/sony/gobreaker/v2"
)

var cb *gobreaker.CircuitBreaker[[]byte]

func Get(url string) ([]byte, error) {
body, err := cb.Execute(func() ([]byte, error) {
resp, err := http.Get(url)
if err != nil {
return nil, err
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
return body, nil
})
if err != nil {
return nil, err
}
return body, nil
body, err := cb.Execute(func() ([]byte, error) {
resp, err := http.Get(url)
if err != nil {
return nil, err
}

defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

return body, nil
})
if err != nil {
return nil, err
}

return body, nil
}
```

Expand Down

0 comments on commit 296b8f1

Please sign in to comment.