mgostorage

package
v1.0.0-...-f3518ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2018 License: LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(c *mgo.Collection) (bakery.Storage, error)

New returns an implementation of Storage that stores all items in MongoDB. It never returns an error (the error return is for backward compatibility with a previous version that could return an error).

Note that the caller is responsible for closing the mgo session associated with the collection.

Types

type Policy

type Policy struct {
	// GenerateInterval holds the maximum length of time
	// for which a root key will be returned from RootKey.
	// If this is zero, it defaults to ExpiryDuration.
	GenerateInterval time.Duration

	// ExpiryDuration holds the minimum length of time that
	// root keys will be valid for after they are returned from
	// RootKey. The maximum length of time that they
	// will be valid for is ExpiryDuration + GenerateInterval.
	ExpiryDuration time.Duration
}

Policy holds a storage policy for root keys.

type RootKeys

type RootKeys struct {
	// contains filtered or unexported fields
}

RootKeys represents a cache of macaroon root keys.

func NewRootKeys

func NewRootKeys(maxCacheSize int) *RootKeys

NewRootKeys returns a root-keys cache that is limited in size to approximately the given size.

The NewStorageMethod returns a storage implementation that uses a specific mongo collection and storage policy.

func (*RootKeys) EnsureIndex

func (s *RootKeys) EnsureIndex(c *mgo.Collection) error

EnsureIndex ensures that the required indexes exist on the collection that will be used for root key storage. This should be called at least once before using NewStorage.

func (*RootKeys) NewStorage

func (s *RootKeys) NewStorage(c *mgo.Collection, policy Policy) bakery.RootKeyStorage

NewStorage returns a new RootKeyStorage implementation that stores and obtains root keys from the given collection.

Root keys will be generated and stored following the given storage policy.

It is expected that all collections passed to a given RootKey's NewStorage method should refer to the same underlying collection.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL