Documentation ¶
Index ¶
- Constants
- Variables
- func DeleteLeaseController() martini.Handler
- func GetAvailableInventory(taskCollection integrations.Collection) (inventory map[string]skurepo.SkuBuilder)
- func GetInfoController() martini.Handler
- func GetTaskByIDController() martini.Handler
- func InitRoutes(m *martini.ClassicMartini, keyCheckHandler martini.Handler, appEnv *cfenv.App)
- func PostLeaseController() martini.Handler
- func SetupDB(dialer integrations.CollectionDialer, URI string, DBName string, ...) (collection integrations.Collection)
- type Lease
- func (s *Lease) Delete(logger *log.Logger, req *http.Request) (statusCode int, response interface{})
- func (s *Lease) InitFromHTTPRequest(req *http.Request) (err error)
- func (s *Lease) Post(logger *log.Logger, req *http.Request) (statusCode int, response interface{})
- func (s *Lease) Procurement() (skuTask *taskmanager.Task)
- func (s *Lease) ReStock() (skuTask *taskmanager.Task)
- type MongoCollection
- type MongoCollectionGetter
- type MongoCollectionWrapper
- type Persistence
Constants ¶
const ( //TaskStatusAvailable - this means the task is in an avaiable state TaskStatusAvailable = "available" //TaskStatusRestocking - reclaiming inventory and restocking TaskStatusRestocking = "restocking" TaskStatusUnavailable = "unavailable" //TaskStatusStarted - started this task TaskStatusStarted = "started" //TaskStatusProcurement - task is now in procurement TaskStatusProcurement = "in_procurement" //TaskCollectionName - collection name for tasks TaskCollectionName = "dispenser_tasks" //SuccessStatusResponseTaskByID - success statuscode for gettaskbyidcontroller SuccessStatusResponseTaskByID = http.StatusOK //FailureStatusResponseTaskByID - failure statuscode for gettaskbyidcontroller FailureStatusResponseTaskByID = http.StatusNotFound //CallerPostLease -- CallerPostLease = "post_lease" )
const (
//APIVersion1 - version 1 const
APIVersion1 = "v1"
)
Variables ¶
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") //ErrEmptyBody - no data in request body ErrEmptyBody = errors.New("request body is empty or invalid") //GLogger - a global logger GLogger *log.Logger = log.New(os.Stdout, "[default]", log.LstdFlags) )
var ( //URLBaseV1 - v1 url path base URLBaseV1 = fmt.Sprintf("/%s", APIVersion1) )
Functions ¶
func DeleteLeaseController ¶ added in v0.0.60
DeleteLeaseController - this is the controller to handle a get task call
func GetAvailableInventory ¶ added in v0.0.65
func GetAvailableInventory(taskCollection integrations.Collection) (inventory map[string]skurepo.SkuBuilder)
GetAvailableInventory - this should return available inventory and start a long task poller
func GetInfoController ¶ added in v0.0.48
GetInfoController - this is the controller to handle a info call to the api
func GetTaskByIDController ¶ added in v0.0.49
GetTaskByIDController - this is the controller to handle a get task call
func InitRoutes ¶
func InitRoutes(m *martini.ClassicMartini, keyCheckHandler martini.Handler, appEnv *cfenv.App)
InitRoutes - initialize the mappings for controllers against valid routes
func PostLeaseController ¶ added in v0.0.52
PostLeaseController - this is the controller to handle a get task call
func SetupDB ¶ added in v0.0.68
func SetupDB(dialer integrations.CollectionDialer, URI string, DBName string, collectionName string) (collection integrations.Collection)
SetupDB - setup your db connection and return a collection interface
Types ¶
type Lease ¶ added in v0.0.52
type Lease struct { ID string `json:"lease_id"` InventoryID string `json:"inventory_id"` UserName string `json:"username"` Sku string `json:"sku"` LeaseDuration float64 `json:"lease_duration"` LeaseEndDate int64 `json:"lease_end_date"` LeaseStartDate int64 `json:"lease_start_date"` ProcurementMeta map[string]interface{} `json:"procurement_meta"` Task taskmanager.RedactedTask `json:"task"` // contains filtered or unexported fields }
Lease - this represents a lease object
func NewLease ¶ added in v0.0.52
func NewLease(taskCollection integrations.Collection, availableSkus map[string]skurepo.SkuBuilder) *Lease
NewLease - create and return a new lease object
func (*Lease) Delete ¶ added in v0.0.60
func (s *Lease) Delete(logger *log.Logger, req *http.Request) (statusCode int, response interface{})
Delete - handle a delete lease call
func (*Lease) InitFromHTTPRequest ¶ added in v0.0.52
InitFromHTTPRequest - initialize a lease from the http request object body
func (*Lease) Procurement ¶ added in v0.0.52
func (s *Lease) Procurement() (skuTask *taskmanager.Task)
Procurement - method to issue a procurement request for the given lease item.
func (*Lease) ReStock ¶ added in v0.0.52
func (s *Lease) ReStock() (skuTask *taskmanager.Task)
ReStock - this will reclaim resources for a given lease
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