-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add new job to the indexer - update the `/stats` endpoint to view numWorkloads on network - update schema/crafter to generate dump data - update stats tests
- Loading branch information
1 parent
c060542
commit fa46309
Showing
13 changed files
with
191 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package indexer | ||
|
||
import ( | ||
"context" | ||
"time" | ||
|
||
"github.com/threefoldtech/tfgrid-sdk-go/grid-proxy/internal/explorer/db" | ||
"github.com/threefoldtech/tfgrid-sdk-go/grid-proxy/pkg/types" | ||
"github.com/threefoldtech/tfgrid-sdk-go/rmb-sdk-go/peer" | ||
) | ||
|
||
const ( | ||
statsCall = "zos.statistics.get" | ||
) | ||
|
||
type WorkloadWork struct { | ||
findersInterval map[string]time.Duration | ||
} | ||
|
||
func NewWorkloadWork(interval uint) *WorkloadWork { | ||
return &WorkloadWork{ | ||
findersInterval: map[string]time.Duration{ | ||
"up": time.Duration(interval) * time.Minute, | ||
}, | ||
} | ||
} | ||
|
||
func (w *WorkloadWork) Finders() map[string]time.Duration { | ||
return w.findersInterval | ||
} | ||
|
||
func (w *WorkloadWork) Get(ctx context.Context, rmb *peer.RpcClient, twinId uint32) ([]types.NodesWorkloads, error) { | ||
var response struct { | ||
Users struct { | ||
Workloads uint32 `json:"workloads"` | ||
} `json:"users"` | ||
} | ||
|
||
if err := callNode(ctx, rmb, statsCall, nil, twinId, &response); err != nil { | ||
return []types.NodesWorkloads{}, err | ||
} | ||
|
||
return []types.NodesWorkloads{ | ||
{ | ||
NodeTwinId: twinId, | ||
WorkloadsNumber: response.Users.Workloads, | ||
}, | ||
}, nil | ||
} | ||
|
||
func (w *WorkloadWork) Upsert(ctx context.Context, db db.Database, batch []types.NodesWorkloads) error { | ||
return db.UpsertNodeWorkloads(ctx, batch) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters