The lightweight client to interact with the RADOS cluster purely implemented with golang.
When your application interacts with ceph, there will be needs to connect to the RADOS cluster in addition to S3(radosgw), file system(cephfs) and raw device(rbd). Thanks for the librados, which provides the common API to fullfil the demand mentioned before, and if you develop your application with Golang, there is also a project called go-ceph providing a librados binding with cgo. It is the first solution for applications to connect RADOS cluster directly. It's easy to use and works OK and I used it in one project, but there are some problems annoying me:
There are also some other problems if you want to build a elegant solution for you golang application interacting with the RADOS cluster. So the idea for gorados comes out. There is every reason to implement the gorados - pure go client to connect the RADOS cluster - to make ceph as a backend storage in production-level golang project directly.
The implementation key points are:
It implements the framework to connect to the ceph-mon and can send monitor commands to make some control to the cluster. Further functions sush as interaction to the ceph-osd need more development.
The following code snippet shows how to get the status of the RADOS cluster:
import (
"context"
"encoding/json"
"log"
"github.com/oshynsong/gorados"
)
func main() {
ctx := context.Backgroud()
// 1. prepare to create a connection to ceph-mon
c := gorados.NewRadosConn(ctx, gorados.MON)
// 2. dial the TCP socket
if err := c.Dial("tcp", "10.10.10.12:6789"); err != nil {
log.Fatal(err)
}
// 3. connect to the ceph-mon with the cephx protocol
if err := c.Connect("AQAXzGxdPT7BIBAAVz8zMAw+70YdylosZcijng=="); err != nil {
log.Fatal(err)
}
defer c.Close()
// 4. send a monitor command
cmd, _ := json.Marshal(map[string]interface{}{
"prefix": "status",
"format": "text",
})
res, err := c.MonCommand(cmd)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(res))
}
Reference locates on the golang.org here.
It needs more development and improvement to make gorados strong and stable. Just fork this repository and make pull request.
Version | Tag | Published |
---|---|---|
v0.0.0-20191216034844-78f61c6cabd6 | 1yr ago |