Merge Go frontend (apiserver + xcecli) into meson build
This commit is contained in:
parent
43dc12a36c
commit
c9dc8c4676
205 changed files with 30793 additions and 328 deletions
139
src/frontend/apiserver/models/resources.go
Normal file
139
src/frontend/apiserver/models/resources.go
Normal file
|
|
@ -0,0 +1,139 @@
|
|||
package models
|
||||
|
||||
type ValueType int
|
||||
|
||||
const (
|
||||
STRING ValueType = iota // Bool value
|
||||
NUMERIC // Numeric value
|
||||
BOOLEAN // String value
|
||||
)
|
||||
|
||||
// String returns the string representation of ValueType
|
||||
func (v ValueType) String() string {
|
||||
switch v {
|
||||
case BOOLEAN:
|
||||
return "Boolean"
|
||||
case NUMERIC:
|
||||
return "Numeric"
|
||||
case STRING:
|
||||
return "String"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
type OrderType int
|
||||
|
||||
const (
|
||||
INCR OrderType = iota
|
||||
DECR
|
||||
NA
|
||||
)
|
||||
|
||||
// String returns the string representation of OrderType
|
||||
func (o OrderType) String() string {
|
||||
switch o {
|
||||
case INCR:
|
||||
return "Incr"
|
||||
case DECR:
|
||||
return "Decr"
|
||||
case NA:
|
||||
return "NA"
|
||||
default:
|
||||
return "Unknown"
|
||||
}
|
||||
}
|
||||
|
||||
var RESOURCE_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"description",
|
||||
"value_type",
|
||||
"order_type",
|
||||
"flag",
|
||||
"interval",
|
||||
}
|
||||
|
||||
var RESOURCE_DISTRIBUTION_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"numeric_value",
|
||||
"location",
|
||||
"is_dynamic",
|
||||
}
|
||||
|
||||
var RESOURCE_DEFINITION_DEFAULT_COLUMN = []string{
|
||||
"res_name",
|
||||
"description",
|
||||
"value_type",
|
||||
"order_type",
|
||||
"flag",
|
||||
"interval",
|
||||
}
|
||||
|
||||
var ResourceFieldMappings = map[string]string{
|
||||
// API field name → struct field name
|
||||
"value": "numeric_value",
|
||||
}
|
||||
|
||||
var ResourcesAvailableTypes = []string{"static", "dynamic"}
|
||||
|
||||
const (
|
||||
BUILTIN = 0x01
|
||||
DYNAMIC = 0x02
|
||||
RELEASE = 0x20
|
||||
CONSUMABLE = 0x80
|
||||
)
|
||||
|
||||
type FlagValue int
|
||||
|
||||
// ToJSON returns the JSON object representation of FlagValue
|
||||
func (f FlagValue) ToJSON() map[string]bool {
|
||||
return map[string]bool{
|
||||
"builtin": f&BUILTIN != 0,
|
||||
"dynamic": f&DYNAMIC != 0,
|
||||
"release": f&RELEASE != 0,
|
||||
"consumable": f&CONSUMABLE != 0,
|
||||
}
|
||||
}
|
||||
|
||||
type ResourceInfo struct {
|
||||
ResName string
|
||||
Description string
|
||||
ValueType ValueType
|
||||
OrderType OrderType
|
||||
Flag int
|
||||
Interval int
|
||||
}
|
||||
|
||||
// queues info query supported filter
|
||||
var RESOURCE_DISTRIBUTION_SUPPORT_FILTERS = []string{
|
||||
"res_name",
|
||||
"is_dynamic",
|
||||
"location",
|
||||
}
|
||||
|
||||
var RESOURCE_DEFINITION_SUPPORT_FILTERS = []string{
|
||||
"res_name",
|
||||
}
|
||||
|
||||
type ResourceDistributionInfo struct {
|
||||
ResourceName string `json:"res_name"`
|
||||
IsDynamic bool `json:"is_dynamic"`
|
||||
ValueType int `json:"value_type"`
|
||||
BooleanValue bool `json:"boolean_value"`
|
||||
StringValue string `json:"string_value"`
|
||||
NumericValue float64 `json:"numeric_value"`
|
||||
Location string `json:"location"`
|
||||
}
|
||||
|
||||
type ResourceDefinitionInfo struct {
|
||||
ResourceName string `json:"res_name"`
|
||||
Description string `json:"description"`
|
||||
ValueType int `json:"value_type"`
|
||||
OrderType int `json:"order_type"`
|
||||
Flag int `json:"flag"`
|
||||
Interval int `json:"interval"`
|
||||
}
|
||||
|
||||
var RESOURCE_DISTRIBUTION_SUPPORT_SORT = []string{
|
||||
"res_name",
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue