mirror of
https://github.com/ceph/go-ceph
synced 2024-12-23 06:33:24 +00:00
rados: rename pool to ioctx
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
This commit is contained in:
parent
7ca7bc5376
commit
7316c3d70f
@ -51,15 +51,15 @@ similar to a standard file I/O interface:
|
||||
|
||||
```go
|
||||
// open a pool handle
|
||||
pool, err := conn.OpenPool("mypool")
|
||||
ioctx, err := conn.OpenIOContext("mypool")
|
||||
|
||||
// write some data
|
||||
bytes_in := []byte("input data")
|
||||
err = pool.Write("obj", bytes_in, 0)
|
||||
err = ioctx.Write("obj", bytes_in, 0)
|
||||
|
||||
// read the data back out
|
||||
bytes_out := make([]byte, len(bytes_in))
|
||||
n_out, err := pool.Read("obj", bytes_out, 0)
|
||||
n_out, err := ioctx.Read("obj", bytes_out, 0)
|
||||
|
||||
if bytes_in != bytes_out {
|
||||
fmt.Println("Output is not input!")
|
||||
|
4
conn.go
4
conn.go
@ -79,10 +79,10 @@ func (c *Conn) ReadDefaultConfigFile() error {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Conn) OpenPool(pool string) (*Pool, error) {
|
||||
func (c *Conn) OpenIOContext(pool string) (*IOContext, error) {
|
||||
c_pool := C.CString(pool)
|
||||
defer C.free(unsafe.Pointer(c_pool))
|
||||
ioctx := &Pool{}
|
||||
ioctx := &IOContext{}
|
||||
ret := C.rados_ioctx_create(c.cluster, c_pool, &ioctx.ioctx)
|
||||
if ret == 0 {
|
||||
return ioctx, nil
|
||||
|
@ -7,14 +7,14 @@ import "C"
|
||||
|
||||
import "unsafe"
|
||||
|
||||
// Pool represents a context for performing I/O within a pool.
|
||||
type Pool struct {
|
||||
// IOContext represents a context for performing I/O within a pool.
|
||||
type IOContext struct {
|
||||
ioctx C.rados_ioctx_t
|
||||
}
|
||||
|
||||
// Write writes len(data) bytes to the object with key oid starting at byte
|
||||
// offset offset. It returns an error, if any.
|
||||
func (p *Pool) Write(oid string, data []byte, offset uint64) error {
|
||||
func (p *IOContext) Write(oid string, data []byte, offset uint64) error {
|
||||
c_oid := C.CString(oid)
|
||||
defer C.free(unsafe.Pointer(c_oid))
|
||||
|
||||
@ -32,7 +32,7 @@ func (p *Pool) Write(oid string, data []byte, offset uint64) error {
|
||||
|
||||
// Read reads up to len(data) bytes from the object with key oid starting at byte
|
||||
// offset offset. It returns the number of bytes read and an error, if any.
|
||||
func (p *Pool) Read(oid string, data []byte, offset uint64) (int, error) {
|
||||
func (p *IOContext) Read(oid string, data []byte, offset uint64) (int, error) {
|
||||
if len(data) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
@ -55,7 +55,7 @@ func (p *Pool) Read(oid string, data []byte, offset uint64) (int, error) {
|
||||
}
|
||||
|
||||
// Delete deletes the object with key oid. It returns an error, if any.
|
||||
func (p *Pool) Delete(oid string) error {
|
||||
func (p *IOContext) Delete(oid string) error {
|
||||
c_oid := C.CString(oid)
|
||||
defer C.free(unsafe.Pointer(c_oid))
|
||||
|
||||
@ -72,7 +72,7 @@ func (p *Pool) Delete(oid string) error {
|
||||
// enlarges the object, the new area is logically filled with zeroes. If the
|
||||
// operation shrinks the object, the excess data is removed. It returns an
|
||||
// error, if any.
|
||||
func (p *Pool) Truncate(oid string, size uint64) error {
|
||||
func (p *IOContext) Truncate(oid string, size uint64) error {
|
||||
c_oid := C.CString(oid)
|
||||
defer C.free(unsafe.Pointer(c_oid))
|
||||
|
@ -82,7 +82,7 @@ func TestGetClusterStats(t *testing.T) {
|
||||
err := conn.MakePool(poolname)
|
||||
assert.NoError(t, err)
|
||||
|
||||
pool, err := conn.OpenPool(poolname)
|
||||
pool, err := conn.OpenIOContext(poolname)
|
||||
assert.NoError(t, err)
|
||||
|
||||
// grab current stats
|
||||
@ -290,7 +290,7 @@ func TestReadWrite(t *testing.T) {
|
||||
err := conn.MakePool(pool_name)
|
||||
assert.NoError(t, err)
|
||||
|
||||
pool, err := conn.OpenPool(pool_name)
|
||||
pool, err := conn.OpenIOContext(pool_name)
|
||||
assert.NoError(t, err)
|
||||
|
||||
bytes_in := []byte("input data")
|
||||
|
Loading…
Reference in New Issue
Block a user