github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/state/binarystorage/interface.go (about)

     1  // Copyright 2014 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package binarystorage
     5  
     6  import (
     7  	"io"
     8  )
     9  
    10  // Metadata describes a binary file stored in the storage.
    11  type Metadata struct {
    12  	Version string
    13  	Size    int64
    14  	SHA256  string
    15  }
    16  
    17  // Storage provides methods for storing and retrieving binary files by version.
    18  type Storage interface {
    19  	// Add adds the binary file and metadata into state, replacing existing
    20  	// metadata if any exists with the specified version.
    21  	Add(io.Reader, Metadata) error
    22  
    23  	// Open returns the Metadata and binary file contents for the specified
    24  	// version if it exists, else an error satisfying errors.IsNotFound.
    25  	Open(version string) (Metadata, io.ReadCloser, error)
    26  
    27  	// AllMetadata returns metadata for the full list of binary files in the
    28  	// catalogue.
    29  	AllMetadata() ([]Metadata, error)
    30  
    31  	// Metadata returns the Metadata for the specified version if it exists,
    32  	// else an error satisfying errors.IsNotFound.
    33  	Metadata(version string) (Metadata, error)
    34  }
    35  
    36  // StorageCloser extends the Storage interface with a Close method.
    37  type StorageCloser interface {
    38  	Storage
    39  	Close() error
    40  }