environment

package
v0.0.0-...-5948d4f Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

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

View Source
var ErrCouldNotSave = status.Error(
	codes.Internal,
	"could not create a new environment",
)

ErrCouldNotSave is a GRPC error that is returned when an unknown error occurs while creating a new environment.

View Source
var ErrEnvironmentIDCast = status.Error(
	codes.Internal,
	"could not create a new environment",
)

ErrEnvironmentIDCast is a GRPC error that is returned when the ID of the environment could not be cast.

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

ErrNameTaken is a GRPC error that is returned when creating a new environment and the provided environment name is already taken.

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

ErrNotFound is a GRPC error that is returned when no environments are found for the provided query.

View Source
var ErrTxnSession = status.Error(
	codes.Internal,
	"could not create a transaction session",
)

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

Functions

This section is empty.

Types

type DataRepository

type DataRepository interface {
	// Creates a new `Environment` document.
	Save(
		ctx context.Context,
		environment *Environment,
	) (*mongo.InsertOneResult, error)

	// Gets an `Environment` by it's object ID.
	GetByID(ctx context.Context, id primitive.ObjectID) (*Environment, error)

	// Gets an environment by it's name and the project ID.
	GetByNameAndProjectID(
		ctx context.Context,
		environmentName string,
		projectID primitive.ObjectID,
	) (*Environment, error)
}

type Environment

type Environment 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 NewEnvironmentRepository

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

func (*MongoDataRepository) GetByID

func (*MongoDataRepository) GetByNameAndProjectID

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

func (*MongoDataRepository) Save

func (r *MongoDataRepository) Save(
	ctx context.Context,
	environment *Environment,
) (*mongo.InsertOneResult, error)

type Server

type Server struct {
	environmentpb.UnimplementedEnvironmentServer
	// contains filtered or unexported fields
}

func NewEnvironmentServer

func NewEnvironmentServer(
	client *mongo.Client,
	userDataRepo user.DataRepository,
	projectDataRepo project.DataRepository,
	flagSettingDataRepo flagsetting.DataRepository,
	environmentDataRepo DataRepository,
) *Server

Jump to

Keyboard shortcuts

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