pezdispenser

package
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2015 License: Apache-2.0, GPL-2.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

View Source
const (
	Type = iota
	Item
	List
	SuccessStatus = "success"
	FailureStatus = "error"
)

Different contexts for rest calls

View Source
const (
	APIVersion1 = "v1"

	ItemGUID = "inventoryItemGUID"
	TypeGUID = "inventoryTypeGUID"
)

Constants to construct routes with

Variables

View Source
var (
	//ErrNoMatchInStore - error when there is no matching org in the datastore
	ErrNoMatchInStore = errors.New("Could not find a matching user org or connection failure")
	//ErrCanNotAddOrgRec - error when we can not add a new org record to the datastore
	ErrCanNotAddOrgRec = errors.New("Could not add a new org record")
)
View Source
var (
	ErrUndefinedPost   = errors.New("You must define a Post() function for your struct that extends Controller")
	ErrUndefinedGet    = errors.New("You must define a Get() function for your struct that extends Controller")
	ErrUndefinedDelete = errors.New("You must define a Delete() function for your struct that extends Controller")
)

Definition of errors for controller

View Source
var (
	URLLeaseBaseV1 = fmt.Sprintf("/%s/%s", APIVersion1, leasePath)
	URLLockBaseV1  = fmt.Sprintf("/%s/%s", APIVersion1, lockPath)
	URLTypeGUID    = fmt.Sprintf("/%s/:%s", typePath, TypeGUID)
	URLItemGUID    = fmt.Sprintf("/%s/:%s", itemPath, ItemGUID)
	URLLeases      = "/list"
)

formatted strings based on constants, to be used in URLs

Functions

func InitRoutes

func InitRoutes(m *martini.ClassicMartini, validationTargetUrl string)

InitRoutes - initialize the mappings for controllers against valid routes

Types

type Controller

type Controller interface {
	Get() interface{}
	Post() interface{}
	Delete() interface{}
}

Controller - This is a controller's interface

func NewLeaseController

func NewLeaseController(version string, category int) (controller Controller)

NewLeaseController - builds a new object of type controller from arguments

func NewLockController

func NewLockController(version string) (controller Controller)

NewLockController - returns a controller interface build using the version argument

type Dispenser

type Dispenser interface {
	GUID() string
	Status() ([]byte, error)
	Lock() ([]byte, error)
	UnLock() ([]byte, error)
	Lease() ([]byte, error)
	Unlease() ([]byte, error)
	Renew() ([]byte, error)
}

Dispenser - a interface for leasable inventory

type DispenserFinder

type DispenserFinder interface {
	GetAll() []Dispenser
	GetByTypeGUID(string) Dispenser
	GetByItemGUID(string) Dispenser
}

DispenserFinder - interfcae for a object to find Dispensers

func NewFinder

func NewFinder() (f DispenserFinder)

NewFinder - returns a DispenserFinder interface

type LeaseItemController

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

LeaseItemController - this is a controller for a lease for a specific item

func (*LeaseItemController) Delete

func (s *LeaseItemController) Delete() (post interface{})

Delete - this will return the versioned controller for a delete rest call

func (*LeaseItemController) Get

func (s *LeaseItemController) Get() (get interface{})

Get - this will return the versioned controller for a get rest call

func (*LeaseItemController) Post

func (s *LeaseItemController) Post() (post interface{})

Post - this will return the versioned controller for a post rest call

type LeaseListController

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

LeaseListController - this is a controller for a lease for a specific type

func (*LeaseListController) Delete

func (s *LeaseListController) Delete() (i interface{})

func (*LeaseListController) Get

func (s *LeaseListController) Get() (get interface{})

Get - this will return the versioned controller for a get rest call

func (*LeaseListController) Post

func (s *LeaseListController) Post() (i interface{})

type LeaseTypeController

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

LeaseTypeController - this is a controller for a lease for a specific type

func (*LeaseTypeController) Delete

func (s *LeaseTypeController) Delete() (i interface{})

func (*LeaseTypeController) Get

func (s *LeaseTypeController) Get() (get interface{})

Get - this will return the versioned controller for a get rest call

func (*LeaseTypeController) Post

func (s *LeaseTypeController) Post() (post interface{})

Post - this will return the versioned controller for a post rest call

type LockController

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

LockController - a controller for locking leases when they hit their expiration date

func (*LockController) Delete

func (s *LockController) Delete() (i interface{})

func (*LockController) Get

func (s *LockController) Get() (post interface{})

Get - returns a versioned controller for get requests

func (*LockController) Post

func (s *LockController) Post() (post interface{})

Post - returns a versioned controller for post requests

type MongoCollection added in v0.0.23

type MongoCollection interface {
	Remove(selector interface{}) error
	Find(query interface{}) *mgo.Query
	Upsert(selector interface{}, update interface{}) (info *mgo.ChangeInfo, err error)
}

MongoCollection - interface to a collection in mongo

type MongoCollectionGetter added in v0.0.23

type MongoCollectionGetter interface {
	Collection() Persistence
}

MongoCollectionGetter - Getting collections in mongo

type MongoCollectionWrapper added in v0.0.23

type MongoCollectionWrapper struct {
	Persistence
	// contains filtered or unexported fields
}

MongoCollectionWrapper - interface to wrap mongo collections with additional persistence functions

func (*MongoCollectionWrapper) FindOne added in v0.0.23

func (s *MongoCollectionWrapper) FindOne(query interface{}, result interface{}) (err error)

FindOne - combining the Find and One calls of a Mongo collection object

func (*MongoCollectionWrapper) Remove added in v0.0.23

func (s *MongoCollectionWrapper) Remove(selector interface{}) error

Remove - removes the matching selector from collection

func (*MongoCollectionWrapper) Upsert added in v0.0.23

func (s *MongoCollectionWrapper) Upsert(selector interface{}, update interface{}) (err error)

Upsert - allow us to call upsert on Mongo collection object

type Persistence added in v0.0.23

type Persistence interface {
	Remove(selector interface{}) error
	FindOne(query interface{}, result interface{}) (err error)
	Upsert(selector interface{}, update interface{}) (err error)
}

Persistence - interface to a persistence store of some kind

func NewMongoCollectionWrapper added in v0.0.23

func NewMongoCollectionWrapper(c MongoCollection) Persistence

NewMongoCollectionWrapper - wraps a Mongo collection in as a Peristence interface implementation

type ResponseMessage

type ResponseMessage struct {
	Version string
	Body    []byte
	Status  string
}

ResponseMessage - this is the structure of a response from any call to a controller

Jump to

Keyboard shortcuts

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