MCPcopy Create free account
hub / github.com/bytebase/bytebase / checkActivationLimit

Method checkActivationLimit

backend/api/v1/instance_service.go:399–412  ·  view source on GitHub ↗
(ctx context.Context, workspaceID string, activating bool)

Source from the content-addressed store, hash-verified

397const instanceExceededError = "activation instance count has reached the limit (%v)"
398
399func (s *InstanceService) checkActivationLimit(ctx context.Context, workspaceID string, activating bool) error {
400 if !activating || s.licenseService.IsUnifiedInstanceLicense(ctx, workspaceID) {
401 return nil
402 }
403 activatedInstanceLimit := s.licenseService.GetActivatedInstanceLimit(ctx, workspaceID)
404 count, err := s.store.GetActivatedInstanceCount(ctx, workspaceID)
405 if err != nil {
406 return connect.NewError(connect.CodeInternal, err)
407 }
408 if count >= activatedInstanceLimit {
409 return connect.NewError(connect.CodeResourceExhausted, errors.Errorf(instanceExceededError, activatedInstanceLimit))
410 }
411 return nil
412}
413
414func (s *InstanceService) checkDataSource(ctx context.Context, instance *store.InstanceMessage, dataSource *storepb.DataSource) error {
415 if dataSource.GetId() == "" {

Callers 2

CreateInstanceMethod · 0.95
UpdateInstanceMethod · 0.95

Calls 4

ErrorfMethod · 0.80

Tested by

no test coverage detected