services

package
v0.0.0-...-d9c4052 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2014 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	URL                   string `json:"url"`
	Port                  string `json:"port"`
	StaticContentPath     string `json:"static_content_path"`
	RedisAddress          string `json:"redis_address"`
	SecretKey             string `json:"secret_key"`
	SessionName           string `json:"session_name"`
	DatabaseUrl           string `json:"database_url"`
	DatabaseName          string `json:"database_name"`
	Debug                 bool   `json:"debug"`
	SecureCookies         bool   `json:"secure_cookies"`
	StorePath             string `json:"store_path"`
	ThumbnailStorePath    string `json:"thumbnail_store_path"`
	WebStorePath          string `json:"web_store_path"`
	WebThumbnailStorePath string `json:"web_thumbnail_store_path"`
	LogsPath              string `json:"logs_path"`
	UseHTTPS              bool   `json:"use_https"`
	SSLCert               string `json:"ssl_cert"`
	SSLKey                string `json:"ssl_key"`
}

Config gathers all the necessary data to run the app

func NewConfig

func NewConfig(configPath string) (*Config, error)

NewConfig creates a new config struct

type Connection

type Connection struct {
	Session *mgo.Session
	Db      *mgo.Database
}

Connection represents the database session

func NewDatabaseConn

func NewDatabaseConn(config *Config) (*Connection, error)

NewDatabaseConn initializes the database connection

func (*Connection) C

func (c *Connection) C(collection string) *mgo.Collection

C returns a pointer to a mgo.Collection

func (*Connection) Close

func (c *Connection) Close()

Close closes mongodb open connection

func (*Connection) Remove

func (c *Connection) Remove(collection string, ID bson.ObjectId) error

Remove removes an item with the specified id on the given collection

func (*Connection) Save

func (c *Connection) Save(collection string, ID bson.ObjectId, item interface{}) error

Save inserts an item or updates it if it has already been created

type TaskService

type TaskService struct {
	redis.Conn
}

func NewTaskService

func NewTaskService(config *Config) (*TaskService, error)

NewTaskSercice initializes the task service

func (*TaskService) Close

func (ts *TaskService) Close()

Close closes mongodb open connection

func (*TaskService) Do

func (ts *TaskService) Do(commandName string, args ...interface{}) (reply interface{}, err error)

Do performs a Redis commant

func (*TaskService) FailedOpSolved

func (ts *TaskService) FailedOpSolved(task string, taskID, opID bson.ObjectId) error

FailedOpSolved marks a previously failed operation as solved and erases its data

func (*TaskService) PushFail

func (ts *TaskService) PushFail(task string, taskID bson.ObjectId, args ...interface{}) bson.ObjectId

PushFail pushes a failed operation to Redis

func (*TaskService) PushTask

func (ts *TaskService) PushTask(task string, args ...interface{}) bson.ObjectId

PushTask pushes a task to Redis

func (*TaskService) TaskDone

func (ts *TaskService) TaskDone(task string, taskID bson.ObjectId) error

TaskDone clears all the data for the given task

func (*TaskService) TaskResolver

func (ts *TaskService) TaskResolver(conn *Connection)

TaskResolver is a process that takes care of the failed operations pushed to redis. The resolver tries to run again the task. If the task can't be completed by the resolver it will get discarded.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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