Skip to content

Instantly share code, notes, and snippets.

@shuaihanhungry
Last active April 12, 2020 05:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuaihanhungry/150f666ef1f65324c99aa1ccfc006abb to your computer and use it in GitHub Desktop.
Save shuaihanhungry/150f666ef1f65324c99aa1ccfc006abb to your computer and use it in GitHub Desktop.
使用 pandora-go-sdk 中的 pipeline
package main
import (
"flag"
"log"
"time"
"github.com/qiniu/pandora-go-sdk/base"
"github.com/qiniu/pandora-go-sdk/base/config"
"github.com/qiniu/pandora-go-sdk/pipeline"
)
var (
defaultLogdbHost = "http://pipeline.qiniu.com"
defaultRespTimeout = 30 // minutes
)
var (
accessKey = flag.String("accessKey", "", "access key")
secretKey = flag.String("secretKey", "", "secret key")
respTimeout = flag.Int("respTimeout", defaultRespTimeout, "response timeout")
)
func main() {
flag.Parse()
checkParams()
logger := base.NewDefaultLogger()
logger.SetLoggerLevel(base.LogDebug)
logdbConfig := &config.Config{
Ak: *accessKey,
Sk: *secretKey,
Endpoint: defaultLogdbHost,
ResponseTimeout: time.Duration(*respTimeout) * time.Minute,
Logger: logger,
}
pipelineClient, err := pipeline.New(logdbConfig)
if err != nil {
log.Fatal("create pipeline client failed:", err)
}
listReposOuput, err := pipelineClient.ListRepos(&pipeline.ListReposInput{})
if err != nil {
log.Fatal("list repos failed:", err)
}
log.Printf("%#v", listReposOuput)
}
func checkParams() {
if *accessKey == "" || *secretKey == "" {
log.Fatal("please set your access key and secret key")
}
if *respTimeout <= 0 {
log.Fatal("option respTimeout should be non-negative integer")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment