func FindByName(name string) (*Action, error) {
	conn, err := db.Conn()
	if err != nil {
		logger().Error(err)
		return nil, err
	}
	defer conn.Close()
	var action Action
	err = conn.Actions().Find(bson.M{"name": name}).One(&action)
	if err != nil {
		if err == mgo.ErrNotFound {
			err = fmt.Errorf("action %q not found", name)
		}
		logger().Error(err)
		return nil, err
	}
	return &action, nil
}
FindByName finds action by name.
package action
import (
	"errors"
	"fmt"
	"net/http"
	"strings"
	"github.com/tsuru/tsuru-autoscale/db"
	"github.com/tsuru/tsuru-autoscale/log"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)
func logger() *log.Logger {
	return log.Log()
}
type Action struct {
	Name    string
	URL     string
	Method  string
	Body    string
	Headers map[string]string
}
func New(a *Action) error {
	if a.URL == "" {
		return errors.New("action: url required")
	}
	if a.Method == "" {
		return errors.New("action: method required")
	}
	conn, err := db.Conn()
	if err != nil {
		logger().Error(err)
		return err
	}
	defer conn.Close()
	return conn.Actions().Insert(&a)
}