Documentation ¶
Overview ¶
Stores and retrieves fiddles and associated assets in Google Storage.
Index ¶
- Constants
- type Media
- type Named
- type Store
- func (s *Store) DeleteName(name string) error
- func (s *Store) Exists(hash string) error
- func (s *Store) GetCode(fiddleHash string) (string, *types.Options, error)
- func (s *Store) GetHashFromName(name string) (string, error)
- func (s *Store) GetMedia(fiddleHash string, media Media) ([]byte, string, string, error)
- func (s *Store) ListAllNames() ([]Named, error)
- func (s *Store) Put(code string, options types.Options, results *types.Result) (string, error)
- func (s *Store) PutMedia(options types.Options, fiddleHash string, results *types.Result) error
- func (s *Store) SetStatus(name, status string) error
- func (s *Store) ValidName(name string) bool
- func (s *Store) WriteName(name, hash, user, status string) error
Constants ¶
const ( FIDDLE_STORAGE_BUCKET = "skia-fiddle" LRU_CACHE_SIZE = 10000 // *_METADATA are the keys used to store the metadata values in Google Storage. USER_METADATA = "user" HASH_METADATA = "hash" STATUS_METADATA = "status" WIDTH_METADATA = "width" HEIGHT_METADATA = "height" SOURCE_METADATA = "source" SOURCE_MIPMAP_METADATA = "source_mipmap" TEXTONLY_METADATA = "textOnly" SRGB_METADATA = "srgb" F16_METADATA = "f16" ANIMATED_METADATA = "animated" DURATION_METADATA = "duration" OFFSCREEN_METADATA = "offscreen" OFFSCREEN_WIDTH_METADATA = "offscreen_width" OFFSCREEN_HEIGHT_METADATA = "offscreen_height" OFFSCREEN_SAMPLE_COUNT_METADATA = "offscreen_sample_count" OFFSCREEN_TEXTURABLE_METADATA = "offscreen_texturable" OFFSCREEN_MIPMAP_METADATA = "offscreen_mipmap" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Named ¶
type Named struct { Name string User string Hash string Status string // If a non-empty string then this named fiddle is broken and the string contains some information about the breakage. }
Named is the information about a named fiddle.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is used to read and write user code and media to and from Google Storage.
func (*Store) GetCode ¶
GetCode returns the code and options for the given fiddle hash.
fiddleHash - The fiddle hash.
Returns the code and the options the code was run under.
func (*Store) GetHashFromName ¶
GetHashFromName loads the fiddle hash for the given name.
func (*Store) GetMedia ¶
GetMedia returns the file, content-type, filename, and error for a given fiddle hash and type of media.
fiddleHash - The hash of the fiddle. media - The type of the file to read.
Returns the media file contents as a byte slice, the content-type, and the filename of the media.
func (*Store) ListAllNames ¶
ListAllNames returns the list of all named fiddles.
func (*Store) Put ¶
Put writes the code and media to Google Storage.
code - The user's code. options - The options the user chose to run the code under. results - The results from running fiddle_run.
Code is written to:
gs://skia-fiddle/fiddle/<fiddleHash>/draw.cpp
And media files are written to:
gs://skia-fiddle/fiddle/<fiddleHash>/cpu.png gs://skia-fiddle/fiddle/<fiddleHash>/gpu.png gs://skia-fiddle/fiddle/<fiddleHash>/skp.skp gs://skia-fiddle/fiddle/<fiddleHash>/pdf.pdf
If results is nil then only the code is written.
Returns the fiddleHash.
func (*Store) PutMedia ¶
PutMedia writes the media for the given fiddleHash to Google Storage.
fiddleHash - The fiddle hash. results - The results from running fiddle_run.
Media files are written to:
gs://skia-fiddle/fiddle/<fiddleHash>/cpu.png gs://skia-fiddle/fiddle/<fiddleHash>/gpu.png gs://skia-fiddle/fiddle/<fiddleHash>/skp.skp gs://skia-fiddle/fiddle/<fiddleHash>/pdf.pdf
If results is nil then only the code is written.
Returns the fiddleHash.
func (*Store) SetStatus ¶
SetStatus updates just the status of a named fiddle.
name - The name of the fidde. status - The current status of the named fiddle. An empty string means it is working. Non-empty string implies the fiddle is broken.
func (*Store) ValidName ¶
ValidName returns true if the name conforms to the restrictions on names.
name - The name of the fidde.
func (*Store) WriteName ¶
WriteName writes the name file for a named fiddle.
name - The name of the fidde. hash - The fiddle hash. user - The email of the user that created the name. status - The current status of the named fiddle. An empty string means it is working. Non-empty string implies the fiddle is broken.