initSDK creates the SDK client, bridging the CLI's auth and config.
(authMgr *auth.Manager, baseURL string)
| 58 | |
| 59 | // initSDK creates the SDK client, bridging the CLI's auth and config. |
| 60 | func initSDK(authMgr *auth.Manager, baseURL string) { |
| 61 | sdkCfg := &hey.Config{ |
| 62 | BaseURL: baseURL, |
| 63 | CacheEnabled: false, |
| 64 | } |
| 65 | |
| 66 | var opts []hey.ClientOption |
| 67 | opts = append(opts, hey.WithAuthStrategy(&cliAuthStrategy{mgr: authMgr})) |
| 68 | opts = append(opts, hey.WithUserAgent(version.UserAgent()+" "+hey.DefaultUserAgent)) |
| 69 | |
| 70 | if verboseFlag > 0 { |
| 71 | opts = append(opts, hey.WithLogger(slog.New(slog.NewTextHandler(os.Stderr, &slog.HandlerOptions{Level: slog.LevelDebug})))) |
| 72 | } |
| 73 | |
| 74 | sdkStats = &statsHooks{} |
| 75 | opts = append(opts, hey.WithHooks(sdkStats)) |
| 76 | |
| 77 | sdk = hey.NewClient(sdkCfg, nil, opts...) |
| 78 | } |
| 79 | |
| 80 | // convertSDKError maps hey.Error to apierr.Error for CLI error display. |
| 81 | func convertSDKError(err error) error { |
no test coverage detected