Skip to content

Bucket

reduct.Bucket

A bucket of data in Reduct Storage

get_entry_list() async

Get list of entries with their stats

Returns:

Type Description
List[EntryInfo]

List[EntryInfo]

Raises:

Type Description
ReductError

if there is an HTTP error

get_settings() async

Get current bucket settings

Returns:

Name Type Description
BucketSettings BucketSettings

Raises:

Type Description
ReductError

if there is an HTTP error

info() async

Get statistics about bucket

Returns:

Name Type Description
BucketInfo BucketInfo

Raises:

Type Description
ReductError

if there is an HTTP error

list(entry_name, start, stop) async

Get a list of records in an entry for a specified time interval

Parameters:

Name Type Description Default
entry_name str

name of entry in the bucket

required
start int

the beginning of the time interval

required
stop int

the end of the time interval

required

Raises:

Type Description
ReductError

if there is an HTTP error

Returns:

Type Description
List[Tuple[int, int]]

List[Tuple[int,int]]: list of tuples, where each tuple

List[Tuple[int, int]]

has time stamp (first element) of a record and its size in bytes

query(entry_name, start=None, stop=None, ttl=None) async

Query data for a time interval

async for record in bucket.query("entry-1", stop=time.time_ns() / 1000): data: bytes = record.read_all() # or async for chunk in record.read(n=1024): print(chunk)

Parameters:

Name Type Description Default
entry_name str

name of entry in the bucket

required
start Optional[int]

the beginning of the time interval

None
stop Optional[int]

the end of the time interval

None
ttl Optional[int]

Time To Live of the request in seconds

None

Returns:

Type Description
AsyncIterator[Record]

AsyncIterator[Record]: iterator to the records

read(entry_name, timestamp=None) async

Read a record from entry

Parameters:

Name Type Description Default
entry_name str

name of entry in the bucket

required
timestamp Optional[int]

UNIX timestamp in microseconds - if None: get the latest record

None

Returns:

Name Type Description
bytes bytes

Raises:

Type Description
ReductError

if there is an HTTP error

read_by(entry_name, timestamp=None, chunk_size=1024) async

Read a record from entry in chunks

async for chunk in bucket.read_by("entry-1", chunk_size=1024): print(chunk)

Parameters:

Name Type Description Default
entry_name str

name of entry in the bucket

required
timestamp Optional[int]

UNIX timestamp in microseconds

None
chunk_size int 1024

Returns:

Name Type Description
bytes AsyncIterator[bytes]

Raises:

Type Description
ReductError

if there is an HTTP error

remove() async

Remove bucket

Raises:

Type Description
ReductError

if there is an HTTP error

set_settings(settings) async

Update bucket settings

Parameters:

Name Type Description Default
settings BucketSettings

new settings

required

Raises:

Type Description
ReductError

if there is an HTTP error

write(entry_name, data, timestamp=None, content_length=None) async

Write a record to entry

await bucket.write("entry-1", b"some_data", timestamp=19231023101)

You can write data chunk-wise using an asynchronous iterator and the size of the content:

async def sender(): for chunk in [b"part1", b"part2", b"part3"]: yield chunk await bucket.write("entry-1", sender(), content_length=15)

Parameters:

Name Type Description Default
entry_name str

name of entry in the bucket

required
data Union[bytes, AsyncIterator[bytes]]

bytes to write or async iterator

required
timestamp Optional[int]

UNIX time stamp in microseconds. Current time if it's None

None
content_length Optional[int]

content size in bytes, needed only when the data is an iterator

None

Raises:

Type Description
ReductError

if there is an HTTP error