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

Method IsFeatureEnabledForInstance

backend/enterprise/license.go:301–318  ·  view source on GitHub ↗

IsFeatureEnabledForInstance returns whether a feature is enabled for the instance.

(ctx context.Context, workspaceID string, f v1pb.PlanFeature, instance *store.InstanceMessage)

Source from the content-addressed store, hash-verified

299
300// IsFeatureEnabledForInstance returns whether a feature is enabled for the instance.
301func (s *LicenseService) IsFeatureEnabledForInstance(ctx context.Context, workspaceID string, f v1pb.PlanFeature, instance *store.InstanceMessage) error {
302 plan := s.GetEffectivePlan(ctx, workspaceID)
303 // DO NOT check instance license fo FREE plan.
304 if plan == v1pb.PlanType_FREE {
305 return s.IsFeatureEnabled(ctx, workspaceID, f)
306 }
307 if err := s.IsFeatureEnabled(ctx, workspaceID, f); err != nil {
308 return err
309 }
310 if !s.IsInstanceEffectivelyActivated(ctx, workspaceID, instance) {
311 instanceID := ""
312 if instance != nil {
313 instanceID = instance.ResourceID
314 }
315 return errors.Errorf(`feature "%s" requires an activated instance under the current license: %s`, f.String(), instanceID)
316 }
317 return nil
318}
319
320// GetUserLimit gets the user limit value for the plan.
321func (s *LicenseService) GetUserLimit(ctx context.Context, workspaceID string) int {

Callers 10

GetDataSourceDriverMethod · 0.80
queryRetryFunction · 0.80
doExportFunction · 0.80
checkDataSourceMethod · 0.80
UpdateInstanceMethod · 0.80
AddDataSourceMethod · 0.80
UpdateDataSourceMethod · 0.80

Calls 5

GetEffectivePlanMethod · 0.95
IsFeatureEnabledMethod · 0.95
ErrorfMethod · 0.80
StringMethod · 0.65