Documentation ¶
Overview ¶
The store package is capable of storing and updating charms in a MongoDB database, as well as maintaining further information about them such as the VCS revision the charm was loaded from and the URLs for the charms.
Index ¶
- Constants
- Variables
- func PublishBazaarBranch(store *Store, urls []*charm.URL, burl string, digest string) error
- func PublishCharmsDistro(store *Store, apiBase lpad.APIBase) error
- type CharmDir
- type CharmEvent
- type CharmEventKind
- type CharmInfo
- type CharmPublisher
- type Config
- type Counter
- type CounterRequest
- type CounterRequestBy
- type PublishBranchError
- type PublishBranchErrors
- type Server
- type Store
- func (s *Store) CharmEvent(url *charm.URL, digest string) (*CharmEvent, error)
- func (s *Store) CharmInfo(url *charm.URL) (*CharmInfo, error)
- func (s *Store) CharmPublisher(urls []*charm.URL, digest string) (p *CharmPublisher, err error)
- func (s *Store) Close()
- func (s *Store) Counters(req *CounterRequest) ([]Counter, error)
- func (s *Store) DeleteCharm(url *charm.URL) ([]*CharmInfo, error)
- func (s *Store) IncCounter(key []string) error
- func (s *Store) LockUpdates(urls []*charm.URL) (l *UpdateLock, err error)
- func (s *Store) LogCharmEvent(event *CharmEvent) (err error)
- func (s *Store) OpenCharm(url *charm.URL) (info *CharmInfo, rc io.ReadCloser, err error)
- type UpdateLock
Constants ¶
const (
UpdateTimeout = 600e9
)
Variables ¶
var ( ErrUpdateConflict = errors.New("charm update in progress") ErrRedundantUpdate = errors.New("charm is up-to-date") // Note that this error message is part of the API, since it's sent // both in charm-info and charm-event responses as errors indicating // that the given charm or charm event wasn't found. ErrNotFound = errors.New("entry not found") )
Functions ¶
func PublishBazaarBranch ¶
PublishBazaarBranch checks out the Bazaar branch from burl and publishes its latest revision at urls in the given store. The digest parameter must be the most recent known Bazaar revision id for the branch tip. If publishing this specific digest for these URLs has been attempted already, the publishing procedure may abort early. The published digest is the Bazaar revision id of the checked out branch's tip, though, which may differ from the digest parameter.
func PublishCharmsDistro ¶
PublishCharmsDistro publishes all branch tips found in the /charms distribution in Launchpad onto store under the "cs:" scheme. apiBase specifies the Launchpad base API URL, such as lpad.Production or lpad.Staging. Errors found while processing one or more branches are all returned as a PublishBranchErrors value.
Types ¶
type CharmDir ¶
type CharmDir interface { Meta() *charm.Meta Config() *charm.Config SetRevision(revision int) BundleTo(w io.Writer) error }
CharmDir matches the part of the interface of *charm.Dir that is necessary to publish a charm. Using this interface rather than *charm.Dir directly makes testing some aspects of the store possible.
type CharmEvent ¶
type CharmEvent struct { Kind CharmEventKind Digest string Revision int URLs []*charm.URL Errors []string `bson:",omitempty"` Warnings []string `bson:",omitempty"` Time time.Time }
CharmEvent is a record for an event relating to one or more charm URLs.
type CharmEventKind ¶
type CharmEventKind int
const ( EventPublished CharmEventKind = iota + 1 EventPublishError EventKindCount )
func (CharmEventKind) String ¶
func (k CharmEventKind) String() string
type CharmInfo ¶
type CharmInfo struct {
// contains filtered or unexported fields
}
func (*CharmInfo) BundleSha256 ¶
BundleSha256 returns the sha256 checksum for the stored charm bundle.
func (*CharmInfo) BundleSize ¶
BundleSize returns the size for the stored charm bundle.
func (*CharmInfo) Digest ¶
Digest returns the unique identifier that represents the charm data imported. This is typically set to the VCS revision digest.
type CharmPublisher ¶
type CharmPublisher struct {
// contains filtered or unexported fields
}
A CharmPublisher is responsible for importing a charm dir onto the store.
func (*CharmPublisher) Publish ¶
func (p *CharmPublisher) Publish(charm CharmDir) error
Publish bundles charm and writes it to the store. The written charm bundle will have its revision set to the result of Revision. Publish must be called only once for a CharmPublisher.
func (*CharmPublisher) Revision ¶
func (p *CharmPublisher) Revision() int
Revision returns the revision that will be assigned to the published charm.
type Config ¶
func ReadConfig ¶
type CounterRequest ¶
type CounterRequest struct { // Key and Prefix determine the counter keys to match. // If Prefix is false, Key must match exactly. Otherwise, counters // must begin with Key and have at least one more key token. Key []string Prefix bool // If List is true, matching counters are aggregated under their // prefixes instead of being returned as a single overall sum. // // For example, given the following counts: // // {"a", "b"}: 1, // {"a", "c"}: 3 // {"a", "c", "d"}: 5 // {"a", "c", "e"}: 7 // // and assuming that Prefix is true, the following keys will // present the respective results if List is true: // // {"a"} => {{"a", "b"}, 1, false}, // {{"a", "c"}, 3, false}, // {{"a", "c"}, 12, true} // {"a", "c"} => {{"a", "c", "d"}, 3, false}, // {{"a", "c", "e"}, 5, false} // // If List is false, the same key prefixes will present: // // {"a"} => {{"a"}, 16, true} // {"a", "c"} => {{"a", "c"}, 12, false} // List bool // By defines the period covered by each aggregated data point. // If unspecified, it defaults to ByAll, which aggregates all // matching data points in a single entry. By CounterRequestBy // Start, if provided, changes the query so that only data points // ocurring at the given time or afterwards are considered. Start time.Time // Stop, if provided, changes the query so that only data points // ocurring at the given time or before are considered. Stop time.Time }
CounterRequest represents a request to aggregate counter values.
type CounterRequestBy ¶
type CounterRequestBy int
const ( ByAll CounterRequestBy = iota ByDay ByWeek )
type PublishBranchError ¶
type PublishBranchErrors ¶
type PublishBranchErrors []PublishBranchError
func (PublishBranchErrors) Error ¶
func (errs PublishBranchErrors) Error() string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is an http.Handler that serves the HTTP API of juju so that juju clients can retrieve published charms.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store holds a connection to a charm store.
func Open ¶
Open creates a new session with the store. It connects to the MongoDB server at the given address (as expected by the Mongo function in the labix.org/v2/mgo package).
func (*Store) CharmEvent ¶
CharmEvent returns the most recent event associated with url and digest. If the specified event isn't found the error ErrUnknownChange will be returned. If digest is empty, any digest will match.
func (*Store) CharmPublisher ¶
CharmPublisher returns a new CharmPublisher for importing a charm that will be made available in the store at all of the provided URLs. The digest parameter must contain the unique identifier that represents the charm data being imported (e.g. the VCS revision sha1). ErrRedundantUpdate is returned if all of the provided urls are already associated to that digest.
func (*Store) Counters ¶
func (s *Store) Counters(req *CounterRequest) ([]Counter, error)
Counters aggregates and returns counter values according to the provided request.
func (*Store) DeleteCharm ¶
DeleteCharm deletes the charms matching url. If no revision is specified, all revisions of the charm are deleted.
func (*Store) IncCounter ¶
IncCounter increases by one the counter associated with the composed key.
func (*Store) LockUpdates ¶
func (s *Store) LockUpdates(urls []*charm.URL) (l *UpdateLock, err error)
LockUpdates acquires a server-side lock for updating a single charm that is supposed to be made available in all of the provided urls. If the lock can't be acquired in any of the urls, an error will be immediately returned. In the usual case, any locking done is undone when an error happens, or when l.Unlock is called. If something else goes wrong, the locks will also expire after the period defined in UpdateTimeout.
func (*Store) LogCharmEvent ¶
func (s *Store) LogCharmEvent(event *CharmEvent) (err error)
LogCharmEvent records an event related to one or more charm URLs.
type UpdateLock ¶
type UpdateLock struct {
// contains filtered or unexported fields
}
UpdateLock represents an acquired update lock over a set of charm URLs.
func (*UpdateLock) Unlock ¶
func (l *UpdateLock) Unlock()
Unlock removes the previously acquired server-side lock that prevents other processes from attempting to update a set of charm URLs.