Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/chai2010/etcdfs
(WIP)virtual file system on etcd
https://github.com/chai2010/etcdfs
Last synced: 3 months ago
JSON representation
(WIP)virtual file system on etcd
- Host: GitHub
- URL: https://github.com/chai2010/etcdfs
- Owner: chai2010
- License: bsd-3-clause
- Created: 2018-04-24T21:49:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-25T05:59:09.000Z (over 6 years ago)
- Last Synced: 2024-10-06T01:18:21.914Z (3 months ago)
- Language: Go
- Homepage: https://godoc.org/github.com/chai2010/etcdfs
- Size: 11.7 KB
- Stars: 1
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# etcdfs: virtual file system on etcd
[![Build Status](https://travis-ci.org/chai2010/etcdfs.svg)](https://travis-ci.org/chai2010/etcdfs)
[![Go Report Card](https://goreportcard.com/badge/github.com/chai2010/etcdfs)](https://goreportcard.com/report/github.com/chai2010/etcdfs)
[![GoDoc](https://godoc.org/github.com/chai2010/etcdfs?status.svg)](https://godoc.org/github.com/chai2010/etcdfs)## Install
1. `go get github.com/chai2010/etcdfs`
## Example
Start etcd in local:
etcd
Put some data to edcd:
ETCDCTL_API=3 etcdctl put /abc/readme.md abc/aaa-value
ETCDCTL_API=3 etcdctl put /abc/hello.go "package main; func main(){}"
ETCDCTL_API=3 etcdctl get --prefix ""Create go progrom:
```go
package mainimport (
"flag"
"log"
"net/http"
"strings"
"time""golang.org/x/tools/godoc/vfs"
"golang.org/x/tools/godoc/vfs/httpfs""github.com/chai2010/etcdfs"
)var (
flagEtcdHost = flag.String("ectd-host", "localhost:2379", "set etcd nodes")
)func main() {
flag.Parse()etcdClient, err := etcdfs.NewEtcdClient(strings.Split(*flagEtcdHost, ","), time.Second/10)
if err != nil {
log.Fatal(err)
}ns := vfs.NameSpace{}
ns.Bind("/", etcdfs.New(etcdClient), "/", vfs.BindReplace)http.Handle("/", http.FileServer(httpfs.New(ns)))
log.Fatal(http.ListenAndServe(":8080", nil))
}
```Run the program ([hello.go](hello.go)):
go run hello.go
Then open http://127.0.0.1:8080/ in browser.
## BUGS
Report bugs to .
Thanks!