-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit implements binding for rados_getaddrs. Includes a unit test. Signed-off-by: Robert Vasek <[email protected]>
- Loading branch information
1 parent
df3b6a9
commit da1e313
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//go:build ceph_preview | ||
|
||
package rados | ||
|
||
// #cgo LDFLAGS: -lrados | ||
// #include <stdlib.h> | ||
// #include <rados/librados.h> | ||
import "C" | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
// GetAddrs returns the addresses of the RADOS session, | ||
// suitable for blocklisting. | ||
// | ||
// Implements: | ||
// | ||
// int rados_getaddrs(rados_t cluster, char **addrs) | ||
func (c *Conn) GetAddrs() (string, error) { | ||
var cAddrs *C.char | ||
defer C.free(unsafe.Pointer(cAddrs)) | ||
|
||
ret := C.rados_getaddrs(c.cluster, &cAddrs) | ||
if ret < 0 { | ||
return "", getError(ret) | ||
} | ||
|
||
return C.GoString(cAddrs), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//go:build ceph_preview | ||
|
||
package rados | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func (suite *RadosTestSuite) TestGetAddrs() { | ||
suite.SetupConnection() | ||
|
||
addrs, err := suite.conn.GetAddrs() | ||
assert.NoError(suite.T(), err) | ||
assert.NotEmpty(suite.T(), addrs, "rados_getaddrs") | ||
} |