MCPcopy Index your code
hub / github.com/bytebase/bytebase / start

Method start

backend/tests/tests.go:259–323  ·  view source on GitHub ↗

start only called by StartServer() and StartServerWithExternalPg().

(ctx context.Context, port int)

Source from the content-addressed store, hash-verified

257
258// start only called by StartServer() and StartServerWithExternalPg().
259func (ctl *controller) start(ctx context.Context, port int) (context.Context, error) {
260 ctl.rootURL = fmt.Sprintf("http://localhost:%d", port)
261 ctl.apiURL = fmt.Sprintf("http://localhost:%d/api", port)
262 ctl.v1APIURL = fmt.Sprintf("http://localhost:%d/v1", port)
263
264 errChan := make(chan error, 1)
265
266 go func() {
267 if err := ctl.server.Run(ctx, port); err != nil {
268 errChan <- errors.Wrap(err, "failed to run main server")
269 }
270 }()
271
272 // initialize controller clients.
273 ctl.client = &http.Client{
274 Transport: &http2.Transport{
275 AllowHTTP: true,
276 DialTLSContext: func(_ context.Context, network, addr string, _ *tls.Config) (net.Conn, error) {
277 return net.Dial(network, addr)
278 },
279 },
280 }
281
282 ctl.authInterceptor = &authInterceptor{}
283 interceptors := connect.WithInterceptors(ctl.authInterceptor)
284
285 baseURL := "http://localhost:" + fmt.Sprintf("%d", port)
286 ctl.issueServiceClient = v1connect.NewIssueServiceClient(ctl.client, baseURL, interceptors)
287 ctl.rolloutServiceClient = v1connect.NewRolloutServiceClient(ctl.client, baseURL, interceptors)
288 ctl.planServiceClient = v1connect.NewPlanServiceClient(ctl.client, baseURL, interceptors)
289 ctl.roleServiceClient = v1connect.NewRoleServiceClient(ctl.client, baseURL, interceptors)
290 ctl.orgPolicyServiceClient = v1connect.NewOrgPolicyServiceClient(ctl.client, baseURL, interceptors)
291 ctl.reviewConfigServiceClient = v1connect.NewReviewConfigServiceClient(ctl.client, baseURL, interceptors)
292 ctl.projectServiceClient = v1connect.NewProjectServiceClient(ctl.client, baseURL, interceptors)
293 ctl.databaseGroupServiceClient = v1connect.NewDatabaseGroupServiceClient(ctl.client, baseURL, interceptors)
294 ctl.authServiceClient = v1connect.NewAuthServiceClient(ctl.client, baseURL, interceptors)
295 ctl.userServiceClient = v1connect.NewUserServiceClient(ctl.client, baseURL, interceptors)
296 ctl.settingServiceClient = v1connect.NewSettingServiceClient(ctl.client, baseURL, interceptors)
297 ctl.instanceServiceClient = v1connect.NewInstanceServiceClient(ctl.client, baseURL, interceptors)
298 ctl.databaseServiceClient = v1connect.NewDatabaseServiceClient(ctl.client, baseURL, interceptors)
299 ctl.databaseCatalogServiceClient = v1connect.NewDatabaseCatalogServiceClient(ctl.client, baseURL, interceptors)
300 ctl.sheetServiceClient = v1connect.NewSheetServiceClient(ctl.client, baseURL, interceptors)
301 ctl.sqlServiceClient = v1connect.NewSQLServiceClient(ctl.client, baseURL, interceptors)
302 ctl.subscriptionServiceClient = v1connect.NewSubscriptionServiceClient(ctl.client, baseURL, interceptors)
303 ctl.actuatorServiceClient = v1connect.NewActuatorServiceClient(ctl.client, baseURL, interceptors)
304 ctl.workspaceServiceClient = v1connect.NewWorkspaceServiceClient(ctl.client, baseURL, interceptors)
305 ctl.releaseServiceClient = v1connect.NewReleaseServiceClient(ctl.client, baseURL, interceptors)
306 ctl.revisionServiceClient = v1connect.NewRevisionServiceClient(ctl.client, baseURL, interceptors)
307 ctl.groupServiceClient = v1connect.NewGroupServiceClient(ctl.client, baseURL, interceptors)
308 ctl.auditLogServiceClient = v1connect.NewAuditLogServiceClient(ctl.client, baseURL, interceptors)
309 ctl.serviceAccountServiceClient = v1connect.NewServiceAccountServiceClient(ctl.client, baseURL, interceptors)
310 ctl.workloadIdentityServiceClient = v1connect.NewWorkloadIdentityServiceClient(ctl.client, baseURL, interceptors)
311 ctl.accessGrantServiceClient = v1connect.NewAccessGrantServiceClient(ctl.client, baseURL, interceptors)
312
313 if err := ctl.waitForHealthz(ctx); err != nil {
314 return nil, errors.Wrap(err, "failed to wait for healthz")
315 }
316 authToken, err := ctl.signupAndLogin(ctx)

Callers 4

qp.min.jsFile · 0.80
initializeRunnerFunction · 0.80
bindStreamingLogicFunction · 0.80

Calls 15

waitForHealthzMethod · 0.95
signupAndLoginMethod · 0.95
NewIssueServiceClientFunction · 0.92
NewRolloutServiceClientFunction · 0.92
NewPlanServiceClientFunction · 0.92
NewRoleServiceClientFunction · 0.92
NewProjectServiceClientFunction · 0.92
NewAuthServiceClientFunction · 0.92
NewUserServiceClientFunction · 0.92

Tested by

no test coverage detected