mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2025-06-08 00:23:48 +02:00
Update GraphQL schema. Refactor node repository
This commit is contained in:
parent
6f9737c2c2
commit
7466fe7a34
@ -301,7 +301,7 @@ type Query {
|
||||
allocatedNodes(cluster: String!): [Count!]!
|
||||
|
||||
node(id: ID!): Node
|
||||
nodes(filter: [NodeFilter!], order: OrderByInput): NodesResultList!
|
||||
nodes(filter: [NodeFilter!], order: OrderByInput): NodeStateResultList!
|
||||
nodeStats(filter: [NodeFilter!]): [NodeStats!]!
|
||||
|
||||
job(id: ID!): Job
|
||||
@ -459,7 +459,7 @@ input FloatRange {
|
||||
to: Float!
|
||||
}
|
||||
|
||||
type NodesResultList {
|
||||
type NodeStateResultList {
|
||||
items: [Node!]!
|
||||
count: Int
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -167,12 +167,30 @@ type NamedStatsWithScope struct {
|
||||
Stats []*ScopedStats `json:"stats"`
|
||||
}
|
||||
|
||||
type NodeFilter struct {
|
||||
Hostname *StringInput `json:"hostname,omitempty"`
|
||||
Cluster *StringInput `json:"cluster,omitempty"`
|
||||
SubCluster *StringInput `json:"subCluster,omitempty"`
|
||||
NodeState *string `json:"nodeState,omitempty"`
|
||||
HealthState *schema.NodeState `json:"healthState,omitempty"`
|
||||
}
|
||||
|
||||
type NodeMetrics struct {
|
||||
Host string `json:"host"`
|
||||
SubCluster string `json:"subCluster"`
|
||||
Metrics []*JobMetricWithName `json:"metrics"`
|
||||
}
|
||||
|
||||
type NodeStateResultList struct {
|
||||
Items []*schema.Node `json:"items"`
|
||||
Count *int `json:"count,omitempty"`
|
||||
}
|
||||
|
||||
type NodeStats struct {
|
||||
State string `json:"state"`
|
||||
Count int `json:"count"`
|
||||
}
|
||||
|
||||
type NodesResultList struct {
|
||||
Items []*NodeMetrics `json:"items"`
|
||||
Offset *int `json:"offset,omitempty"`
|
||||
|
@ -358,6 +358,21 @@ func (r *queryResolver) AllocatedNodes(ctx context.Context, cluster string) ([]*
|
||||
return counts, nil
|
||||
}
|
||||
|
||||
// Node is the resolver for the node field.
|
||||
func (r *queryResolver) Node(ctx context.Context, id string) (*schema.Node, error) {
|
||||
panic(fmt.Errorf("not implemented: Node - node"))
|
||||
}
|
||||
|
||||
// Nodes is the resolver for the nodes field.
|
||||
func (r *queryResolver) Nodes(ctx context.Context, filter []*model.NodeFilter, order *model.OrderByInput) (*model.NodeStateResultList, error) {
|
||||
panic(fmt.Errorf("not implemented: Nodes - nodes"))
|
||||
}
|
||||
|
||||
// NodeStats is the resolver for the nodeStats field.
|
||||
func (r *queryResolver) NodeStats(ctx context.Context, filter []*model.NodeFilter) ([]*model.NodeStats, error) {
|
||||
panic(fmt.Errorf("not implemented: NodeStats - nodeStats"))
|
||||
}
|
||||
|
||||
// Job is the resolver for the job field.
|
||||
func (r *queryResolver) Job(ctx context.Context, id string) (*schema.Job, error) {
|
||||
numericId, err := strconv.ParseInt(id, 10, 64)
|
||||
|
@ -159,16 +159,16 @@ func (r *NodeRepository) AddNode(node *schema.Node) (int64, error) {
|
||||
return node.ID, nil
|
||||
}
|
||||
|
||||
func (r *NodeRepository) UpdateNodeState(id int64, nodeState *schema.NodeState) error {
|
||||
if _, err := sq.Update("node").Set("node_state", nodeState).Where("node.id = ?", id).RunWith(r.DB).Exec(); err != nil {
|
||||
log.Errorf("error while updating node '%d'", id)
|
||||
func (r *NodeRepository) UpdateNodeState(hostname string, nodeState *schema.NodeState) error {
|
||||
if _, err := sq.Update("node").Set("node_state", nodeState).Where("node.hostname = ?", hostname).RunWith(r.DB).Exec(); err != nil {
|
||||
log.Errorf("error while updating node '%s'", hostname)
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *NodeRepository) UpdateHealthState(id int64, healthState *schema.MonitoringState) error {
|
||||
func (r *NodeRepository) UpdateHealthState(hostname string, healthState *schema.MonitoringState) error {
|
||||
if _, err := sq.Update("node").Set("health_state", healthState).Where("node.id = ?", id).RunWith(r.DB).Exec(); err != nil {
|
||||
log.Errorf("error while updating node '%d'", id)
|
||||
return err
|
||||
|
Loading…
x
Reference in New Issue
Block a user