Exemple #1
0
// Return a Iterator object that can be used to list the object names in the current pool
func (ioctx *IOContext) Iter() (*Iter, error) {
	iter := Iter{}
	if cerr := C.rados_objects_list_open(ioctx.ioctx, &iter.ctx); cerr < 0 {
		return nil, GetRadosError(int(cerr))
	}
	return &iter, nil
}
Exemple #2
0
func (r *RadosIoCtx) ObjectsListOpen() (*RadosListCtx, error) {
	var list_ctx C.rados_list_ctx_t
	cerr := C.rados_objects_list_open(*r.ctx, &list_ctx)
	if cerr < 0 {
		return nil, errors.New("list object failed")
	}
	return &RadosListCtx{&list_ctx}, nil
}
Exemple #3
0
// OpenObjectList returns an ObjectList handler to start iterating over objects of a pool.
func (pool *Pool) OpenObjectList() (*ObjectList, error) {
	objectList := new(ObjectList)
	objectList.ioContext = pool.context
	ret := C.rados_objects_list_open(objectList.ioContext, &objectList.listContext)
	if err := toRadosError(ret); err != nil {
		err.Message = "Unable to open object list"
		return nil, err
	}
	return objectList, nil
}
Exemple #4
0
// ListObjects lists all of the objects in the pool associated with the I/O
// context, and called the provided listFn function for each object, passing
// to the function the name of the object.
func (ioctx *IOContext) ListObjects(listFn ObjectListFunc) error {
	var ctx C.rados_list_ctx_t
	ret := C.rados_objects_list_open(ioctx.ioctx, &ctx)
	if ret < 0 {
		return RadosError(ret)
	}
	defer func() { C.rados_objects_list_close(ctx) }()

	for {
		var c_entry *C.char
		ret := C.rados_objects_list_next(ctx, &c_entry, nil)
		if ret == -2 { // FIXME
			return nil
		} else if ret < 0 {
			return RadosError(ret)
		}
		listFn(C.GoString(c_entry))
	}

	panic("invalid state")
}