utils

package
v0.0.0-...-c9dffe9 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package utils implements utility methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckUserNoBalance

func CheckUserNoBalance(client *mongo.Client, billMap map[string]float64) error

func CreateUserWithBalance

func CreateUserWithBalance(client *mongo.Client, userID string,
	balance float64, callbackURL string) error

func DeleteUser

func DeleteUser(client *mongo.Client, userID string) error

func GetComputeunitGroupList

func GetComputeunitGroupList(client *mongo.Client) ([]string, error)

func GetComputeunitInGroupByID

func GetComputeunitInGroupByID(client *mongo.Client, groupName string, computeunitID string) (map[string]interface{}, bool, error)

func GetComputeunitInfoByGroup

func GetComputeunitInfoByGroup(client *mongo.Client, groupName string) ([]map[string]interface{}, bool, error)

func GetKubernetesClient

func GetKubernetesClient() (*kubernetes.Clientset, error)

func GetPodList

func GetPodList(client *kubernetes.Clientset, labelSelector string, ns string) (*[]v1.Pod, error)

func GetPriceMap

func GetPriceMap(client *mongo.Client) (map[string]float64, error)

func GetUserBalance

func GetUserBalance(client *mongo.Client, userID string) (float64, error)

func GetUserComputeunitGroup

func GetUserComputeunitGroup(client *mongo.Client, userID string) ([]string, error)

func In

func In(haystack interface{}, needle interface{}) (bool, error)

func InitColl

func InitColl(client *mongo.Client) error

func ModifyUserBalance

func ModifyUserBalance(client *mongo.Client, userID string, balance float64) error

func ModifyUserComputeunitGroup

func ModifyUserComputeunitGroup(client *mongo.Client, userID string, groups []string) error

func UpdateOrInsertPod

func UpdateOrInsertPod(client *mongo.Client, pod PodInfo) error

func UpdateUserAccount

func UpdateUserAccount(client *mongo.Client, userID string, balance *float64,
	callbackURL *string, computeunitGroup *[]string) error

Types

type AccountInfo

type AccountInfo struct {
	UserID           string   `bson:"userId,omitempty"`
	Balance          *float64 `bson:"balance,omitempty"`
	CallbackURL      string   `bson:"callbackUrl,omitempty"`
	ComputeunitGroup []string `bson:"computeunitGroup,omitempty"`
}

func GetAccountList

func GetAccountList(client *mongo.Client) ([]AccountInfo, error)

type ComputeunitGroup

type ComputeunitGroup struct {
	GroupName       string   `bson:"groupName,omitempty"`
	ComputeunitList []string `bson:"computeunitList,omitempty"`
	Avl             bool     `bson:"avl,omitempty"`
}

type ComputeunitInfo

type ComputeunitInfo struct {
	ID    string   `bson:"id,omitempty"`
	Price *float64 `bson:"price,omitempty"`
}

type InstanceInfo

type InstanceInfo struct {
	// using _id as instance id
	InstanceName string `bson:"instanceName,omitempty"`
	UserID       string `bson:"userId,omitempty"`
}

type PodInfo

type PodInfo struct {
	UserID          string    `bson:"userId,omitempty"`
	PodName         string    `bson:"podName,omitempty"`
	PodUID          types.UID `bson:"podUID,omitempty"`
	InstanceID      string    `bson:"instanceId,omitempty"`
	ComputeunitList []string  `bson:"computeunitList,omitempty"`
	StartTime       time.Time `bson:"startTime,omitempty"`
	UpdateTime      time.Time `bson:"updateTime,omitempty"`
	Count           int64     `bson:"count,omitempty"`
}

Jump to

Keyboard shortcuts

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