Skip to content

Commit

Permalink
rename project name.
Browse files Browse the repository at this point in the history
  • Loading branch information
jolestar committed Aug 26, 2016
1 parent 492d856 commit 3d48f88
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 91 deletions.
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# metadata-proxy
# metad


`metadata-proxy` is a metadata server support the following features:
`metad` is a metadata server support the following features:

* **self** semantic support. metadata-proxy keep a mapping of IP and metadata, client direct request "/self", will get the metadata of this node. mapping settings is store to backend (etcd).
* **self** semantic support. metad keep a mapping of IP and metadata, client direct request "/self", will get the metadata of this node. mapping settings is store to backend (etcd).
* metadata backend support [etcd](https://github.com/coreos/etcd) (TODO support more).
* support metadata local cache, so it can be used as a proxy to reducing the request pressure of backend (etcd).
* api out format support json/yaml/text,and is metadata/developer friendly data structure.
Expand All @@ -17,16 +17,16 @@ Go 1.6 is required to build confd, which uses the new vendor directory.

```
$ mkdir -p $GOPATH/src/github.com/yunify
$ git clone https://github.com/yunify/metadata-proxy.git $GOPATH/src/github.com/yunify/metadata-proxy
$ cd $GOPATH/src/github.com/yunify/metadata-proxy
$ git clone https://github.com/yunify/metad.git $GOPATH/src/github.com/yunify/metad
$ cd $GOPATH/src/github.com/yunify/metad
$ ./build
```

You should now have metadata-proxy in your `bin/` directory:
You should now have metad in your `bin/` directory:

```
$ ls bin/
metadata-proxy
metad
```

## Manage API
Expand All @@ -53,10 +53,10 @@ Manage API default port is 127.0.0.1:8112
etcd
```

* start metadata-proxy
* start metad

```
bin/metadata-proxy --backend etcdv3 --nodes 127.0.0.1:2379 --log_level debug --listen :8080 --xff true
bin/metad --backend etcdv3 --nodes 127.0.0.1:2379 --log_level debug --listen :8080 --xff true
```

* set etcd version
Expand All @@ -75,7 +75,7 @@ do
done
```

* fill data by metadata-proxy
* fill data by metad

```
curl -X POST -H "Content-Type: application/json" http://127.0.0.1:8112/v1/data -d '{"nodes":{"1":{"ip":"192.168.1.1","name":"node1"},"2":{"ip":"192.168.1.2","name":"node2"},"3":{"ip":"192.168.1.3","name":"node3"},"4":{"ip":"192.168.1.4","name":"node4"},"5":{"ip":"192.168.1.5","name":"node5"}}}'
Expand Down Expand Up @@ -142,15 +142,15 @@ node5
```


by metadata-proxy text output
by metad text output

```
curl http://127.0.0.1:8080/
nodes/
```

by metadata-proxy json output
by metad json output

```
curl -H "Accept: application/json" http://127.0.0.1:8080/
Expand Down Expand Up @@ -181,7 +181,7 @@ curl -H "Accept: application/json" http://127.0.0.1:8080/
}
```

by metadata-proxy yaml output
by metad yaml output

```
curl -H "Accept: application/yaml" http://127.0.0.1:8080/
Expand Down
23 changes: 2 additions & 21 deletions README_zh.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
# metadata-proxy
# metad


`metadata-proxy` 是一个元数据服务,主要提供以下功能:
`metad` 是一个元数据服务,主要提供以下功能:

* **self** 语义支持,在服务器端对 IP 和元数据做映射,客户端直接通过 /self 请求和本节点相关的元数据.映射设置会保存到后端存储服务进行持久化.
* 元数据后端存储支持 [etcd](https://github.com/coreos/etcd) (TODO 支持更多后端).
* 元数据缓存,可以降低对后端(etcd)的请求压力.
* 输出格式支持json/yaml/text,对配置以及开发更友好.
* 支持作为 [confd](https://github.com/kelseyhightower/confd) 的后端服务(TODO).


## Building

需要 Go 1.6 , 依赖通过 vendor 管理.

```
$ mkdir -p $GOPATH/src/github.com/yunify
$ git clone https://github.com/yunify/metadata-proxy.git $GOPATH/src/github.com/yunify/metadata-proxy
$ cd $GOPATH/src/github.com/yunify/metadata-proxy
$ ./build
```

编译后的 metadata-proxy 在 `bin/` 目录下:

```
$ ls bin/
metadata-proxy
```
8 changes: 4 additions & 4 deletions backends/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package backends

import (
"errors"
"github.com/yunify/metadata-proxy/backends/etcd"
"github.com/yunify/metadata-proxy/backends/etcdv3"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/store"
"github.com/yunify/metad/backends/etcd"
"github.com/yunify/metad/backends/etcdv3"
"github.com/yunify/metad/log"
"github.com/yunify/metad/store"
"strings"
)

Expand Down
6 changes: 3 additions & 3 deletions backends/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/json"
"fmt"
"github.com/stretchr/testify/assert"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/store"
"github.com/yunify/metadata-proxy/util/flatmap"
"github.com/yunify/metad/log"
"github.com/yunify/metad/store"
"github.com/yunify/metad/util/flatmap"
"math/rand"
"testing"
"time"
Expand Down
10 changes: 5 additions & 5 deletions backends/etcd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"crypto/x509"
"fmt"
"github.com/coreos/etcd/client"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/store"
"github.com/yunify/metadata-proxy/util"
"github.com/yunify/metadata-proxy/util/flatmap"
"github.com/yunify/metad/log"
"github.com/yunify/metad/store"
"github.com/yunify/metad/util"
"github.com/yunify/metad/util/flatmap"
"golang.org/x/net/context"
"io/ioutil"
"net"
Expand All @@ -18,7 +18,7 @@ import (
"time"
)

const SELF_MAPPING_PATH = "/_metadata-proxy/mapping"
const SELF_MAPPING_PATH = "/_metad/mapping"

// Client is a wrapper around the etcd client
type Client struct {
Expand Down
4 changes: 2 additions & 2 deletions backends/etcd/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package etcd
import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/store"
"github.com/yunify/metad/log"
"github.com/yunify/metad/store"
"math/rand"
"testing"
"time"
Expand Down
10 changes: 5 additions & 5 deletions backends/etcdv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import (
"fmt"
client "github.com/coreos/etcd/clientv3"
"github.com/coreos/etcd/mvcc/mvccpb"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/store"
"github.com/yunify/metadata-proxy/util"
"github.com/yunify/metadata-proxy/util/flatmap"
"github.com/yunify/metad/log"
"github.com/yunify/metad/store"
"github.com/yunify/metad/util"
"github.com/yunify/metad/util/flatmap"
"golang.org/x/net/context"
"io/ioutil"
"path"
"reflect"
"time"
)

const SELF_MAPPING_PATH = "/_metadata-proxy/mapping"
const SELF_MAPPING_PATH = "/_metad/mapping"

var (
//see github.com/coreos/etcd/etcdserver/api/v3rpc/key.go
Expand Down
4 changes: 2 additions & 2 deletions backends/etcdv3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package etcdv3
import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/store"
"github.com/yunify/metad/log"
"github.com/yunify/metad/store"
"math/rand"
"testing"
"time"
Expand Down
4 changes: 2 additions & 2 deletions build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

echo "Building metadata-proxy..."
echo "Building metad ..."
mkdir -p bin
go build -o bin/metadata-proxy .
go build -o bin/metad .
6 changes: 3 additions & 3 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package main
import (
"flag"
"fmt"
"github.com/yunify/metadata-proxy/backends"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/metadata"
"github.com/yunify/metad/backends"
"github.com/yunify/metad/log"
"github.com/yunify/metad/metadata"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
Expand Down
8 changes: 4 additions & 4 deletions example/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
backend: etcd
# Set log level: debug|info|warning
log_level: debug
pid_file: /var/run/metadata-proxy.pid
pid_file: /var/run/metad.pid
# X-Forwarded-For header support"
xff: true
# Default backend key prefix
Expand All @@ -16,11 +16,11 @@ listen_manage: 127.0.0.1:8112
# Use Basic Auth to authenticate (only used with -backend=etcd)
basic_auth: true
# The client ca keys
client_ca_keys: /opt/metadata-proxy/client_ca_keys
client_ca_keys: /opt/metad/client_ca_keys
# The client cert
client_cert: /opt/metadata-proxy/client_cert
client_cert: /opt/metad/client_cert
# The client key
client_key: /opt/metadata-proxy/client_key
client_key: /opt/metad/client_key
# List of backend nodes
nodes:
- 192.168.11.1:2379
Expand Down
12 changes: 6 additions & 6 deletions example/etcdv2.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# etcd v2 metadata-proxy demo
# etcd v2 metad demo

* start etcd

```
etcd
```

* start metadata-proxy
* start metad

```
bin/metadata-proxy --backend etcd --nodes 127.0.0.1:2379 --log_level debug --listen :8080 --xff true
bin/metad --backend etcd --nodes 127.0.0.1:2379 --log_level debug --listen :8080 --xff true
```

* fill data to etcd
Expand Down Expand Up @@ -170,15 +170,15 @@ curl "http://127.0.0.1:2379/v2/keys/?recursive=true"
}
```

by metadata-proxy text output
by metad text output

```
curl http://127.0.0.1:8080/
nodes/
```

by metadata-proxy json output
by metad json output

```
curl -H "Accept: application/json" http://127.0.0.1:8080/
Expand Down Expand Up @@ -209,7 +209,7 @@ curl -H "Accept: application/json" http://127.0.0.1:8080/
}
```

by metadata-proxy yaml output
by metad yaml output

```
curl -H "Accept: application/yaml" http://127.0.0.1:8080/
Expand Down
8 changes: 4 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"fmt"
"github.com/golang/gddo/httputil"
"github.com/gorilla/mux"
"github.com/yunify/metadata-proxy/backends"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/metadata"
"github.com/yunify/metad/backends"
"github.com/yunify/metad/log"
"github.com/yunify/metad/metadata"
yaml "gopkg.in/yaml.v2"
"io"
"net"
Expand Down Expand Up @@ -56,7 +56,7 @@ func main() {
os.Exit(-1)
}

log.Info("Starting metadata-proxy %s", VERSION)
log.Info("Starting metad %s", VERSION)
var err error
storeClient, err = backends.New(backendsConfig)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ func TestConfigFile(t *testing.T) {
config := Config{
Backend: "etcd",
LogLevel: "debug",
PIDFile: "/var/run/metadata-proxy.pid",
PIDFile: "/var/run/metad.pid",
EnableXff: true,
Prefix: "/users/uid1",
OnlySelf: true,
Listen: ":8080",
ListenManage: "127.0.0.1:8112",
BasicAuth: true,
ClientCaKeys: "/opt/metadata-proxy/client_ca_keys",
ClientCert: "/opt/metadata-proxy/client_cert",
ClientKey: "/opt/metadata-proxy/client_key",
ClientCaKeys: "/opt/metad/client_ca_keys",
ClientCert: "/opt/metad/client_cert",
ClientKey: "/opt/metad/client_key",
BackendNodes: []string{"192.168.11.1:2379", "192.168.11.2:2379"},
Username: "username",
Password: "password",
}

data, err := yaml.Marshal(config)
assert.NoError(t, err)
configFile, fileErr := ioutil.TempFile("/tmp", "metadata-proxy")
configFile, fileErr := ioutil.TempFile("/tmp", "metad")

fmt.Printf("configFile: %v \n", configFile.Name())

Expand Down
6 changes: 3 additions & 3 deletions metadata/metarepo.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package metadata

import (
"errors"
"github.com/yunify/metadata-proxy/backends"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/store"
"github.com/yunify/metad/backends"
"github.com/yunify/metad/log"
"github.com/yunify/metad/store"
"net"
"path"
"reflect"
Expand Down
8 changes: 4 additions & 4 deletions metadata/metarepo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package metadata
import (
"fmt"
"github.com/stretchr/testify/assert"
"github.com/yunify/metadata-proxy/backends"
"github.com/yunify/metadata-proxy/log"
"github.com/yunify/metadata-proxy/store"
"github.com/yunify/metadata-proxy/util/flatmap"
"github.com/yunify/metad/backends"
"github.com/yunify/metad/log"
"github.com/yunify/metad/store"
"github.com/yunify/metad/util/flatmap"
"math/rand"
"testing"
"time"
Expand Down
4 changes: 2 additions & 2 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package store

import (
"fmt"
"github.com/yunify/metadata-proxy/util"
"github.com/yunify/metadata-proxy/util/flatmap"
"github.com/yunify/metad/util"
"github.com/yunify/metad/util/flatmap"
"path"
"reflect"
"strings"
Expand Down
Loading

0 comments on commit 3d48f88

Please sign in to comment.