| 161 | } |
| 162 | |
| 163 | func Run(ctx context.Context, opts *ReportOptions) *healthsdk.HealthcheckReport { |
| 164 | var ( |
| 165 | wg sync.WaitGroup |
| 166 | report healthsdk.HealthcheckReport |
| 167 | ) |
| 168 | |
| 169 | if opts.Checker == nil { |
| 170 | opts.Checker = defaultChecker{} |
| 171 | } |
| 172 | |
| 173 | wg.Add(1) |
| 174 | go func() { |
| 175 | defer wg.Done() |
| 176 | defer func() { |
| 177 | if err := recover(); err != nil { |
| 178 | report.DERP.Error = health.Errorf(health.CodeUnknown, "derp report panic: %s", err) |
| 179 | } |
| 180 | }() |
| 181 | |
| 182 | if opts.Progress != nil { |
| 183 | opts.Progress.Start("DERP") |
| 184 | defer opts.Progress.Complete("DERP") |
| 185 | } |
| 186 | report.DERP = opts.Checker.DERP(ctx, &opts.DerpHealth) |
| 187 | }() |
| 188 | |
| 189 | wg.Add(1) |
| 190 | go func() { |
| 191 | defer wg.Done() |
| 192 | defer func() { |
| 193 | if err := recover(); err != nil { |
| 194 | report.AccessURL.Error = health.Errorf(health.CodeUnknown, "access url report panic: %s", err) |
| 195 | } |
| 196 | }() |
| 197 | |
| 198 | if opts.Progress != nil { |
| 199 | opts.Progress.Start("AccessURL") |
| 200 | defer opts.Progress.Complete("AccessURL") |
| 201 | } |
| 202 | report.AccessURL = opts.Checker.AccessURL(ctx, &opts.AccessURL) |
| 203 | }() |
| 204 | |
| 205 | wg.Add(1) |
| 206 | go func() { |
| 207 | defer wg.Done() |
| 208 | defer func() { |
| 209 | if err := recover(); err != nil { |
| 210 | report.Websocket.Error = health.Errorf(health.CodeUnknown, "websocket report panic: %s", err) |
| 211 | } |
| 212 | }() |
| 213 | |
| 214 | if opts.Progress != nil { |
| 215 | opts.Progress.Start("Websocket") |
| 216 | defer opts.Progress.Complete("Websocket") |
| 217 | } |
| 218 | report.Websocket = opts.Checker.Websocket(ctx, &opts.Websocket) |
| 219 | }() |
| 220 | |