-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split extract requests into game and music contents
- Add Analyzer interface to handle game and music zips differently, and add implementations for both. Logic previously in extractAndUploadOne was moved into the GameAnalyzer implementation. - Observe query param "contents". If present and equal to "music", use MusicAnalyzer, otherwise use default behavior. - Change some structs, namely removing ResourceSpec, which fragmented concerns across domains a bit. Logic which affected outgoing headers was consolidated under the GameAnalyzer implementation. - Add optional Metadata field to API result JSON. - Tests: Replaced assert.NoError() with require.NoError(). The latter stops a test immediatly if the assertion fails, which prevents useless and noisy panic traces in test output. No dependencies added, already part of the testify module. - Removed unnecessary struct literal type names when they can be inferred, per linter. The current implementation of MusicAnalyzer is not efficient with memory. I left a TODO to address this once we confirm it works.
- Loading branch information
Showing
13 changed files
with
331 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package zipserver | ||
|
||
import ( | ||
"errors" | ||
"io" | ||
) | ||
|
||
// ErrSkipped is non-critical and indicates that analysis | ||
// chose to ignore a file. The file should not be uploaded. | ||
var ErrSkipped = errors.New("skipped file") | ||
|
||
// Analyzer analyzes individual files in a zip archive. | ||
// Behavior may change based on the intended workload. | ||
type Analyzer interface { | ||
// Analyze should return info about the contained file. | ||
// It should return ErrSkipped if a file was ignored. | ||
Analyze(r io.Reader, key string) (AnalyzeResult, error) | ||
} | ||
|
||
type AnalyzeResult struct { | ||
Key string // Analysis may choose a new key/filename | ||
Metadata interface{} | ||
ContentType string | ||
ContentEncoding string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.