Documentation
¶
Index ¶
- Constants
- Variables
- func BulkRegisterMetrics(data []interface{}) ([]interface{}, error)
- func BulkUpsert(collectionName string, data []m.WriteModel, options *options.BulkWriteOptions) (interface{}, error)
- func CountDocs(collectionName string, filter types.M) (int64, error)
- func CountInstanceInTimeFrame(owner string, instance string, rate time.Duration) int
- func CountInstances(filter types.M) (int64, error)
- func CountInstancesByUser(owner string, instance string) int
- func CountServiceInstances(service, hostIP string) (int64, error)
- func CountUsers(filter types.M) (int64, error)
- func DeleteInstance(filter types.M) (interface{}, error)
- func DeleteInstances(filter types.M) (interface{}, error)
- func DeleteMany(collectionName string, filter types.M) (interface{}, error)
- func DeleteMetrics(filter types.M) (interface{}, error)
- func DeleteOne(collectionName string, filter types.M) (interface{}, error)
- func DeleteUser(filter types.M) (interface{}, error)
- func FetchAppInfo(filter types.M) []types.M
- func FetchContainerMetrics(filter types.M, count int64) []types.M
- func FetchDBInfo(filter types.M) []types.M
- func FetchDatabaseLanguage(name string) (string, error)
- func FetchDocs(collectionName string, filter types.M, opts ...*options.FindOptions) []types.M
- func FetchInstanceField(name, instanceType, field string) (interface{}, error)
- func FetchInstances(filter types.M) []types.M
- func FetchSingleApp(name string) (*types.ApplicationConfig, error)
- func FetchSingleDatabase(name string) (*types.DatabaseConfig, error)
- func FetchSingleUser(email string, opts ...*options.FindOneOptions) (*types.User, error)
- func FetchSingleUserWithoutPassword(email string) (*types.User, error)
- func FetchUserInfo(filter types.M) []types.M
- func InsertMany(collectionName string, data []interface{}) ([]interface{}, error)
- func InsertOne(collectionName string, data interface{}) (interface{}, error)
- func RegisterInstance(data interface{}) (interface{}, error)
- func RegisterMetrics(data interface{}) (interface{}, error)
- func RegisterUser(data interface{}) (interface{}, error)
- func UpdateInstance(filter types.M, data interface{}) error
- func UpdateInstances(filter types.M, data interface{}) (interface{}, error)
- func UpdateMany(collectionName string, filter types.M, data interface{}) (interface{}, error)
- func UpdateOne(collectionName string, filter types.M, data interface{}, ...) error
- func UpdateOneWithUpsert(collectionName string, filter types.M, data interface{}, ...) error
- func UpdateUser(filter types.M, data interface{}) error
- func UpsertInstance(filter types.M, data interface{}) error
- func UpsertMetrics(data []m.WriteModel) (interface{}, error)
- func UpsertUser(filter types.M, data interface{}) error
Constants ¶
const ( // DBInstance is db instance type name in the instances collection DBInstance = "database" // Mysql is db instance type name for mysql database in the instances collection Mysql = types.MySQL // MongoDB is db instance type name in the instances collection MongoDB = types.MongoDB // AppInstance is app instance type name in the instances collection AppInstance = "application" // InstanceCollection is the collection for all the instances InstanceCollection = "instances" // UserCollection is the collection for all users UserCollection = "users" // MetricsCollection is the collection to hold the metrics of the instances MetricsCollection = "metrics" // NameKey is the key holding the name of an instance NameKey = "name" // OwnerKey is the key holding the owner of an instance OwnerKey = "owner" // InstanceTypeKey is the key holding the instance type of an instance InstanceTypeKey = "instance_type" // LanguageKey is the key holding the language of an instance LanguageKey = "language" // HostIPKey is the key holding the host IP address of an instance HostIPKey = "host_ip" // ContainerPortKey is the key holding the port of the container in which an application is deployed ContainerPortKey = "container_port" // PortKey is the key holding the port of the container in which a database server is deployed PortKey = "port" // EmailKey is the key holding the email of a user EmailKey = "email" // UsernameKey is the key holding the username of a user UsernameKey = "username" // PasswordKey is the key holding the password of a user/instance PasswordKey = "password" // AdminKey is the key denoting whether a user has superuser privileges or not AdminKey = "admin" // TimestampKey is the key holding the timestamp of when a metrics collection was inserted TimestampKey = "timestamp" //GctlUUIDKey is the key holding a unique key for authentication of user by jwt GctlUUIDKey = "gctl_uuid" // DatetimeKey is the key holding the timestamp of when the instance was created DatetimeKey = "datetime" )
Variables ¶
var ErrNoDocuments = mongo.ErrNoDocuments
ErrNoDocuments is the error when no matching documents are found for an update operation
Functions ¶
func BulkRegisterMetrics ¶
func BulkRegisterMetrics(data []interface{}) ([]interface{}, error)
BulkRegisterMetrics is an abstraction over InsertMany which inserts multiple metrics documents into the mongoDB
func BulkUpsert ¶
func BulkUpsert(collectionName string, data []m.WriteModel, options *options.BulkWriteOptions) (interface{}, error)
BulkUpsert upserts multiple documents using BulkWrite
func CountInstanceInTimeFrame ¶
CountInstanceInTimeFrame returns the number of instances created by a user
func CountInstances ¶
CountInstances returns the number of instances matching a filter
func CountInstancesByUser ¶
CountInstancesByUser returns the number of specified instances by the user
func CountServiceInstances ¶
CountServiceInstances returns the number of applications of a given service deployed in a host machine
func CountUsers ¶
CountUsers returns the number of users matching a filter
func DeleteInstance ¶
DeleteInstance is an abstraction over DeleteOne which deletes an application from mongoDB
func DeleteInstances ¶
DeleteInstances is an abstraction over DeleteMany which deletes applications from mongoDB
func DeleteMany ¶
DeleteMany deletes multiple documents from a mongoDB collection
func DeleteMetrics ¶
DeleteMetrics is an abstraction over DeleteOne which deletes a container metrics from mongoDB
func DeleteUser ¶
DeleteUser is an abstraction over DeleteOne which deletes a user from mongoDB
func FetchAppInfo ¶
FetchAppInfo is an abstraction over FetchDocs for retrieving application related documents
func FetchContainerMetrics ¶
FetchContainerMetrics is an abstraction over FetchDocs for retrieving metrics of a container
func FetchDBInfo ¶
FetchDBInfo is an abstraction over FetchDocs for retrieving database related documents
func FetchDatabaseLanguage ¶
FetchDatabaseLanguage returns the language of a database
func FetchDocs ¶
FetchDocs is a generic function which takes a collection name and mongoDB filter as input and returns documents
func FetchInstanceField ¶
FetchInstanceField returns the value of a given field from an instance
func FetchInstances ¶
FetchInstances is an abstraction over FetchDocs for retrieving any instance documents
func FetchSingleApp ¶
func FetchSingleApp(name string) (*types.ApplicationConfig, error)
FetchSingleApp returns an application based on a name based filter
func FetchSingleDatabase ¶
func FetchSingleDatabase(name string) (*types.DatabaseConfig, error)
FetchSingleDatabase returns a database based on a name based filter
func FetchSingleUser ¶
FetchSingleUser returns a user based on a email based filter
func FetchSingleUserWithoutPassword ¶
FetchSingleUserWithoutPassword returns a user based on a email based filter without his/her password
func FetchUserInfo ¶
FetchUserInfo is an abstraction over FetchDocs for retrieving user details
func InsertMany ¶
InsertMany inserts multiple document into a mongoDB collection
func RegisterInstance ¶
func RegisterInstance(data interface{}) (interface{}, error)
RegisterInstance is an abstraction over InsertOne which inserts application info into mongoDB
func RegisterMetrics ¶
func RegisterMetrics(data interface{}) (interface{}, error)
RegisterMetrics is an abstraction over InsertOne which inserts metrics into the mongoDB
func RegisterUser ¶
func RegisterUser(data interface{}) (interface{}, error)
RegisterUser is an abstraction over InsertOne which inserts user into the mongoDB
func UpdateInstance ¶
UpdateInstance is an abstraction over UpdateOne which updates an application in mongoDB
func UpdateInstances ¶
UpdateInstances is an abstraction over UpdateMany which updates multiple applications in mongoDB
func UpdateMany ¶
UpdateMany updates multiple documents in the mongoDB collection
func UpdateOne ¶
func UpdateOne(collectionName string, filter types.M, data interface{}, option *options.FindOneAndUpdateOptions) error
UpdateOne updates a document in the mongoDB collection
func UpdateOneWithUpsert ¶
func UpdateUser ¶
UpdateUser is an abstraction over UpdateOne which updates an application in mongoDB
func UpsertInstance ¶
UpsertInstance is an abstraction over UpdateOne which updates an application in mongoDB or inserts it if the corresponding document doesn't exist
func UpsertMetrics ¶
func UpsertMetrics(data []m.WriteModel) (interface{}, error)
UpsertMetrics is an abstraction over BulkUpsert which updates multiple metrics documents in mongoDB or inserts them if the corresponding document doesn't exist
func UpsertUser ¶
UpsertUser is an abstraction over UpdateOne which updates an application in mongoDB or inserts it if the corresponding document doesn't exist
Types ¶
This section is empty.