Skip to content

s3_message_store

messageflux.iodevices.objectstorage.s3_message_store

BucketNameFormatterBase

a base class for formatter to manipulate the bucket name in case it needs to be different then the device name

format_name

format_name(device_name, message_bundle)

uses the given parameters to determine what the bucket name should be

Parameters:

Name Type Description Default
device_name str

the name of the device

required
message_bundle MessageBundle

the message that was sent to the device

required

Returns:

Type Description
str

the bucket name

S3MessageStore

S3MessageStore(
    s3_resource=None,
    magic=b"__S3_MSGSTORE__",
    auto_create_bucket=False,
    bucket_name_formatter=None,
    put_object_extra_args=None,
)

Bases: _S3MessageStoreBase

a message store that uses S3 as it's base

An S3 based message store

Parameters:

Name Type Description Default
s3_resource Optional[S3ServiceResource]

the s3 resource from boto (or None, to create it from env vars)

None
auto_create_bucket bool

Whether or not a bucket will be created when a message is being put in a nonexistent one.

False
bucket_name_formatter Optional[BucketNameFormatterBase]

a formatter to use to manipulate the bucket name. if none is given the device name will be used

None
put_object_extra_args Optional[Dict[str, Any]]

extra args to give to bucket.put_object(). i.e 'StorageClass'

None

S3UploadMessageStore

S3UploadMessageStore(
    s3_resource=None,
    magic=b"__S3_UPLOAD_MSGSTORE__",
    auto_create_bucket=False,
    bucket_name_formatter=None,
    upload_extra_args=None,
)

Bases: _S3MessageStoreBase

a message store that uses S3 as it's base (using upload_file method)

An S3 based message store

Parameters:

Name Type Description Default
s3_resource Optional[S3ServiceResource]

the s3 resource from boto (or None, to create it from env vars)

None
auto_create_bucket bool

Whether or not a bucket will be created when a message is being put in a nonexistent one.

False
bucket_name_formatter Optional[BucketNameFormatterBase]

a formatter to use to manipulate the bucket name. if none is given the device name will be used

None
upload_extra_args Optional[Dict[str, Any]]

extra args to give to client.upload_fileobj(). i.e 'StorageClass'

None