Skip to content

Commit f724615

Browse files
authored
Update README.md
1 parent 414e41c commit f724615

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎README.md‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ for _, task := range p.Tasks {
157157
**Health Checker Component**
158158
159159
```golang
160+
import "fmt"
161+
160162
healthChecker := hippo.NewHealthChecker()
161163
healthChecker.AddCheck("ping_check", func() (bool, error){
162164
return true, nil
@@ -171,6 +173,24 @@ fmt.Println(healthChecker.ChecksStatus())
171173
fmt.Println(healthChecker.ChecksReport())
172174
// Output -> [{"id":"ping_check","status":"UP","error":"","result":true},{"id":"db_check","status":"DOWN","error":"Database Down","result":false}]
173175
```
176+
```golang
177+
import "fmt"
178+
179+
healthChecker := hippo.NewHealthChecker()
180+
181+
healthChecker.AddCheck("url_check", func() (bool, error){
182+
return hippo.HTTPCheck("httpbin_service", "https://httpbin.org/status/503", map[string]string{}, map[string]string{})
183+
})
184+
healthChecker.AddCheck("redis_check", func() (bool, error){
185+
return hippo.RedisCheck("redis_service", "localhost:6379", "", 0)
186+
})
187+
healthChecker.RunChecks()
188+
189+
fmt.Println(healthChecker.ChecksStatus())
190+
// Outputs -> DOWN
191+
fmt.Println(healthChecker.ChecksReport())
192+
// Outputs -> [{"id":"url_check","status":"DOWN","error":"Service httpbin_service is unavailable","result":false},{"id":"redis_check","status":"DOWN","error":"Error while connecting redis_service: dial tcp [::1]:6379: connect: connection refused","result":false}]
193+
```
174194

175195
## Versioning
176196

0 commit comments

Comments
 (0)