diff --git a/README.md b/README.md index 19357da..0ed1ba0 100644 --- a/README.md +++ b/README.md @@ -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!") diff --git a/conn.go b/conn.go index 9373f5e..0bc4bcd 100644 --- a/conn.go +++ b/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 diff --git a/pool.go b/ioctx.go similarity index 84% rename from pool.go rename to ioctx.go index 82e6a64..b3b2689 100644 --- a/pool.go +++ b/ioctx.go @@ -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)) diff --git a/rados_test.go b/rados_test.go index 048696a..8b85355 100644 --- a/rados_test.go +++ b/rados_test.go @@ -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")