flag

package
v0.0.0-...-0874bd6 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

View Source
var ErrCouldNotSave = status.Error(
	codes.Internal,
	"error occurred while saving the flag",
)

ErrCouldNotSave is a GRPC error that is returned when an unknown error occurs while saving a flag.

View Source
var ErrNameTaken = status.Error(
	codes.AlreadyExists,
	"a flag with that name already exists",
)

ErrNameTaken is a GRPC error that is returned when attempting to save a new flag and the flag name has already been taken.

View Source
var ErrNoEnvironments = status.Error(
	codes.FailedPrecondition,
	"no environments have been configured for the project",
)

ErrNoEnvironments is a GRPC error that is returned when no environments have been configured and the user tries to create a new flag.

View Source
var ErrNotFound = status.Error(codes.NotFound, "flag not found")

ErrNotFound is a GRPC error that is returned when the requested flag was not found.

View Source
var ErrTxnSession = status.Error(
	codes.Internal,
	"could start the transaction to save flag",
)

ErrTxnSession is a GRPC error that is returned when a new session for starting a transaction could not be created.

View Source
var ErrUpdateStatus = status.Error(
	codes.Internal,
	"no flag settings could be updated",
)

ErrUpdateStatus is a GRPC error that is returned when the status of a flag could not be updated.

Functions

This section is empty.

Types

type DataRepository

type DataRepository interface {
	// Save creates a new `Flag` document.
	Save(ctx context.Context, flag *Flag) (*mongo.InsertOneResult, error)

	// GetByID gets a `Flag` by it's object ID.
	GetByID(ctx context.Context, flagID primitive.ObjectID) (*Flag, error)

	// GetByNameAndProjectID gets a `Flag` by it's name and the ID of the
	// project that it belongs to.
	GetByNameAndProjectID(
		ctx context.Context,
		flagName string,
		projectID primitive.ObjectID,
	) (*Flag, error)
}

type Flag

type Flag struct {
	ID        primitive.ObjectID `bson:"_id,omitempty"`
	Name      string             `bson:"name"`
	ProjectID primitive.ObjectID `bson:"project_id"`
	CreatedBy primitive.ObjectID `bson:"created_by"`
	CreatedAt time.Time          `bson:"created_at"`
}

type MongoDataRepository

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

func NewFlagRepository

func NewFlagRepository(
	ctx context.Context,
	db *mongo.Database,
) (*MongoDataRepository, error)

func (*MongoDataRepository) GetByID

func (r *MongoDataRepository) GetByID(
	ctx context.Context,
	flagID primitive.ObjectID,
) (*Flag, error)

func (*MongoDataRepository) GetByNameAndProjectID

func (r *MongoDataRepository) GetByNameAndProjectID(
	ctx context.Context,
	flagName string,
	projectID primitive.ObjectID,
) (*Flag, error)

func (*MongoDataRepository) Save

func (r *MongoDataRepository) Save(
	ctx context.Context,
	flag *Flag,
) (*mongo.InsertOneResult, error)

type Server

type Server struct {
	flagpb.UnimplementedFlagServer
	// contains filtered or unexported fields
}

func NewFlagServer

func NewFlagServer(
	mongoClient *mongo.Client,
	userDataRepo user.DataRepository,
	projectDataRepo project.DataRepository,
	environmentDataRepo environment.DataRepository,
	flagDataRepo DataRepository,
	flagSettingDataRepo flagsetting.DataRepository,
) *Server

NewFlagServer creates a new `FlagServer` for serving GRPC requests.

func (*Server) CreateFlag

func (s *Server) CreateFlag(
	ctx context.Context,
	req *flagpb.CreateFlagRequest,
) (*flagpb.CreateFlagResponse, error)

func (*Server) UpdateFlagStatus

Jump to

Keyboard shortcuts

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