From 4e93929943936c7d2fb5477d406b7819ad1821c0 Mon Sep 17 00:00:00 2001 From: Michael Hohn Date: Wed, 30 Oct 2024 11:10:28 -0700 Subject: [PATCH] Code generalization: cleanup --- pkg/artifactstore/common.go | 4 +--- pkg/artifactstore/store_memory.go | 11 ----------- pkg/artifactstore/store_minio.go | 6 ------ pkg/server/server.go | 1 - 4 files changed, 1 insertion(+), 21 deletions(-) diff --git a/pkg/artifactstore/common.go b/pkg/artifactstore/common.go index 7bc971b..2a3bd7a 100644 --- a/pkg/artifactstore/common.go +++ b/pkg/artifactstore/common.go @@ -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 } diff --git a/pkg/artifactstore/store_memory.go b/pkg/artifactstore/store_memory.go index e56e700..f174280 100644 --- a/pkg/artifactstore/store_memory.go +++ b/pkg/artifactstore/store_memory.go @@ -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, diff --git a/pkg/artifactstore/store_minio.go b/pkg/artifactstore/store_minio.go index 221a30f..dff34ad 100644 --- a/pkg/artifactstore/store_minio.go +++ b/pkg/artifactstore/store_minio.go @@ -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, diff --git a/pkg/server/server.go b/pkg/server/server.go index 4ee4aa6..25a49c8 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -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)