From 26056233244fb1b579ab2695fbd8db2cf30209b7 Mon Sep 17 00:00:00 2001 From: Lou Knauer Date: Wed, 12 May 2021 18:34:55 +0200 Subject: [PATCH] Change cluster.json to camelCase, go fmt --- README.md | 8 ++++---- graph/model/models.go | 18 +++++++++--------- graph/resolver.go | 22 +++++++++++----------- server.go | 2 +- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index a7263a0..46eccee 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ # Run server * The server expects the SQLite Job database in `./job.db`. -* The metric data as JSON is expected in `./job-data/.../.../data.json`. -* A JSON-description of the clusters is expected in `./clusters/*.json`. -* Run ```go run server.go``` -* The GraphQL backend is located at http://localhost:8080/query/ . +* The metric data as JSON is expected in `./job-data//.../data.json`. +* A JSON-description of the clusters is expected in `./job-data//cluster.json`. +* Run `go run server.go` +* The GraphQL backend is located at http://localhost:8080/query . # Debugging and Testing diff --git a/graph/model/models.go b/graph/model/models.go index 085e6c7..5d40351 100644 --- a/graph/model/models.go +++ b/graph/model/models.go @@ -33,13 +33,13 @@ type JobTag struct { } type Cluster struct { - ClusterID string `json:"cluster_id"` - ProcessorType string `json:"processor_type"` - SocketsPerNode int `json:"sockets_per_node"` - CoresPerSocket int `json:"cores_per_socket"` - ThreadsPerCore int `json:"threads_per_core"` - FlopRateScalar int `json:"flop_rate_scalar"` - FlopRateSimd int `json:"flop_rate_simd"` - MemoryBandwidth int `json:"memory_bandwidth"` - MetricConfig []MetricConfig `json:"metric_config"` + ClusterID string `json:"clusterID"` + ProcessorType string `json:"processorType"` + SocketsPerNode int `json:"socketsPerNode"` + CoresPerSocket int `json:"coresPerSocket"` + ThreadsPerCore int `json:"threadsPerCore"` + FlopRateScalar int `json:"flopRateScalar"` + FlopRateSimd int `json:"flopRateSimd"` + MemoryBandwidth int `json:"memoryBandwidth"` + MetricConfig []MetricConfig `json:"metricConfig"` } diff --git a/graph/resolver.go b/graph/resolver.go index a602290..371bf7b 100644 --- a/graph/resolver.go +++ b/graph/resolver.go @@ -63,7 +63,7 @@ func addTimeCondition(conditions []string, field string, input *model.TimeRange) func addFloatCondition(conditions []string, field string, input *model.FloatRange) []string { conditions = append(conditions, fmt.Sprintf("%s BETWEEN %f AND %f", field, input.From, input.To)) - return conditions; + return conditions } func buildQueryConditions(filterList *model.JobFilterList) (string, string) { @@ -410,8 +410,8 @@ func (r *queryResolver) FilterRanges( panic("expected exactly one row") } - duration := &model.IntRangeOutput{}; - numNodes := &model.IntRangeOutput{}; + duration := &model.IntRangeOutput{} + numNodes := &model.IntRangeOutput{} var startTimeMin, startTimeMax int64 err = rows.Scan(&duration.From, &duration.To, @@ -421,9 +421,9 @@ func (r *queryResolver) FilterRanges( return nil, err } - startTime := &model.TimeRangeOutput { - time.Unix(startTimeMin, 0), time.Unix(startTimeMax, 0) } - return &model.FilterRanges{ duration, numNodes, startTime }, nil + startTime := &model.TimeRangeOutput{ + time.Unix(startTimeMin, 0), time.Unix(startTimeMax, 0)} + return &model.FilterRanges{duration, numNodes, startTime}, nil } func (r *jobResolver) Tags(ctx context.Context, job *model.Job) ([]*model.JobTag, error) { @@ -468,8 +468,8 @@ func (r *clusterResolver) FilterRanges( panic("expected exactly one row") } - duration := &model.IntRangeOutput{}; - numNodes := &model.IntRangeOutput{}; + duration := &model.IntRangeOutput{} + numNodes := &model.IntRangeOutput{} var startTimeMin, startTimeMax int64 err = rows.Scan(&duration.From, &duration.To, @@ -479,9 +479,9 @@ func (r *clusterResolver) FilterRanges( return nil, err } - startTime := &model.TimeRangeOutput { - time.Unix(startTimeMin, 0), time.Unix(startTimeMax, 0) } - return &model.FilterRanges{ duration, numNodes, startTime }, nil + startTime := &model.TimeRangeOutput{ + time.Unix(startTimeMin, 0), time.Unix(startTimeMax, 0)} + return &model.FilterRanges{duration, numNodes, startTime}, nil } func (r *Resolver) Job() generated.JobResolver { return &jobResolver{r} } diff --git a/server.go b/server.go index 4871d15..cdeed2a 100644 --- a/server.go +++ b/server.go @@ -36,7 +36,7 @@ func main() { r.Handle("/query", srv) log.Printf("connect to http://localhost:%s/ for GraphQL playground", port) - log.Fatal(http.ListenAndServe("127.0.0.1:" + port, + log.Fatal(http.ListenAndServe("127.0.0.1:"+port, handlers.CORS(handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}), handlers.AllowedMethods([]string{"GET", "POST", "HEAD", "OPTIONS"}), handlers.AllowedOrigins([]string{"*"}))(loggedRouter)))