本文整理匯總了Golang中github.com/ernestokarim/cb/registry.Queue類的典型用法代碼示例。如果您正苦於以下問題:Golang Queue類的具體用法?Golang Queue怎麽用?Golang Queue使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Queue類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: doForm
func doForm(c *config.Config, q *registry.Queue, mode string) error {
if !templates.IsRegistered(mode) {
return fmt.Errorf("unrecognized template mode: %s", mode)
}
templates.SetMode(mode)
filename := q.NextTask()
if filename == "" {
return fmt.Errorf("validator filename not passed as an argument")
}
q.RemoveNextTask()
form, err := parseForm(filename)
if err != nil {
return fmt.Errorf("parse form failed: %s", err)
}
result := strings.Replace(form.Build(), "'", `'"'"'`, -1)
args := []string{
"-c", fmt.Sprintf(`echo -n '%s' | xsel -bi`, result),
}
output, err := utils.Exec("bash", args)
if err != nil {
fmt.Println(output)
return fmt.Errorf("bash error: %s", err)
}
return nil
}
示例2: push
func push(c *config.Config, q *registry.Queue) error {
scriptsPath := utils.PackagePath(selfPkg)
host := c.GetRequired("push")
// FTP User & password
user := q.NextTask()
if user == "" {
return fmt.Errorf("ftp user required as the first argument")
}
q.RemoveNextTask()
password, err := gopass.GetPass(fmt.Sprintf("Enter \"%s\" password: ", user))
if err != nil {
return fmt.Errorf("cannot read password: %s", err)
}
if password == "" {
return fmt.Errorf("ftp password is required")
}
// Hash local files
log.Printf("Hashing local files... ")
localHashes, err := hashLocalFiles()
if err != nil {
return fmt.Errorf("hash local files failed: %s", err)
}
log.Printf("Hashing local files... %s[SUCCESS]%s\n", colors.Green, colors.Reset)
// Hash remote files
log.Printf("Hashing remote files... ")
remoteHashes, err := retrieveRemoteHashes(scriptsPath, user, password, host)
if err != nil {
return fmt.Errorf("retrieve remote hashes failed: %s", err)
}
log.Printf("Hashing remote files... %s[SUCCESS]%s\n", colors.Green, colors.Reset)
if err := saveLocalHashes(localHashes); err != nil {
return fmt.Errorf("save local hashes failed: %s", err)
}
// Prepare FTP commands
log.Printf("Preparing FTP commands... ")
if err := prepareFTPCommands(localHashes, remoteHashes); err != nil {
return fmt.Errorf("prepare FTP commands failed: %s", err)
}
log.Printf("Preparing FTP commands... %s[SUCCESS]%s\n", colors.Green, colors.Reset)
// Upload files
log.Printf("Uploading files... ")
if err := uploadFiles(scriptsPath, user, password, host); err != nil {
return fmt.Errorf("uploading files failed: %s", err)
}
log.Printf("Uploading files... %s[SUCCESS]%s\n", colors.Green, colors.Reset)
return nil
}
示例3: server
func server(c *config.Config, q *registry.Queue) error {
tasks := []string{
"update:[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
}
if err := q.RunTasks(c, tasks); err != nil {
return err
}
sc, err := readServeConfig(c)
if err != nil {
return err
}
if err := configureExts(); err != nil {
return fmt.Errorf("configure exts failed")
}
if *config.Verbose {
log.Printf("proxy url: %s (serve base: %+v)\n", sc.url, sc.base)
log.Printf("proxy mappings: %+v\n", sc.proxy)
}
http.Handle("/scenarios/", wrapHandler(c, q, scenariosHandler))
http.Handle("/test", wrapHandler(c, q, testHandler))
http.Handle("/utils.js", wrapHandler(c, q, scenariosHandler))
http.Handle("/angular-scenario.js", wrapHandler(c, q, angularScenarioHandler))
http.Handle("/scripts/", wrapHandler(c, q, appHandler))
http.Handle("/styles/", wrapHandler(c, q, stylesHandler))
http.Handle("/fonts/", wrapHandler(c, q, appHandler))
http.Handle("/images/", wrapHandler(c, q, appHandler))
http.Handle("/components/", wrapHandler(c, q, appHandler))
http.Handle("/views/", wrapHandler(c, q, appHandler))
p, err := NewProxy(sc)
if err != nil {
return fmt.Errorf("cannot prepare proxy: %s", err)
}
http.Handle("/", p)
for _, proxyURL := range sc.proxy {
log.Printf("%sserving app at http://%s/...%s\n", colors.Yellow, proxyURL.host, colors.Reset)
}
if err := http.ListenAndServe(fmt.Sprintf(":%d", *config.Port), nil); err != nil {
return fmt.Errorf("server listener failed: %s", err)
}
return nil
}
示例4: service
func service(c *config.Config, q *registry.Queue) error {
name := q.NextTask()
if name == "" {
return fmt.Errorf("first arg should be the name of the service")
}
q.RemoveNextTask()
module := q.NextTask()
if module == "" {
return fmt.Errorf("second arg should be the module of the service")
}
q.RemoveNextTask()
data := &serviceData{
Name: name,
Module: module,
Filename: filepath.Join(strings.Split(module, ".")...),
}
if err := writeServiceFile(data); err != nil {
return fmt.Errorf("write service failed: %s", err)
}
if err := writeServiceTestFile(data); err != nil {
return fmt.Errorf("write service test failed: %s", err)
}
return nil
}
示例5: updateCheck
func updateCheck(c *config.Config, q *registry.Queue) error {
// Check update-check file before updating again
shouldCheck, err := checkShouldCheckUpdate()
if err != nil {
return err
}
if !shouldCheck {
return nil
}
// Fetch last commits, both localy & remotely
latestSha, err := fetchLatestCommit()
if err != nil {
return err
}
currentSha, err := fetchCurrentCommit()
if err != nil {
return err
}
// Couldn't retrieve current/latest commit, ignore update
if latestSha == "" || currentSha == "" {
if *config.Verbose {
log.Printf("local or remote version was not retrieved correctly\n")
}
return nil
}
if err := writeCheckUpdate(); err != nil {
return err
}
// No update, return directly
if latestSha == currentSha {
if *config.Verbose {
log.Printf("same version detected\n")
}
return nil
}
// Ask for update
if utils.Ask("There's a new CB version. Do you want to auto-update it?") {
return q.RunTasks(c, []string{"[email protected]"})
}
return nil
}
示例6: build
func build(c *config.Config, q *registry.Queue) error {
q.AddTasks([]string{
"update:[email protected]",
"[email protected]",
"dist:[email protected]",
"recess:[email protected]",
"sass:[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"[email protected]",
"dist:[email protected]",
})
deploy := c.GetDefault("deploy.mode", "")
if len(deploy) > 0 {
q.AddTask(fmt.Sprintf("deploy:%s", deploy))
}
return nil
}
示例7: initTask
func initTask(c *config.Config, q *registry.Queue) error {
// Check for updates
if err := q.RunTasks(c, []string{"update:check"}); err != nil {
return err
}
// Retrieve the current working directory
cur, err := os.Getwd()
if err != nil {
return fmt.Errorf("getwd failed: %s", err)
}
// Go back one folder if we're inside the client one
if filepath.Base(cur) == "client" {
cur = filepath.Dir(cur)
if pathErr := os.Chdir(cur); pathErr != nil {
return fmt.Errorf("chdir to root folder failed: %s", err)
}
}
// Prepare some paths and start copying from the root templates folder
parts := strings.Split(q.CurTask, ":")
base := utils.PackagePath(filepath.Join(selfPkg, parts[1]))
appname := filepath.Base(cur)
if err := copyFiles(c, appname, base, cur, cur); err != nil {
return fmt.Errorf("copy files failed: %s", err)
}
// Post-init steps
if err := postInit(); err != nil {
return fmt.Errorf("post init failed: %s", err)
}
return nil
}
示例8: controller_noview
func controller_noview(c *config.Config, q *registry.Queue) error {
name := q.NextTask()
if name == "" {
return fmt.Errorf("first arg should be the name of the controller")
}
q.RemoveNextTask()
if !strings.Contains(name, "Ctrl") {
name = name + "Ctrl"
}
module := q.NextTask()
if module == "" {
return fmt.Errorf("second arg should be the module of the controller")
}
q.RemoveNextTask()
route := q.NextTask()
q.RemoveNextTask()
data := &controllerData{
Name: name,
Module: module,
Route: route,
Filename: filepath.Join(strings.Split(module, ".")...),
AppPath: c.GetDefault("paths.app", filepath.Join("app", "scripts", "app.js")),
}
if err := writeControllerFile(data); err != nil {
return fmt.Errorf("write controller failed: %s", err)
}
if err := writeControllerTestFile(data); err != nil {
return fmt.Errorf("write controller test failed: %s", err)
}
if route != "" {
if err := writeControllerRouteFile(data); err != nil {
return fmt.Errorf("write route failed: %s", err)
}
}
return nil
}
示例9: e2eCompiled
func e2eCompiled(c *config.Config, q *registry.Queue) error {
q.AddTask("server:angular:compiled")
return nil
}
示例10: e2e
func e2e(c *config.Config, q *registry.Queue) error {
q.AddTask("server")
return nil
}