juju-core: github.com/prabhakhar/juju-core/store Index | Files

package store

import "github.com/prabhakhar/juju-core/store"

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.


Package Files

branch.go lpad.go server.go store.go


const (
    UpdateTimeout = 600e9


var (
    ErrUpdateConflict  = errors.New("charm update in progress")
    ErrRedundantUpdate = errors.New("charm is up-to-date")
    ErrNotFound        = errors.New("entry not found")

func PublishBazaarBranch Uses

func PublishBazaarBranch(store *Store, urls []*charm.URL, burl string, digest string) error

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 Uses

func PublishCharmsDistro(store *Store, apiBase lpad.APIBase) error

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.

type CharmDir Uses

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 Uses

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 Uses

type CharmEventKind int
const (
    EventPublished CharmEventKind = iota + 1


func (CharmEventKind) String Uses

func (k CharmEventKind) String() string

type CharmInfo Uses

type CharmInfo struct {
    // contains filtered or unexported fields

func (*CharmInfo) BundleSha256 Uses

func (ci *CharmInfo) BundleSha256() string

BundleSha256 returns the sha256 checksum for the stored charm bundle.

func (*CharmInfo) BundleSize Uses

func (ci *CharmInfo) BundleSize() int64

BundleSize returns the size for the stored charm bundle.

func (*CharmInfo) Config Uses

func (ci *CharmInfo) Config() *charm.Config

Config returns the charm.Config details for the stored charm.

func (*CharmInfo) Digest Uses

func (ci *CharmInfo) Digest() string

Digest returns the unique identifier that represents the charm data imported. This is typically set to the VCS revision digest.

func (*CharmInfo) Meta Uses

func (ci *CharmInfo) Meta() *charm.Meta

Meta returns the charm.Meta details for the stored charm.

func (*CharmInfo) Revision Uses

func (ci *CharmInfo) Revision() int

Revision returns the store charm's revision.

type CharmPublisher Uses

type CharmPublisher struct {
    // contains filtered or unexported fields

A CharmPublisher is responsible for importing a charm dir onto the store.

func (*CharmPublisher) Publish Uses

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 Uses

func (p *CharmPublisher) Revision() int

Revision returns the revision that will be assigned to the published charm.

type PublishBranchError Uses

type PublishBranchError struct {
    URL string
    Err error

type PublishBranchErrors Uses

type PublishBranchErrors []PublishBranchError

func (PublishBranchErrors) Error Uses

func (errs PublishBranchErrors) Error() string

type Server Uses

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.

func NewServer Uses

func NewServer(store *Store) (*Server, error)

New returns a new *Server using store.

func (*Server) ServeHTTP Uses

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves an http request. This method turns *Server into an http.Handler.

type Store Uses

type Store struct {
    // contains filtered or unexported fields

Store holds a connection to a charm store.

func Open Uses

func Open(mongoAddr string) (store *Store, err error)

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 Uses

func (s *Store) CharmEvent(url *charm.URL, digest string) (*CharmEvent, error)

CharmEvent returns the most recent event associated with url and digest. If the specified event isn't found the error ErrUnknownChange will be returned.

func (*Store) CharmInfo Uses

func (s *Store) CharmInfo(url *charm.URL) (info *CharmInfo, err error)

CharmInfo retrieves the CharmInfo value for the charm at url.

func (*Store) CharmPublisher Uses

func (s *Store) CharmPublisher(urls []*charm.URL, digest string) (p *CharmPublisher, err error)

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) Close Uses

func (s *Store) Close()

Close terminates the connection with the store.

func (*Store) IncCounter Uses

func (s *Store) IncCounter(key []string) error

IncCounter increases by one the counter associated with the composed key.

func (*Store) LockUpdates Uses

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 Uses

func (s *Store) LogCharmEvent(event *CharmEvent) (err error)

LogCharmEvent records an event related to one or more charm URLs.

func (*Store) OpenCharm Uses

func (s *Store) OpenCharm(url *charm.URL) (info *CharmInfo, rc io.ReadCloser, err error)

OpenCharm opens for reading via rc the charm currently available at url. rc must be closed after dealing with it or resources will leak.

func (*Store) SumCounter Uses

func (s *Store) SumCounter(key []string, prefix bool) (count int64, err error)

SumCounter returns the sum of all the counters that exactly match key, or that are prefixed by it if prefix is true.

type UpdateLock Uses

type UpdateLock struct {
    // contains filtered or unexported fields

UpdateLock represents an acquired update lock over a set of charm URLs.

func (*UpdateLock) Unlock Uses

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.

Package store imports 23 packages (graph). Updated 2017-03-27. Refresh now. Tools for package owners.