Documentation ¶
Index ¶
- Variables
- type DataRepository
- type Flag
- type MongoDataRepository
- func (r *MongoDataRepository) GetByID(ctx context.Context, flagID primitive.ObjectID) (*Flag, error)
- func (r *MongoDataRepository) GetByNameAndProjectID(ctx context.Context, flagName string, projectID primitive.ObjectID) (*Flag, error)
- func (r *MongoDataRepository) Save(ctx context.Context, flag *Flag) (*mongo.InsertOneResult, error)
- type Server
Constants ¶
This section is empty.
Variables ¶
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.
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.
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.
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.
var ErrNotFound = status.Error(codes.NotFound, "flag not found")
ErrNotFound is a GRPC error that is returned when the requested flag was not found.
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.
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 MongoDataRepository ¶
type MongoDataRepository struct {
// contains filtered or unexported fields
}
func NewFlagRepository ¶
func (*MongoDataRepository) GetByNameAndProjectID ¶
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 ¶
func (s *Server) UpdateFlagStatus( ctx context.Context, req *flagpb.UpdateFlagStatusRequest, ) (*flagpb.UpdateFlagStatusResponse, error)