Documentation ¶
Index ¶
- Constants
- Variables
- type BindConn
- type BindNode
- type Bucket
- type CaptchaResult
- type CasbinUsecase
- type DynamicParam
- type Entry
- type JsonBody
- type LatencyDistribution
- type LoginForm
- type LoginResult
- type LoginUsecase
- func (u *LoginUsecase) GetCaptcha(ctx context.Context) (CaptchaResult, error)
- func (u *LoginUsecase) GetUserInfo(ctx context.Context) (*User, error)
- func (u *LoginUsecase) Login(ctx context.Context, formItem *LoginForm) (*LoginResult, error)
- func (u *LoginUsecase) Logout(ctx context.Context) error
- func (u *LoginUsecase) ParseUserID(c *gin.Context) (string, error)
- func (u *LoginUsecase) QueryMenus(ctx context.Context) (Menus, error)
- func (u *LoginUsecase) RefreshToken(ctx context.Context) (*LoginResult, error)
- func (u *LoginUsecase) ResponseCaptcha(ctx context.Context, w http.ResponseWriter, id string, reload bool) error
- func (u *LoginUsecase) UpdatePassword(ctx context.Context, updateItem *UpdateLoginPassword) error
- func (u *LoginUsecase) UpdateUser(ctx context.Context, updateItem *UpdateCurrentUser) error
- type Menu
- type MenuForm
- type MenuQueryOptions
- type MenuQueryParam
- type MenuQueryResult
- type MenuRepository
- type MenuResource
- type MenuResourceForm
- type MenuResourceQueryOptions
- type MenuResourceQueryParam
- type MenuResourceQueryResult
- type MenuResourceRepository
- type MenuResources
- type MenuUsecase
- func (a *MenuUsecase) Create(ctx context.Context, formItem *MenuForm) (*Menu, error)
- func (a *MenuUsecase) CreateInBatchByParent(ctx context.Context, items Menus, parent *Menu) error
- func (a *MenuUsecase) Delete(ctx context.Context, id string) error
- func (a *MenuUsecase) Get(ctx context.Context, id string) (*Menu, error)
- func (a *MenuUsecase) Query(ctx context.Context, params MenuQueryParam) (*MenuQueryResult, error)
- func (a *MenuUsecase) Update(ctx context.Context, id string, formItem *MenuForm) error
- type Menus
- type NodeInstanceCost
- type NodeListResult
- type NodeQuery
- type NodeQueryResult
- type NodeResultItem
- type NodeUsecase
- type Plan
- type PlanQueryResult
- type PlanRecordQuery
- type PlanRecordResultItem
- type Restart
- type Role
- type RoleForm
- type RoleMenu
- type RoleMenuForm
- type RoleMenuQueryOptions
- type RoleMenuQueryParam
- type RoleMenuQueryResult
- type RoleMenuRepository
- type RoleMenus
- type RoleQueryOptions
- type RoleQueryParam
- type RoleQueryResult
- type RoleRepository
- type RoleUsecase
- func (a *RoleUsecase) Create(ctx context.Context, formItem *RoleForm) (*Role, error)
- func (a *RoleUsecase) Delete(ctx context.Context, id string) error
- func (a *RoleUsecase) Get(ctx context.Context, id string) (*Role, error)
- func (a *RoleUsecase) Query(ctx context.Context, params RoleQueryParam) (*RoleQueryResult, error)
- func (a *RoleUsecase) Update(ctx context.Context, id string, formItem *RoleForm) error
- type Roles
- type ScheduledTask
- type ScheduledTaskRepository
- type Stop
- type StressUsecase
- func (s *StressUsecase) QueryPlanAndTaskRecords(ctx context.Context, userId string, query TaskRecordQuery) (*Plan, error)
- func (s *StressUsecase) QueryPlanTaskRecords(ctx context.Context, userId string, query TaskRecordQuery) (*TaskResult, error)
- func (s *StressUsecase) QueryUserRecords(ctx context.Context, userId string, query PlanRecordQuery) (*PlanQueryResult, error)
- func (s *StressUsecase) RestartStress(ctx context.Context, restart *Restart) error
- func (s *StressUsecase) StartStress(ctx context.Context, in *Plan) error
- func (s *StressUsecase) Stop(ctx context.Context, planId uint64, task *repo.TaskRecord)
- func (s *StressUsecase) StopStress(ctx context.Context, b *Stop) error
- type Summary
- type Task
- type TaskRecordQuery
- type TaskResult
- type TaskResultItem
- type UpdateCurrentUser
- type UpdateLoginPassword
- type UpdateNodeForm
- type User
- type UserForm
- type UserQueryOptions
- type UserQueryParam
- type UserQueryResult
- type UserRepository
- type UserRole
- type UserRoleForm
- type UserRoleQueryOptions
- type UserRoleQueryParam
- type UserRoleQueryResult
- type UserRoleRepository
- type UserRoles
- type UserUsecase
- func (a *UserUsecase) Create(ctx context.Context, formItem *UserForm) (*User, error)
- func (a *UserUsecase) Delete(ctx context.Context, id string) error
- func (a *UserUsecase) Get(ctx context.Context, id string) (*User, error)
- func (a *UserUsecase) GetRoleIDs(ctx context.Context, id string) ([]string, error)
- func (a *UserUsecase) Query(ctx context.Context, params UserQueryParam) (*UserQueryResult, error)
- func (a *UserUsecase) ResetPassword(ctx context.Context, id string) error
- func (a *UserUsecase) Update(ctx context.Context, id string, formItem *UserForm) error
- type Users
Constants ¶
const ( CacheNSForUser = "user" CacheNSForRole = "role" )
const ( ErrInvalidTokenID = "com.invalid.token" ErrInvalidCaptchaID = "com.invalid.captcha" ErrInvalidUsernameOrPassword = "com.invalid.username-or-password" )
const ( MenuStatusDisabled = "disabled" MenuStatusEnabled = "enabled" )
const ( RoleStatusEnabled = "enabled" // Enabled RoleStatusDisabled = "disabled" // Disabled RoleResultTypeSelect = "select" // Select )
const ( UserStatusActivated = "activated" UserStatusFreezed = "freezed" )
const (
CacheKeyForSyncToCasbin = "sync:casbin"
)
const MaxPullTaskCount = 200
MaxPullTaskCount max pull task count by planId, generally 200 is enough
const (
PopWaitSecond = 10
)
Variables ¶
var ( MenusOrderParams = []common.OrderByParam{ {Field: "sequence", Direction: common.DESC}, {Field: "created_at", Direction: common.DESC}, } )
var ProviderSet = wire.NewSet( NewCasbinUsecase, NewLoginUsecase, NewMenuUsecase, NewRoleUsecase, NewStressUsecase, NewUserUsecase, NewNodeUsecase, )
Functions ¶
This section is empty.
Types ¶
type BindNode ¶
type BindNode struct { Nums []int32 // contains filtered or unexported fields }
stress
type CaptchaResult ¶
type CaptchaResult struct {
CaptchaID string `json:"captcha_id"` // Captcha ID
}
login
type CasbinUsecase ¶
type CasbinUsecase struct { Enforcer *atomic.Value `wire:"-"` // contains filtered or unexported fields }
func NewCasbinUsecase ¶
func NewCasbinUsecase( cache cachex.Cache, menuRepository MenuRepository, roleRepository RoleRepository, menuResourceRepository MenuResourceRepository, conf *conf.ServerConf, ) *CasbinUsecase
NewCasbinUsecase initializes a new CasbinUsecase with the given parameters.
cache: cachex.Cache menuRepository: MenuRepository roleRepository: RoleRepository menuResourceRepository: MenuResourceRepository conf: *conf.ServerConf Returns *CasbinUsecase
func (*CasbinUsecase) GetEnforcer ¶
func (a *CasbinUsecase) GetEnforcer() *casbin.Enforcer
type DynamicParam ¶
stress
type LatencyDistribution ¶
type LatencyDistribution struct { Percentage float64 Latency int PercentageStr string LatencyMs string }
record
type LoginForm ¶
type LoginForm struct { Username string `json:"username" binding:"required"` // Login name Password string `json:"password" binding:"required"` // Login password (md5 hash) CaptchaID string `json:"captcha_id" binding:"required"` // Captcha verify id CaptchaCode string `json:"captcha_code" binding:"required"` // Captcha verify code }
login
type LoginResult ¶
type LoginResult struct { AccessToken string `json:"access_token"` // Access token (JWT) TokenType string `json:"token_type"` // Token type (Usage: Authorization=${token_type} ${access_token}) ExpiresAt int64 `json:"expires_at"` // Expired time (Unit: second) }
login
type LoginUsecase ¶
type LoginUsecase struct {
// contains filtered or unexported fields
}
func NewLoginUsecase ¶
func NewLoginUsecase( cache cachex.Cache, conf *conf.ServerConf, userRepository UserRepository, auth jwtx.Auther, userUsecase *UserUsecase, userRoleRepository UserRoleRepository, menuRepository MenuRepository, ) *LoginUsecase
func (*LoginUsecase) GetCaptcha ¶
func (u *LoginUsecase) GetCaptcha(ctx context.Context) (CaptchaResult, error)
func (*LoginUsecase) GetUserInfo ¶
func (u *LoginUsecase) GetUserInfo(ctx context.Context) (*User, error)
func (*LoginUsecase) Login ¶
func (u *LoginUsecase) Login(ctx context.Context, formItem *LoginForm) (*LoginResult, error)
func (*LoginUsecase) ParseUserID ¶
func (u *LoginUsecase) ParseUserID(c *gin.Context) (string, error)
ParseUserID parse user id for middleware
func (*LoginUsecase) QueryMenus ¶
func (u *LoginUsecase) QueryMenus(ctx context.Context) (Menus, error)
func (*LoginUsecase) RefreshToken ¶
func (u *LoginUsecase) RefreshToken(ctx context.Context) (*LoginResult, error)
func (*LoginUsecase) ResponseCaptcha ¶
func (u *LoginUsecase) ResponseCaptcha(ctx context.Context, w http.ResponseWriter, id string, reload bool) error
ResponseCaptcha Response captcha image
func (*LoginUsecase) UpdatePassword ¶
func (u *LoginUsecase) UpdatePassword(ctx context.Context, updateItem *UpdateLoginPassword) error
func (*LoginUsecase) UpdateUser ¶
func (u *LoginUsecase) UpdateUser(ctx context.Context, updateItem *UpdateCurrentUser) error
type Menu ¶
type Menu struct { ID string `json:"id" gorm:"size:20;primarykey;"` // Unique ID Code string `json:"code" gorm:"size:32;index;"` // Code of menu (unique for each level) Name string `json:"name" gorm:"size:128;index"` // Display name of menu Description string `json:"description" gorm:"size:1024"` // Details about menu Sequence int `json:"sequence" gorm:"index;"` // Sequence for sorting (Order by desc) Type string `json:"type" gorm:"size:20;index"` // Type of menu (page, button) Path string `json:"path" gorm:"size:255;"` // Access path of menu Properties string `json:"properties" gorm:"type:text;"` // Properties of menu (JSON) Status string `json:"status" gorm:"size:20;index"` // Status of menu (enabled, disabled) ParentID string `json:"parent_id" gorm:"size:20;index;"` // Parent ID (From Menu.ID) ParentPath string `json:"parent_path" gorm:"size:255;index;"` // Parent path (split by .) Children *Menus `json:"children" gorm:"-"` // Child menus CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time Resources MenuResources `json:"resources" gorm:"-"` // Resources of menu }
type MenuForm ¶
type MenuForm struct { Code string `json:"code" binding:"required,max=32"` // Code of menu (unique for each level) Name string `json:"name" binding:"required,max=128"` // Display name of menu Description string `json:"description"` // Details about menu Sequence int `json:"sequence"` // Sequence for sorting (Order by desc) Type string `json:"type" binding:"required,oneof=page button"` // Type of menu (page, button) Path string `json:"path"` // Access path of menu Properties string `json:"properties"` // Properties of menu (JSON) Status string `json:"status" binding:"required,oneof=disabled enabled"` // Status of menu (enabled, disabled) ParentID string `json:"parent_id"` // Parent ID (From Menu.ID) Resources MenuResources `json:"resources"` // Resources of menu }
type MenuQueryOptions ¶
type MenuQueryOptions struct {
common.QueryOptions
}
type MenuQueryParam ¶
type MenuQueryParam struct { common.PaginationParam CodePath string `form:"code"` // Code path (like xxx.xxx.xxx) LikeName string `form:"name"` // Display name of menu IncludeResources bool `form:"includeResources"` // Include resources InIDs []string `form:"-"` // Include menu IDs Status string `form:"-"` // Status of menu (disabled, enabled) ParentID string `form:"-"` // Parent ID (From Menu.ID) ParentPathPrefix string `form:"-"` // Parent path (split by .) UserID string `form:"-"` // User ID RoleID string `form:"-"` // Role ID }
type MenuQueryResult ¶
type MenuQueryResult struct { Data Menus PageResult *common.PaginationResult }
type MenuRepository ¶
type MenuRepository interface { Query(ctx context.Context, params MenuQueryParam, opts ...MenuQueryOptions) (*MenuQueryResult, error) Get(ctx context.Context, id string, opts ...MenuQueryOptions) (*Menu, error) GetByCodeAndParentID(ctx context.Context, code, parentID string, opts ...MenuQueryOptions) (*Menu, error) GetByNameAndParentID(ctx context.Context, name, parentID string, opts ...MenuQueryOptions) (*Menu, error) Exists(ctx context.Context, id string) (bool, error) ExistsCodeByParentID(ctx context.Context, code, parentID string) (bool, error) ExistsNameByParentID(ctx context.Context, name, parentID string) (bool, error) Create(ctx context.Context, item *Menu) error Update(ctx context.Context, item *Menu) error Delete(ctx context.Context, id string) error UpdateParentPath(ctx context.Context, id, parentPath string) error UpdateStatusByParentPath(ctx context.Context, parentPath, status string) error }
type MenuResource ¶
type MenuResource struct { ID string `json:"id" gorm:"size:20;primarykey"` // Unique ID MenuID string `json:"menu_id" gorm:"size:20;index"` // From Menu.ID Method string `json:"method" gorm:"size:20;"` // HTTP method Path string `json:"path" gorm:"size:255;"` // API request path (e.g. /api/v1/users/:id) CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time }
func (*MenuResource) TableName ¶
func (a *MenuResource) TableName() string
type MenuResourceForm ¶
type MenuResourceForm struct { }
func (*MenuResourceForm) FillTo ¶
func (a *MenuResourceForm) FillTo(menuResource *MenuResource) error
func (*MenuResourceForm) Validate ¶
func (a *MenuResourceForm) Validate() error
type MenuResourceQueryOptions ¶
type MenuResourceQueryOptions struct {
common.QueryOptions
}
type MenuResourceQueryParam ¶
type MenuResourceQueryParam struct { common.PaginationParam MenuID string `form:"-"` // From Menu.ID MenuIDs []string `form:"-"` // From Menu.ID }
type MenuResourceQueryResult ¶
type MenuResourceQueryResult struct { Data MenuResources PageResult *common.PaginationResult }
type MenuResourceRepository ¶
type MenuResourceRepository interface { Query(ctx context.Context, params MenuResourceQueryParam, opts ...MenuResourceQueryOptions) (*MenuResourceQueryResult, error) Get(ctx context.Context, id string, opts ...MenuResourceQueryOptions) (*MenuResource, error) Exists(ctx context.Context, id string) (bool, error) ExistsMethodPathByMenuID(ctx context.Context, method, path, menuID string) (bool, error) Create(ctx context.Context, item *MenuResource) error Update(ctx context.Context, item *MenuResource) error Delete(ctx context.Context, id string) error DeleteByMenuID(ctx context.Context, menuID string) error }
type MenuResources ¶
type MenuResources []*MenuResource
type MenuUsecase ¶
type MenuUsecase struct {
// contains filtered or unexported fields
}
func NewMenuUsecase ¶
func NewMenuUsecase( cache cachex.Cache, trans *common.Trans, menuRepository MenuRepository, menuResourceRepository MenuResourceRepository, roleMenuRepository RoleMenuRepository, conf *conf.ServerConf, ) *MenuUsecase
NewMenuUsecase initializes a new MenuUsecase with the provided dependencies.
cache: Cache interface for caching. trans: Trans pointer for translations. menuRepository: MenuRepository interface for menu operations. menuResourceRepository: MenuResourceRepository interface for menu resource operations. roleMenuRepository: RoleMenuRepository interface for role menu operations. conf: ServerConf pointer for server configuration. Returns a pointer to the initialized MenuUsecase.
func (*MenuUsecase) CreateInBatchByParent ¶
CreateInBatchByParent creates multiple menu items in batch under a parent menu.
ctx: the context for the operation. items: the list of menu items to create. parent: the parent menu under which the items will be created. error: an error if any occurred during the operation.
func (*MenuUsecase) Delete ¶
func (a *MenuUsecase) Delete(ctx context.Context, id string) error
Delete the specified menu from the data access object.
func (*MenuUsecase) Query ¶
func (a *MenuUsecase) Query(ctx context.Context, params MenuQueryParam) (*MenuQueryResult, error)
Query menus from the data access object based on the provided parameters and options.
type NodeInstanceCost ¶
type NodeInstanceCost struct { RpsQuota int GoroutineQuota int RpsCost int GoroutineCost int RunningTaskCount int UnExist bool // contains filtered or unexported fields }
stress
type NodeResultItem ¶
type NodeResultItem struct { Addr string `json:"addr"` RpsQuota int `json:"rps_quota"` GoroutineQuota int `json:"goroutine_quota"` RpsCost int `json:"rps_cost"` GoroutineCost int `json:"goroutine_cost"` RunningTaskCount int `json:"running_task_count"` }
node
type NodeUsecase ¶
type NodeUsecase struct {
// contains filtered or unexported fields
}
func NewNodeUsecase ¶
func NewNodeUsecase(nodeRepository repo.NodeRepository, discovery registry.Discovery) *NodeUsecase
NewNodeUsecase creates a new NodeUsecase.
Parameters:
nodeRepository: repo.NodeRepository discovery: registry.Discovery
Return type: *NodeUsecase
func (*NodeUsecase) QueryAllNodes ¶
func (s *NodeUsecase) QueryAllNodes(ctx context.Context) (*NodeListResult, error)
QueryAllNodes retrieves all nodes using the provided context. It returns a NodeListResult pointer and an error. return rps、goroutine cost/total, status and node executing task count
func (*NodeUsecase) QueryNodes ¶
func (s *NodeUsecase) QueryNodes(ctx context.Context, nodeQuery *NodeQuery) (*NodeQueryResult, error)
QueryNodes retrieves all nodes using the provided context. return node cpu/mem in graph
func (*NodeUsecase) UpdateNodeQuota ¶
func (s *NodeUsecase) UpdateNodeQuota(ctx context.Context, updateNodeForm *UpdateNodeForm) (any, error)
UpdateNodeQuota updates the quota for a node.
ctx: the context for the operation. item: the form containing the updated node information. Returns two empty interfaces.
type Plan ¶
type Plan struct { PlanId uint64 `json:"-"` PlanName string `json:"plan_name"` StartTime int64 `json:"start_time"` // todo if StartTime > 0 then use scheduleTask StressTime int `json:"stress_time" binding:"required,min=1"` StressType int `json:"stress_type" binding:"required,min=1,max=2"` StressMode int `json:"stress_mode" binding:"required,min=1,max=2"` UserId string `json:"user_id"` Tasks []Task `json:"tasks"` StepIntervalTime int `json:"step_interval_time"` IntervalLen int `json:"-"` }
stress
type PlanQueryResult ¶
type PlanQueryResult struct { Data []*PlanRecordResultItem PageResult *common.PaginationResult }
record
type PlanRecordQuery ¶
type PlanRecordQuery struct { common.PaginationParam PlanId uint64 `form:"plan_id"` PlanName string `form:"plan_name"` StartTime int64 `form:"start_time"` EndTime int64 `form:"end_time"` }
stress
type PlanRecordResultItem ¶
type PlanRecordResultItem struct { PlanId string `json:"plan_id"` UserId string `json:"user_id"` StartTime int64 `json:"start_time"` StressTime int `json:"stress_time"` StressType int `json:"stress_type"` StressMode int `json:"stress_mode"` Status int `json:"status"` StressProgress float64 `json:"stress_progress"` OverviewMetricsUrl string `json:"overview_metrics_url"` PlanName string `json:"plan_name"` CreateTime int64 `json:"create_time"` UpdateTime int64 `json:"update_time"` }
record
type Role ¶
type Role struct { ID string `json:"id" gorm:"size:20;primarykey;"` // Unique ID Code string `json:"code" gorm:"size:32;index;"` // Code of role (unique) Name string `json:"name" gorm:"size:128;index"` // Display name of role Description string `json:"description" gorm:"size:1024"` // Details about role Sequence int `json:"sequence" gorm:"index"` // Sequence for sorting Status string `json:"status" gorm:"size:20;index"` // Status of role (disabled, enabled) CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time Menus RoleMenus `json:"menus" gorm:"-"` // Role menu list }
type RoleForm ¶
type RoleForm struct { Code string `json:"code" binding:"required,max=32"` // Code of role (unique) Name string `json:"name" binding:"required,max=128"` // Display name of role Description string `json:"description"` // Details about role Sequence int `json:"sequence"` // Sequence for sorting Status string `json:"status" binding:"required,oneof=disabled enabled"` // Status of role (enabled, disabled) Menus RoleMenus `json:"menus"` // Role menu list }
type RoleMenu ¶
type RoleMenu struct { ID string `json:"id" gorm:"size:20;primarykey"` // Unique ID RoleID string `json:"role_id" gorm:"size:20;index"` // From Role.ID MenuID string `json:"menu_id" gorm:"size:20;index"` // From Menu.ID CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time }
type RoleMenuForm ¶
type RoleMenuForm struct { }
func (*RoleMenuForm) FillTo ¶
func (a *RoleMenuForm) FillTo(roleMenu *RoleMenu) error
func (*RoleMenuForm) Validate ¶
func (a *RoleMenuForm) Validate() error
type RoleMenuQueryOptions ¶
type RoleMenuQueryOptions struct {
common.QueryOptions
}
type RoleMenuQueryParam ¶
type RoleMenuQueryParam struct { common.PaginationParam RoleID string `form:"-"` // From Role.ID }
type RoleMenuQueryResult ¶
type RoleMenuQueryResult struct { Data RoleMenus PageResult *common.PaginationResult }
type RoleMenuRepository ¶
type RoleMenuRepository interface { Query(ctx context.Context, params RoleMenuQueryParam, opts ...RoleMenuQueryOptions) (*RoleMenuQueryResult, error) Get(ctx context.Context, id string, opts ...RoleMenuQueryOptions) (*RoleMenu, error) Exists(ctx context.Context, id string) (bool, error) Create(ctx context.Context, item *RoleMenu) error Update(ctx context.Context, item *RoleMenu) error Delete(ctx context.Context, id string) error DeleteByRoleID(ctx context.Context, roleID string) error DeleteByMenuID(ctx context.Context, menuID string) error }
type RoleQueryOptions ¶
type RoleQueryOptions struct {
common.QueryOptions
}
type RoleQueryParam ¶
type RoleQueryParam struct { common.PaginationParam LikeName string `form:"name"` // Display name of role Status string `form:"status" binding:"oneof=disabled enabled ''"` // Status of role (disabled, enabled) ResultType string `form:"resultType"` // Result type (options: select) InIDs []string `form:"-"` // ID list GtUpdatedAt *time.Time `form:"-"` // Update time is greater than }
type RoleQueryResult ¶
type RoleQueryResult struct { Data Roles PageResult *common.PaginationResult }
type RoleRepository ¶
type RoleRepository interface { Query(ctx context.Context, params RoleQueryParam, opts ...RoleQueryOptions) (*RoleQueryResult, error) Get(ctx context.Context, id string, opts ...RoleQueryOptions) (*Role, error) Exists(ctx context.Context, id string) (bool, error) ExistsCode(ctx context.Context, code string) (bool, error) Create(ctx context.Context, item *Role) error Update(ctx context.Context, item *Role) error Delete(ctx context.Context, id string) error }
type RoleUsecase ¶
type RoleUsecase struct {
// contains filtered or unexported fields
}
func NewRoleUsecase ¶
func NewRoleUsecase( cache cachex.Cache, trans *common.Trans, roleRepository RoleRepository, roleMenuRepository RoleMenuRepository, userRoleRepository UserRoleRepository, ) *RoleUsecase
func (*RoleUsecase) Delete ¶
func (a *RoleUsecase) Delete(ctx context.Context, id string) error
Delete the specified role from the data access object.
func (*RoleUsecase) Query ¶
func (a *RoleUsecase) Query(ctx context.Context, params RoleQueryParam) (*RoleQueryResult, error)
Query roles from the data access object based on the provided parameters and options.
type ScheduledTask ¶
type ScheduledTask struct {
Task Task `json:"task"`
}
type ScheduledTaskRepository ¶
type ScheduledTaskRepository interface { AddTask(ctx context.Context, ttl int64, scheduledTask *ScheduledTask) error WatchTask(ctx context.Context, execute func(task *ScheduledTask) bool) }
type StressUsecase ¶
type StressUsecase struct {
// contains filtered or unexported fields
}
func NewStressUsecase ¶
func NewStressUsecase(recordRepository repo.RecordRepository, nodeRepository repo.NodeRepository, queRepository repo.QueRepository, discovery registry.Discovery, conf *conf.ServerConf) *StressUsecase
NewStressUsecase new stress usecase
func (*StressUsecase) QueryPlanAndTaskRecords ¶
func (s *StressUsecase) QueryPlanAndTaskRecords(ctx context.Context, userId string, query TaskRecordQuery) (*Plan, error)
QueryPlanAndTaskRecords query plan and task record to copy stress plan task
func (*StressUsecase) QueryPlanTaskRecords ¶
func (s *StressUsecase) QueryPlanTaskRecords(ctx context.Context, userId string, query TaskRecordQuery) (*TaskResult, error)
func (*StressUsecase) QueryUserRecords ¶
func (s *StressUsecase) QueryUserRecords(ctx context.Context, userId string, query PlanRecordQuery) (*PlanQueryResult, error)
func (*StressUsecase) RestartStress ¶
func (s *StressUsecase) RestartStress(ctx context.Context, restart *Restart) error
func (*StressUsecase) StartStress ¶
func (s *StressUsecase) StartStress(ctx context.Context, in *Plan) error
StartStress starts the stress use case.
ctx: context.Context, in: *Plan error
func (*StressUsecase) Stop ¶
func (s *StressUsecase) Stop(ctx context.Context, planId uint64, task *repo.TaskRecord)
Stop stops the task execution on the specified nodes.
Parameters: - ctx: the context for the request. - planId: the ID of the plan to stop. - task: the task record containing information about the nodes.
func (*StressUsecase) StopStress ¶
func (s *StressUsecase) StopStress(ctx context.Context, b *Stop) error
StopStress stops stress for a given plan ID by stopping all associated tasks.
ctx context.Context, b *Stop error
type Summary ¶
type Summary struct { Num int TaskId uint64 Rps float64 AvgTotal int64 Fastest int64 Slowest int64 Average float64 ErrorCount int64 ErrorRate string SizeTotal int64 NumRes int64 TotalCostTime float64 Lat90 int `json:"lat_90"` Lat95 int `json:"lat_95"` Lat99 int `json:"lat_99"` Lat999 int `json:"lat_999"` TimeBuckets []int64 `json:"-"` StatusCodeDist map[int]int64 Histogram []Bucket LatencyDistribution []LatencyDistribution ErrorDist map[string]int64 BodyCheckResultMap map[string]int64 }
record
type Task ¶
type Task struct { PlanId uint64 `json:"-"` TaskId uint64 `json:"-"` StressTime int `json:"-"` StressType int `json:"-"` StressMode int `json:"-"` StepIntervalTime int `json:"-"` TaskName string `json:"task_name" binding:"required"` Num int `json:"num" binding:"required,min=1"` MaxNum int `json:"max_num"` StepNum int `json:"step_num"` MaxConnections int `json:"max_connections" binding:"min=1"` Url string `json:"url" binding:"required"` Method string `json:"method" binding:"required,oneof=GET POST PUT DELETE"` Timeout int `json:"timeout" binding:"min=1,max=5000"` QueryEntry []Entry `json:"query"` HeaderEntry []Entry `json:"header"` Query map[string]string `json:"-"` Headers map[string]string `json:"-"` Body string `json:"body"` DynamicParamScript string `json:"dynamic_param_script"` ResponseCheckScript string `json:"response_check_script"` DisableCompression bool `json:"-"` DisableKeepAlive bool `json:"-"` DisableRedirects bool `json:"-"` H2 bool `json:"-"` Options []string `json:"options"` Proxy string `json:"proxy"` DynamicParams []DynamicParam `json:"-"` // contains filtered or unexported fields }
stress
type TaskResultItem ¶
type TaskResultItem struct { TaskId string `json:"task_id"` TaskName string `json:"task_name"` TaskStatus int `json:"task_status"` PlanId string `json:"plan_id"` Url string `json:"url"` StressType int `json:"stress_type"` StressMode int `json:"stress_mode"` Num int `json:"num" binding:"required,min=1"` MaxNum int `json:"max_num"` StepNum int `json:"step_num"` Timeout int `json:"timeout" ` MaxConnections int `json:"max_connections"` ProtocolType int `json:"protocol_type"` Method string `json:"method"` QueryEntry []Entry `json:"query"` HeaderEntry []Entry `json:"header"` Body *JsonBody `json:"body"` DynamicParamScript string `json:"dynamic_param_script"` ResponseCheckScript string `json:"response_check_script"` DisableCompression int8 `json:"disable_compression"` DisableKeepAlive int8 `json:"disable_keep_alive"` DisableRedirects int8 `json:"disable_redirects"` H2 int8 `json:"h_2"` Proxy string `json:"proxy"` MaxBodySize int64 `json:"max_body_size"` Nodes string `json:"nodes"` MetricsUrl string `json:"metrics_url"` Reports []*Summary `json:"reports"` CreateTime int64 `json:"create_time"` UpdateTime int64 `json:"update_time"` }
record
type UpdateCurrentUser ¶
type UpdateCurrentUser struct { Name string `json:"name" binding:"required,max=64"` // Name of user Phone string `json:"phone" binding:"max=32"` // Phone number of user Email string `json:"email" binding:"max=128"` // Email of user Remark string `json:"remark" binding:"max=1024"` // Remark of user }
login
type UpdateLoginPassword ¶
type UpdateLoginPassword struct { OldPassword string `json:"old_password" binding:"required"` // Old password (md5 hash) NewPassword string `json:"new_password" binding:"required"` // New password (md5 hash) }
login
type UpdateNodeForm ¶
type UpdateNodeForm struct { Addr string `json:"addr"` RpsQuota int `json:"rps_quota"` GoroutineQuota int `json:"goroutine_quota"` }
node
type User ¶
type User struct { ID string `json:"id" gorm:"size:20;primarykey;"` // Unique ID Username string `json:"username" gorm:"size:64;index"` // Username for login Name string `json:"name" gorm:"size:64;index"` // Name of user Password string `json:"-" gorm:"size:64;"` // Password for login (encrypted) Phone string `json:"phone" gorm:"size:32;"` // Phone number of user Email string `json:"email" gorm:"size:128;"` // Email of user Remark string `json:"remark" gorm:"size:1024;"` // Remark of user Status string `json:"status" gorm:"size:20;index"` // Status of user (activated, freezed) CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time Roles UserRoles `json:"roles" gorm:"-"` // Roles of user }
type UserForm ¶
type UserForm struct { Username string `json:"username" binding:"required,max=64"` // Username for login Name string `json:"name" binding:"required,max=64"` // Name of user Password string `json:"password" binding:"max=64"` // Password for login (md5 hash) Phone string `json:"phone" binding:"max=32"` // Phone number of user Email string `json:"email" binding:"max=128"` // Email of user Remark string `json:"remark" binding:"max=1024"` // Remark of user Status string `json:"status" binding:"required,oneof=activated freezed"` // Status of user (activated, freezed) Roles UserRoles `json:"roles" binding:"required"` // Roles of user }
type UserQueryOptions ¶
type UserQueryOptions struct {
common.QueryOptions
}
type UserQueryParam ¶
type UserQueryParam struct { common.PaginationParam LikeUsername string `form:"username"` // Username for login LikeName string `form:"name"` // Name of user Status string `form:"status" binding:"oneof=activated freezed ''"` // Status of user (activated, freezed) }
type UserQueryResult ¶
type UserQueryResult struct { Data Users PageResult *common.PaginationResult }
type UserRepository ¶
type UserRepository interface { Query(ctx context.Context, params UserQueryParam, opts ...UserQueryOptions) (*UserQueryResult, error) Get(ctx context.Context, id string, opts ...UserQueryOptions) (*User, error) GetByUsername(ctx context.Context, username string, opts ...UserQueryOptions) (*User, error) Exists(ctx context.Context, id string) (bool, error) ExistsUsername(ctx context.Context, username string) (bool, error) Create(ctx context.Context, item *User) error Update(ctx context.Context, item *User, selectFields ...string) error Delete(ctx context.Context, id string) error UpdatePasswordByID(ctx context.Context, id string, password string) error }
type UserRole ¶
type UserRole struct { ID string `json:"id" gorm:"size:20;primarykey"` // Unique ID UserID string `json:"user_id" gorm:"size:20;index"` // From User.ID RoleID string `json:"role_id" gorm:"size:20;index"` // From Role.ID CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time RoleName string `json:"role_name" gorm:"<-:false;-:migration;"` // From Role.Name }
type UserRoleForm ¶
type UserRoleForm struct { }
func (*UserRoleForm) FillTo ¶
func (a *UserRoleForm) FillTo(userRole *UserRole) error
func (*UserRoleForm) Validate ¶
func (a *UserRoleForm) Validate() error
type UserRoleQueryOptions ¶
type UserRoleQueryOptions struct { common.QueryOptions JoinRole bool // Join role table }
type UserRoleQueryParam ¶
type UserRoleQueryParam struct { common.PaginationParam InUserIDs []string `form:"-"` // From User.ID UserID string `form:"-"` // From User.ID RoleID string `form:"-"` // From Role.ID }
type UserRoleQueryResult ¶
type UserRoleQueryResult struct { Data UserRoles PageResult *common.PaginationResult }
type UserRoleRepository ¶
type UserRoleRepository interface { Query(ctx context.Context, param UserRoleQueryParam, options ...UserRoleQueryOptions) (*UserRoleQueryResult, error) Get(ctx context.Context, id string, opts ...UserRoleQueryOptions) (*UserRole, error) Exists(ctx context.Context, id string) (bool, error) Create(ctx context.Context, item *UserRole) error Update(ctx context.Context, item *UserRole) error Delete(ctx context.Context, id string) error DeleteByUserID(ctx context.Context, userID string) error DeleteByRoleID(ctx context.Context, roleID string) error }
type UserUsecase ¶
type UserUsecase struct {
// contains filtered or unexported fields
}
func NewUserUsecase ¶
func NewUserUsecase( cache cachex.Cache, trans *common.Trans, userRepository UserRepository, userRoleRepository UserRoleRepository, conf *conf.ServerConf, ) *UserUsecase
func (*UserUsecase) Delete ¶
func (a *UserUsecase) Delete(ctx context.Context, id string) error
Delete the specified user from the data access object.
func (*UserUsecase) GetRoleIDs ¶
func (*UserUsecase) Query ¶
func (a *UserUsecase) Query(ctx context.Context, params UserQueryParam) (*UserQueryResult, error)
Query users from the data access object based on the provided parameters and options.
func (*UserUsecase) ResetPassword ¶
func (a *UserUsecase) ResetPassword(ctx context.Context, id string) error
Source Files ¶
- biz_casbin.go
- biz_login.go
- biz_menu.go
- biz_node.go
- biz_role.go
- biz_stress_record.go
- biz_stress_restart.go
- biz_stress_start.go
- biz_stress_stop.go
- biz_user.go
- consts.go
- dto.go
- id.go
- repo_menu.go
- repo_menu_resources.go
- repo_role.go
- repo_role_menu.go
- repo_scheduled_task.go
- repo_user.go
- repo_user_role.go
- wire.go