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_full_info() async

Get full information about bucket (settings, statistics, entries)

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

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

Query data for a time interval

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

Other Parameters:

Name Type Description
include dict

query records which have all labels from this dict

exclude dict

querz records which doesn't have all labels from this dict

Returns:

Type Description
AsyncIterator[Record]

AsyncIterator[Record]: iterator to the records

Examples:

>>> 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)

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:

Type Description
AsyncIterator[Record]

async context, which generates Records

Raises:

Type Description
ReductError

if there is an HTTP error

Examples:

>>> async def reader():
>>>     async with bucket.read("entry", timestamp=123456789) as record:
>>>         data = await record.read_all()

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, **kwargs) async

Write a record to entry

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

Other Parameters:

Name Type Description
labels dict

labels as key-values

content_type str

content type of data

Raises:

Type Description
ReductError

if there is an HTTP error

Examples:

>>> 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)