juju: github.com/juju/juju/state/bakerystorage Index | Files

package bakerystorage

import "github.com/juju/juju/state/bakerystorage"

Package bakerystorage provides an implementation of the bakery Storage interface that uses MongoDB to store items.

This is based on gopkg.in/macaroon-bakery.v2/bakery/mgostorage.

Index

Package Files

interface.go storage.go

func MongoIndexes Uses

func MongoIndexes() []mgo.Index

MongoIndexes returns the indexes to apply to the MongoDB collection.

type Config Uses

type Config struct {
    // GetCollection returns a mongo.Collection and a function that
    // will close any associated resources.
    GetCollection func() (collection mongo.Collection, closer func())

    // GetStorage returns a bakery.Storage and a function that will close
    // any associated resources.
    GetStorage func(rootKeys *mgostorage.RootKeys, coll mongo.Collection, expireAfter time.Duration) (storage bakery.Storage)
}

Config contains configuration for creating bakery storage with New.

func (Config) Validate Uses

func (c Config) Validate() error

Validate validates the configuration.

type ExpirableStorage Uses

type ExpirableStorage interface {
    bakery.Storage

    // ExpireAfter returns a new ExpirableStorage that will expire
    // added items after the specified duration.
    ExpireAfter(time.Duration) ExpirableStorage
}

ExpirableStorage extends bakery.Storage with the ExpireAfter method, to expire data added at the specified time.

func New Uses

func New(config Config) (ExpirableStorage, error)

New returns an implementation of bakery.Storage that stores all items in MongoDB with an expiry time.

Package bakerystorage imports 7 packages (graph) and is imported by 40 packages. Updated 2018-05-30. Refresh now. Tools for package owners.