本文整理汇总了Golang中github.com/google/cayley/graph.Handle类的典型用法代码示例。如果您正苦于以下问题:Golang Handle类的具体用法?Golang Handle怎么用?Golang Handle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Handle类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
// No command? It's time for usage.
if len(os.Args) == 1 {
fmt.Fprintln(os.Stderr, "Cayley is a graph store and graph query layer.")
usage()
os.Exit(1)
}
cmd := os.Args[1]
os.Args = append(os.Args[:1], os.Args[2:]...)
flag.Parse()
var buildString string
if Version != "" {
buildString = fmt.Sprint("Cayley ", Version, " built ", BuildDate)
glog.Infoln(buildString)
}
cfg := configFrom(*configFile)
if os.Getenv("GOMAXPROCS") == "" {
runtime.GOMAXPROCS(runtime.NumCPU())
glog.Infoln("Setting GOMAXPROCS to", runtime.NumCPU())
} else {
glog.Infoln("GOMAXPROCS currently", os.Getenv("GOMAXPROCS"), " -- not adjusting")
}
var (
handle *graph.Handle
err error
)
switch cmd {
case "version":
if Version != "" {
fmt.Println(buildString)
} else {
fmt.Println("Cayley snapshot")
}
os.Exit(0)
case "init":
err = db.Init(cfg)
if err != nil {
break
}
if *quadFile != "" {
handle, err = db.Open(cfg)
if err != nil {
break
}
err = internal.Load(handle.QuadWriter, cfg, *quadFile, *quadType)
if err != nil {
break
}
handle.Close()
}
case "load":
handle, err = db.Open(cfg)
if err != nil {
break
}
err = internal.Load(handle.QuadWriter, cfg, *quadFile, *quadType)
if err != nil {
break
}
handle.Close()
case "repl":
handle, err = db.Open(cfg)
if err != nil {
break
}
if !graph.IsPersistent(cfg.DatabaseType) {
err = internal.Load(handle.QuadWriter, cfg, "", *quadType)
if err != nil {
break
}
}
err = db.Repl(handle, *queryLanguage, cfg)
handle.Close()
case "http":
handle, err = db.Open(cfg)
if err != nil {
break
}
if !graph.IsPersistent(cfg.DatabaseType) {
err = internal.Load(handle.QuadWriter, cfg, "", *quadType)
if err != nil {
break
}
}
http.Serve(handle, cfg)
handle.Close()
//.........这里部分代码省略.........
开发者ID:oliverp19,项目名称:cayley,代码行数:101,代码来源:cayley.go
示例2: main
func main() {
// No command? It's time for usage.
if len(os.Args) == 1 {
Usage()
os.Exit(1)
}
cmd := os.Args[1]
var newargs []string
newargs = append(newargs, os.Args[0])
newargs = append(newargs, os.Args[2:]...)
os.Args = newargs
flag.Parse()
var buildString string
if VERSION != "" {
buildString = fmt.Sprint("Cayley ", VERSION, " built ", BUILD_DATE)
glog.Infoln(buildString)
}
cfg := config.ParseConfigFromFlagsAndFile(*configFile)
if os.Getenv("GOMAXPROCS") == "" {
runtime.GOMAXPROCS(runtime.NumCPU())
glog.Infoln("Setting GOMAXPROCS to", runtime.NumCPU())
} else {
glog.Infoln("GOMAXPROCS currently", os.Getenv("GOMAXPROCS"), " -- not adjusting")
}
var (
handle *graph.Handle
err error
)
switch cmd {
case "version":
if VERSION != "" {
fmt.Println(buildString)
} else {
fmt.Println("Cayley snapshot")
}
os.Exit(0)
case "init":
err = db.Init(cfg)
if err != nil {
break
}
if *tripleFile != "" {
handle, err = db.Open(cfg)
if err != nil {
break
}
err = load(handle.QuadWriter, cfg, *tripleFile, *tripleType)
if err != nil {
break
}
handle.Close()
}
case "load":
handle, err = db.Open(cfg)
if err != nil {
break
}
err = load(handle.QuadWriter, cfg, *tripleFile, *tripleType)
if err != nil {
break
}
handle.Close()
case "repl":
handle, err = db.Open(cfg)
if err != nil {
break
}
if !graph.IsPersistent(cfg.DatabaseType) {
err = load(handle.QuadWriter, cfg, "", *tripleType)
if err != nil {
break
}
}
err = db.Repl(handle, *queryLanguage, cfg)
handle.Close()
case "http":
handle, err = db.Open(cfg)
if err != nil {
break
}
if !graph.IsPersistent(cfg.DatabaseType) {
err = load(handle.QuadWriter, cfg, "", *tripleType)
if err != nil {
break
}
}
http.Serve(handle, cfg)
//.........这里部分代码省略.........
开发者ID:kris-lab,项目名称:cayley,代码行数:101,代码来源:cayley.go
注:本文中的github.com/google/cayley/graph.Handle类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论