provider

package
v0.0.0-...-3700556 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFetchFlagDetails = status.Error(
	codes.Internal,
	"error occurred while fetching flag details",
)

ErrFetchFlagDetails is a GRPC error that is returned when an unknown error occurs while fetching flag details.

View Source
var ErrIncorrectFlagDetailCount = status.Error(
	codes.Internal,
	"an unexpected number of flags were found",
)

ErrIncorrectFlagDetailCount is a GRPC error that is returned when the number of flag details does not match the expected count.

View Source
var ErrStatusCache = status.Error(
	codes.Internal,
	"error occurred while checking flag status cache",
)

ErrStatusCache is a GRPC error that is returned when an error has occurred while checking the cache for the flag status.

Functions

This section is empty.

Types

type CacheRepository

type CacheRepository interface {
	// IsStatusCached checks if the flag status is already cached
	IsFlagStatusCached(
		ctx context.Context,
		params *cacheParameters,
	) (bool, error)

	// GetFlagStatus gets the currently cached value of the flag status.
	GetFlagStatus(ctx context.Context, params *cacheParameters) (bool, error)

	// CacheFlagStatus caches the value of the flag status.
	CacheFlagStatus(
		ctx context.Context,
		params *cacheParameters,
		status bool,
	) error
}

CacheRepository provides the interface for acessing the cache for storing flag statuses.

type DataRepository

type DataRepository interface {
	// GetFlagDetailsByProjectKey gets the details of a flag by the project key,
	// environment name and the flag name.
	GetFlagDetailsByProjectKey(
		ctx context.Context,
		projectKey string,
		environmentName string,
		flagName string,
	) ([]FlagDetails, error)
}

type FlagDetails

type FlagDetails struct {
	ID          primitive.ObjectID      `bson:"_id"`
	Key         string                  `bson:"key"`
	Name        string                  `bson:"name"`
	Environment environment.Environment `bson:"environment"`
	Flag        flag.Flag               `bson:"flag"`
	FlagSetting flagsetting.FlagSetting `bson:"flag_setting"`
	CreatedBy   primitive.ObjectID      `bson:"created_by"`
	CreatedAt   time.Time               `bson:"created_at"`
	UpdatedAt   time.Time               `bson:"updated_at"`
}

FlagDetails contains the details of a particular flag in a particular environment.

type FlagProviderServer

type FlagProviderServer struct {
	providerpb.UnimplementedFlagProviderServer
	// contains filtered or unexported fields
}

FlagProviderServer is an implementation of the FlagProvider service.

func NewFlagProviderServer

func NewFlagProviderServer(
	providerDataRepo DataRepository,
	providerCacheRepo CacheRepository,
) *FlagProviderServer

func (*FlagProviderServer) GetFlag

type MongoDataRepository

type MongoDataRepository struct {
	// contains filtered or unexported fields
}

func NewProviderRepository

func NewProviderRepository(db *mongo.Database) *MongoDataRepository

func (*MongoDataRepository) GetFlagDetailsByProjectKey

func (r *MongoDataRepository) GetFlagDetailsByProjectKey(
	ctx context.Context,
	projectKey string,
	environmentName string,
	flagName string,
) ([]FlagDetails, error)

type RedisCacheRepository

type RedisCacheRepository struct {
	// contains filtered or unexported fields
}

func NewProviderCacheRepository

func NewProviderCacheRepository(rdb *redis.Client) *RedisCacheRepository

func (*RedisCacheRepository) CacheFlagStatus

func (r *RedisCacheRepository) CacheFlagStatus(
	ctx context.Context,
	params *cacheParameters,
	status bool,
) error

func (*RedisCacheRepository) GetFlagStatus

func (r *RedisCacheRepository) GetFlagStatus(
	ctx context.Context,
	params *cacheParameters,
) (bool, error)

func (*RedisCacheRepository) IsFlagStatusCached

func (r *RedisCacheRepository) IsFlagStatusCached(
	ctx context.Context,
	params *cacheParameters,
) (bool, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL