mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-07-28 06:11:59 +08:00

* feat(license): base setup for license service * feat(license): delete old manager and import to new * feat(license): deal with features * feat(license): complete the license service in ee * feat(license): add sqlmigration for licenses * feat(license): remove feature flags * feat(license): refactor into provider pattern * feat(license): remove the ff lookup interface * feat(license): add logging to the validator functions * feat(license): implement features for OSS build * feat(license): fix the OSS build * feat(license): lets blast frontend * feat(license): fix the EE OSS build without license * feat(license): remove the hardcoded testing configs * feat(license): upgrade migration to 34 * feat(license): better naming and structure * feat(license): better naming and structure * feat(license): better naming and structure * feat(license): better naming and structure * feat(license): better naming and structure * feat(license): better naming and structure * feat(license): better naming and structure * feat(license): integration tests * feat(license): integration tests * feat(license): refactor frontend * feat(license): make frontend api structure changes * feat(license): fix integration tests * feat(license): revert hardcoded configs * feat(license): fix integration tests * feat(license): address review comments * feat(license): address review comments * feat(license): address review comments * feat(license): address review comments * feat(license): update migration * feat(license): update migration * feat(license): update migration * feat(license): fixed logging * feat(license): use the unmarshaller for postable subscription * feat(license): correct the error message * feat(license): fix license test * feat(license): fix lint issues * feat(user): do not kill the service if upstream is down
56 lines
2.3 KiB
Go
56 lines
2.3 KiB
Go
package licensing
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
|
|
"github.com/SigNoz/signoz/pkg/errors"
|
|
"github.com/SigNoz/signoz/pkg/factory"
|
|
"github.com/SigNoz/signoz/pkg/types/featuretypes"
|
|
"github.com/SigNoz/signoz/pkg/types/licensetypes"
|
|
"github.com/SigNoz/signoz/pkg/valuer"
|
|
)
|
|
|
|
var (
|
|
ErrCodeUnsupported = errors.MustNewCode("licensing_unsupported")
|
|
ErrCodeFeatureUnavailable = errors.MustNewCode("feature_unavailable")
|
|
)
|
|
|
|
type Licensing interface {
|
|
factory.Service
|
|
|
|
// Validate validates the license with the upstream server
|
|
Validate(ctx context.Context) error
|
|
// Activate validates and enables the license
|
|
Activate(ctx context.Context, organizationID valuer.UUID, key string) error
|
|
// GetActive fetches the current active license in org
|
|
GetActive(ctx context.Context, organizationID valuer.UUID) (*licensetypes.License, error)
|
|
// Refresh refreshes the license state from upstream server
|
|
Refresh(ctx context.Context, organizationID valuer.UUID) error
|
|
// Checkout creates a checkout session via upstream server and returns the redirection link
|
|
Checkout(ctx context.Context, organizationID valuer.UUID, postableSubscription *licensetypes.PostableSubscription) (*licensetypes.GettableSubscription, error)
|
|
// Portal creates a portal session via upstream server and return the redirection link
|
|
Portal(ctx context.Context, organizationID valuer.UUID, postableSubscription *licensetypes.PostableSubscription) (*licensetypes.GettableSubscription, error)
|
|
|
|
// feature surrogate
|
|
// CheckFeature checks if the feature is active or not
|
|
CheckFeature(ctx context.Context, key string) error
|
|
// GetFeatureFlags fetches all the defined feature flags
|
|
GetFeatureFlag(ctx context.Context, key string) (*featuretypes.GettableFeature, error)
|
|
// GetFeatureFlags fetches all the defined feature flags
|
|
GetFeatureFlags(ctx context.Context) ([]*featuretypes.GettableFeature, error)
|
|
// InitFeatures initialises the feature flags
|
|
InitFeatures(ctx context.Context, features []*featuretypes.GettableFeature) error
|
|
// UpdateFeatureFlag updates the feature flag
|
|
UpdateFeatureFlag(ctx context.Context, feature *featuretypes.GettableFeature) error
|
|
}
|
|
|
|
type API interface {
|
|
Activate(http.ResponseWriter, *http.Request)
|
|
Refresh(http.ResponseWriter, *http.Request)
|
|
GetActive(http.ResponseWriter, *http.Request)
|
|
|
|
Checkout(http.ResponseWriter, *http.Request)
|
|
Portal(http.ResponseWriter, *http.Request)
|
|
}
|