Code generalization: cleanup

This commit is contained in:
Michael Hohn
2024-10-30 11:10:28 -07:00
committed by =Michael Hohn
parent e7d32861e5
commit 4e93929943
4 changed files with 1 additions and 21 deletions

View File

@@ -5,8 +5,6 @@ import (
"mrvacommander/pkg/common"
)
// xx: afl use
// XX: static types: split by type?
// Restrict the keys / values for ArtifactLocation and centralize the common ones
// here
const (
@@ -15,7 +13,7 @@ const (
)
type ArtifactLocation struct {
Key string // location in bucket
Key string // location in bucket OR full location for file paths
Bucket string // which bucket: packs or results
}

View File

@@ -25,9 +25,6 @@ func (store *InMemoryArtifactStore) GetQueryPack(location ArtifactLocation) ([]b
store.mu.Lock()
defer store.mu.Unlock()
// xx: afl use
// XX: static types
// key := location.Data[AF_KEY_KEY]
key := location.Key
data, exists := store.packs[key]
if !exists {
@@ -44,8 +41,6 @@ func (store *InMemoryArtifactStore) SaveQueryPack(sessionId int, data []byte) (A
key := deriveKeyFromSessionId(sessionId)
store.packs[key] = data
// XX: static types
// xx: afl use
location := ArtifactLocation{
Bucket: AF_BUCKETNAME_PACKS,
Key: key,
@@ -58,8 +53,6 @@ func (store *InMemoryArtifactStore) GetResult(location ArtifactLocation) ([]byte
store.mu.Lock()
defer store.mu.Unlock()
// xx: afl use
// key := location.Data[AF_KEY_KEY]
key := location.Key
data, exists := store.results[key]
if !exists {
@@ -73,8 +66,6 @@ func (store *InMemoryArtifactStore) GetResultSize(location ArtifactLocation) (in
store.mu.Lock()
defer store.mu.Unlock()
// key := location.Data[AF_KEY_KEY]
// xx: afl use
key := location.Key
data, exists := store.results[key]
if !exists {
@@ -91,8 +82,6 @@ func (store *InMemoryArtifactStore) SaveResult(jobSpec common.JobSpec, data []by
key := deriveKeyFromJobSpec(jobSpec)
store.results[key] = data
// XX: static types
// xx: afl use
location := ArtifactLocation{
Bucket: AF_BUCKETNAME_RESULTS,
Key: key,

View File

@@ -48,7 +48,6 @@ func (store *MinIOArtifactStore) GetQueryPack(location ArtifactLocation) ([]byte
}
func (store *MinIOArtifactStore) SaveQueryPack(jobId int, data []byte) (ArtifactLocation, error) {
// xx: afl use
return store.saveArtifact(AF_BUCKETNAME_PACKS, deriveKeyFromSessionId(jobId), data, "application/gzip")
}
@@ -57,7 +56,6 @@ func (store *MinIOArtifactStore) GetResult(location ArtifactLocation) ([]byte, e
}
func (store *MinIOArtifactStore) GetResultSize(location ArtifactLocation) (int, error) {
// xx: afl use
bucket := location.Bucket
key := location.Key
@@ -74,12 +72,10 @@ func (store *MinIOArtifactStore) GetResultSize(location ArtifactLocation) (int,
}
func (store *MinIOArtifactStore) SaveResult(jobSpec common.JobSpec, data []byte) (ArtifactLocation, error) {
// xx: afl use
return store.saveArtifact(AF_BUCKETNAME_RESULTS, deriveKeyFromJobSpec(jobSpec), data, "application/zip")
}
func (store *MinIOArtifactStore) getArtifact(location ArtifactLocation) ([]byte, error) {
// xx: afl use
bucket := location.Bucket
key := location.Key
@@ -107,8 +103,6 @@ func (store *MinIOArtifactStore) saveArtifact(bucket, key string, data []byte,
return ArtifactLocation{}, err
}
// XX: afl use
// XX: static types
location := ArtifactLocation{
Bucket: bucket,
Key: key,

View File

@@ -791,7 +791,6 @@ func (c *CommanderSingle) decodeAndSaveBase64QueryPack(qp string, sessionId int)
return artifactstore.ArtifactLocation{}, err
}
// XX: afl use
artifactLocation, err := c.v.Artifacts.SaveQueryPack(sessionId, tgz)
if err != nil {
slog.Error("Failed to save query pack", "err", err)