本文整理匯總了Golang中github.com/djbarber/ipfs-hack/core.IpfsNode.Process方法的典型用法代碼示例。如果您正苦於以下問題:Golang IpfsNode.Process方法的具體用法?Golang IpfsNode.Process怎麽用?Golang IpfsNode.Process使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/djbarber/ipfs-hack/core.IpfsNode
的用法示例。
在下文中一共展示了IpfsNode.Process方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Mount
// Mount mounts ipfs at a given location, and returns a mount.Mount instance.
func Mount(ipfs *core.IpfsNode, mountpoint string) (mount.Mount, error) {
cfg, err := ipfs.Repo.Config()
if err != nil {
return nil, err
}
allow_other := cfg.Mounts.FuseAllowOther
fsys := NewFileSystem(ipfs)
return mount.NewMount(ipfs.Process(), fsys, mountpoint, allow_other)
}
示例2: Serve
func Serve(node *core.IpfsNode, lis net.Listener, options ...ServeOption) error {
handler, err := makeHandler(node, lis, options...)
if err != nil {
return err
}
addr, err := manet.FromNetAddr(lis.Addr())
if err != nil {
return err
}
// if the server exits beforehand
var serverError error
serverExited := make(chan struct{})
node.Process().Go(func(p goprocess.Process) {
serverError = http.Serve(lis, handler)
close(serverExited)
})
// wait for server to exit.
select {
case <-serverExited:
// if node being closed before server exits, close server
case <-node.Process().Closing():
log.Infof("server at %s terminating...", addr)
lis.Close()
outer:
for {
// wait until server exits
select {
case <-serverExited:
// if the server exited as we are closing, we really dont care about errors
serverError = nil
break outer
case <-time.After(5 * time.Second):
log.Infof("waiting for server at %s to terminate...", addr)
}
}
}
log.Infof("server at %s terminated", addr)
return serverError
}