Skip to content

Commit b183c0a

Browse files
committed
Fixes
1 parent b60c62b commit b183c0a

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

common/connectors/invokerconn/structs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package invokerconn
22

33
import (
4-
models2 "testing_system/common/db/models"
4+
"testing_system/common/db/models"
55
)
66

77
// This will be changed in later commits
@@ -16,6 +16,6 @@ type Job struct {
1616
JobType int `json:"jobType" binding:"required"`
1717
Test int `json:"test"`
1818

19-
Submit *models2.Submission `json:"submit,omitempty"`
20-
Problem *models2.Problem `json:"problem,omitempty"`
19+
Submit *models.Submission `json:"submit,omitempty"`
20+
Problem *models.Problem `json:"problem,omitempty"`
2121
}

common/connectors/storageconn/structs.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,17 @@ type ResponseFiles struct {
6666
Size uint64
6767
}
6868

69-
func (r *ResponseFiles) File() string {
70-
return filepath.Join(r.R.BaseFolder, r.fileNames[0])
69+
func (r *ResponseFiles) File() (string, bool) {
70+
if len(r.fileNames) == 0 {
71+
return "", false
72+
}
73+
return filepath.Join(r.R.BaseFolder, r.fileNames[0]), true
7174
}
7275

7376
func (r *ResponseFiles) Get(fileName string) (string, bool) {
7477
for _, f := range r.fileNames {
7578
if fileName == f {
76-
return filepath.Join(r.R.BaseFolder, r.fileNames[0]), true
79+
return filepath.Join(r.R.BaseFolder, f), true
7780
}
7881
}
7982
return "", false

invoker/storage/cache.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ import (
66
"testing_system/lib/logger"
77
)
88

9+
// The main idea of cache is following: We have one cache of specific size to hold all types of files.
10+
// However, we have multiple file types so we must have different getter for each file.
11+
//
12+
// So we have single LRUSizeCache that holds all file types. Key for this cache is cacheKey, the internal struct with which we can determine the file type and it's keys.
13+
//
14+
// To access cache we have cacheGetter structs. Each cacheGetter responds for single file type.
15+
// Each cacheGetter accepts any number of uint64 that are transformed to cacheKey struct using cacheGetter.keyGen func.
16+
//
17+
// So to access files, we call methods of cacheGetter, that transforms our request to request for LRUSizeCache and LRUSizeCache then does all the cache work.
18+
919
type commonCache = cache.LRUSizeCache[cacheKey, storageconn.ResponseFiles]
1020

1121
type cacheKey struct {

0 commit comments

Comments
 (0)