storageserver

package
v0.0.0-...-d80fd1a Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2014 License: MPL-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DEFAULT_DATABASE_ROOT_PATH = "/tmp/storageserver"
	DEFAULT_SHARED_SECRET      = "cheesebaconeggs"
)
View Source
const MAX_LIMIT = 5000

Variables

View Source
var CollectionNotFoundErr = errors.New("Collection not found")
View Source
var IterationCancelledErr = errors.New("Iteration cancelled")
View Source
var ObjectNotFoundErr = errors.New("Object not found")

Functions

This section is empty.

Types

type AppContext

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

func SetupRouter

func SetupRouter(r *mux.Router, config Config) (*AppContext, error)

func (*AppContext) Authenticate

func (c *AppContext) Authenticate(w http.ResponseWriter, r *http.Request) (*Credentials, bool)

func (*AppContext) DeleteCollectionObjectsHandler

func (c *AppContext) DeleteCollectionObjectsHandler(w http.ResponseWriter, r *http.Request)

func (*AppContext) DeleteObjectHandler

func (c *AppContext) DeleteObjectHandler(w http.ResponseWriter, r *http.Request)

func (*AppContext) DeleteStorageHandler

func (c *AppContext) DeleteStorageHandler(w http.ResponseWriter, r *http.Request)

func (*AppContext) GetObjectHandler

func (c *AppContext) GetObjectHandler(w http.ResponseWriter, r *http.Request)

func (*AppContext) GetObjectsHandler

func (c *AppContext) GetObjectsHandler(w http.ResponseWriter, r *http.Request)

func (*AppContext) InfoCollectionCountsHandler

func (c *AppContext) InfoCollectionCountsHandler(w http.ResponseWriter, r *http.Request)

func (*AppContext) InfoCollectionsHandler

func (c *AppContext) InfoCollectionsHandler(w http.ResponseWriter, r *http.Request)

func (*AppContext) PostObjectsHandler

func (c *AppContext) PostObjectsHandler(w http.ResponseWriter, r *http.Request)

func (*AppContext) PutObjectHandler

func (c *AppContext) PutObjectHandler(w http.ResponseWriter, r *http.Request)

type CollectionInfo

type CollectionInfo struct {
	LastModified float64
}

type Config

type Config struct {
	DatabaseRootPath string
	SharedSecret     string
}

func DefaultConfig

func DefaultConfig() Config

type Credentials

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

func (*Credentials) Key

func (c *Credentials) Key() hawk.Key

type CredentialsStore

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

func (*CredentialsStore) CredentialsForKeyIdentifier

func (cs *CredentialsStore) CredentialsForKeyIdentifier(keyIdentifier string) (hawk.Credentials, error)

type DatabaseSession

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

func NewDatabaseSession

func NewDatabaseSession(url string) (*DatabaseSession, error)

func (*DatabaseSession) Close

func (session *DatabaseSession) Close()

func (*DatabaseSession) DeleteCollectionObjects

func (ds *DatabaseSession) DeleteCollectionObjects(userId uint64, collectionName string) error

func (*DatabaseSession) DeleteUserObjects

func (ds *DatabaseSession) DeleteUserObjects(userId uint64) error

func (*DatabaseSession) GetCollectionTimestamps

func (ds *DatabaseSession) GetCollectionTimestamps(uid uint64) (map[string]float64, error)

func (*DatabaseSession) GetObject

func (ds *DatabaseSession) GetObject(userId uint64, collectionName string, objectId string) (*Object, error)

func (*DatabaseSession) GetObjectIds

func (ds *DatabaseSession) GetObjectIds(userId uint64, limit int, newer float64) ([]string, error)

TODO: Get rid of this because I don't think it is actually used on any device?

func (*DatabaseSession) GetObjects

func (ds *DatabaseSession) GetObjects(userId uint64, collectionName string, limit int, newer float64) ([]Object, error)

func (*DatabaseSession) PutObject

func (ds *DatabaseSession) PutObject(userId uint64, collectionName string, objectId string, object Object) (float64, error)

func (*DatabaseSession) SetObjects

func (ds *DatabaseSession) SetObjects(userId uint64, collectionName string, objects []Object) (float64, error)

type DeleteCollectionObjectsResponse

type DeleteCollectionObjectsResponse struct {
	Modified float64 `json:"modified"`
}

type GetObjectsOptions

type GetObjectsOptions struct {
	Full  bool
	Limit int
	Newer float64
	Ids   []string
}

func ParseGetObjectsOptions

func ParseGetObjectsOptions(r *http.Request) (*GetObjectsOptions, error)

type Object

type Object struct {
	Id        string  `json:"id"`
	Modified  float64 `json:"modified"`
	Payload   string  `json:"payload"`
	SortIndex int     `json:"sortindex"`
	TTL       int     `json:"ttl"`
}

func (*Object) Validate

func (o *Object) Validate() error

type ObjectDatabase

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

func OpenObjectDatabase

func OpenObjectDatabase(path string) (*ObjectDatabase, error)

func (*ObjectDatabase) Close

func (odb *ObjectDatabase) Close() error

func (*ObjectDatabase) DeleteCollection

func (odb *ObjectDatabase) DeleteCollection(collectionName string) (float64, error)

func (*ObjectDatabase) DeleteObject

func (odb *ObjectDatabase) DeleteObject(collectionName, objectId string) error

func (*ObjectDatabase) DeleteObjects

func (odb *ObjectDatabase) DeleteObjects(collectionName string, objectIds []string) (float64, error)

func (*ObjectDatabase) DeleteStorage

func (odb *ObjectDatabase) DeleteStorage() error

func (*ObjectDatabase) GetCollectionCounts

func (odb *ObjectDatabase) GetCollectionCounts() (map[string]int, error)

func (*ObjectDatabase) GetCollectionsInfo

func (odb *ObjectDatabase) GetCollectionsInfo() (map[string]CollectionInfo, error)

func (*ObjectDatabase) GetObject

func (odb *ObjectDatabase) GetObject(collectionName, objectId string) (Object, error)

func (*ObjectDatabase) GetObjectIds

func (odb *ObjectDatabase) GetObjectIds(collectionName string, options *GetObjectsOptions) ([]string, error)

func (*ObjectDatabase) GetObjects

func (odb *ObjectDatabase) GetObjects(collectionName string, options *GetObjectsOptions) ([]Object, error)

func (*ObjectDatabase) PutObject

func (odb *ObjectDatabase) PutObject(collectionName string, object Object) (Object, error)

func (*ObjectDatabase) PutObjects

func (odb *ObjectDatabase) PutObjects(collectionName string, objects []Object) (float64, error)

type PostObjectsResponse

type PostObjectsResponse struct {
	Failed   map[string]string `json:"failed"`
	Modified float64           `json:"modified"`
	Success  []string          `json:"success"`
}

Jump to

Keyboard shortcuts

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