inline trivial functions
This commit is contained in:
committed by
=Michael Hohn
parent
5bdbd60cc5
commit
cf37b474e4
@@ -1,11 +1,5 @@
|
|||||||
package artifactstore
|
package artifactstore
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
|
|
||||||
"github.com/hohn/mrvacommander/pkg/common"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Restrict the keys / values for ArtifactLocation and centralize the common ones
|
// Restrict the keys / values for ArtifactLocation and centralize the common ones
|
||||||
// here
|
// here
|
||||||
var (
|
var (
|
||||||
@@ -17,13 +11,3 @@ type ArtifactLocation struct {
|
|||||||
Key string // location in bucket OR full location for file paths
|
Key string // location in bucket OR full location for file paths
|
||||||
Bucket string // which bucket: packs or results
|
Bucket string // which bucket: packs or results
|
||||||
}
|
}
|
||||||
|
|
||||||
// deriveKeyFromSessionId generates a key for a query pack based on the job ID
|
|
||||||
func deriveKeyFromSessionId(sessionId int) string {
|
|
||||||
return fmt.Sprintf("%d", sessionId)
|
|
||||||
}
|
|
||||||
|
|
||||||
// deriveKeyFromJobSpec generates a key for a result based on the JobSpec
|
|
||||||
func deriveKeyFromJobSpec(jobSpec common.JobSpec) string {
|
|
||||||
return fmt.Sprintf("%d-%s", jobSpec.SessionID, jobSpec.NameWithOwner)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ package artifactstore
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/hohn/mrvacommander/pkg/common"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
"github.com/hohn/mrvacommander/pkg/common"
|
||||||
)
|
)
|
||||||
|
|
||||||
// InMemoryArtifactStore is an in-memory implementation of the ArtifactStore interface
|
// InMemoryArtifactStore is an in-memory implementation of the ArtifactStore interface
|
||||||
@@ -38,7 +39,7 @@ func (store *InMemoryArtifactStore) SaveQueryPack(sessionId int, data []byte) (A
|
|||||||
store.mu.Lock()
|
store.mu.Lock()
|
||||||
defer store.mu.Unlock()
|
defer store.mu.Unlock()
|
||||||
|
|
||||||
key := deriveKeyFromSessionId(sessionId)
|
key := fmt.Sprintf("%d", sessionId)
|
||||||
store.packs[key] = data
|
store.packs[key] = data
|
||||||
|
|
||||||
location := ArtifactLocation{
|
location := ArtifactLocation{
|
||||||
@@ -79,7 +80,7 @@ func (store *InMemoryArtifactStore) SaveResult(jobSpec common.JobSpec, data []by
|
|||||||
store.mu.Lock()
|
store.mu.Lock()
|
||||||
defer store.mu.Unlock()
|
defer store.mu.Unlock()
|
||||||
|
|
||||||
key := deriveKeyFromJobSpec(jobSpec)
|
key := fmt.Sprintf("%d-%s", jobSpec.SessionID, jobSpec.NameWithOwner)
|
||||||
store.results[key] = data
|
store.results[key] = data
|
||||||
|
|
||||||
location := ArtifactLocation{
|
location := ArtifactLocation{
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ func (store *MinIOArtifactStore) GetQueryPack(location ArtifactLocation) ([]byte
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (store *MinIOArtifactStore) SaveQueryPack(jobId int, data []byte) (ArtifactLocation, error) {
|
func (store *MinIOArtifactStore) SaveQueryPack(jobId int, data []byte) (ArtifactLocation, error) {
|
||||||
return store.saveArtifact(AF_BUCKETNAME_PACKS, deriveKeyFromSessionId(jobId), data, "application/gzip")
|
key := fmt.Sprintf("%d", jobId)
|
||||||
|
return store.saveArtifact(AF_BUCKETNAME_PACKS, key, data, "application/gzip")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *MinIOArtifactStore) GetResult(location ArtifactLocation) ([]byte, error) {
|
func (store *MinIOArtifactStore) GetResult(location ArtifactLocation) ([]byte, error) {
|
||||||
@@ -62,9 +63,9 @@ func (store *MinIOArtifactStore) GetResultSize(location ArtifactLocation) (int,
|
|||||||
|
|
||||||
return int(objectInfo.Size), nil
|
return int(objectInfo.Size), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *MinIOArtifactStore) SaveResult(jobSpec common.JobSpec, data []byte) (ArtifactLocation, error) {
|
func (store *MinIOArtifactStore) SaveResult(jobSpec common.JobSpec, data []byte) (ArtifactLocation, error) {
|
||||||
return store.saveArtifact(AF_BUCKETNAME_RESULTS, deriveKeyFromJobSpec(jobSpec), data, "application/zip")
|
key := fmt.Sprintf("%d-%s", jobSpec.SessionID, jobSpec.NameWithOwner)
|
||||||
|
return store.saveArtifact(AF_BUCKETNAME_RESULTS, key, data, "application/zip")
|
||||||
}
|
}
|
||||||
|
|
||||||
func (store *MinIOArtifactStore) getArtifact(location ArtifactLocation) ([]byte, error) {
|
func (store *MinIOArtifactStore) getArtifact(location ArtifactLocation) ([]byte, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user