Skip to content

Naming the extended client #27

Description

@damebrown

Since I use your library in high load, in order to not create a client in every call, I wrote the following code:

import sqs_extended_client

_sqs_extended_client = None

def get_sqs_extended_client():
    global _sqs_extended_client
    if not _sqs_extended_client:
        _sqs_extended_client = client(service_name='sqs', region_name=os.getenv(AWS_REGION, US_EAST_1))
        ~other _sqs_extended_client attribute initialization~
    return _sqs_extended_client


def send_message(args) -> None:
        get_sqs_extended_client().send_message(args)

As you can see it initializes the client only if it's None. Since the name sqs_extended_client is imported, this can be done only by giving the client a different name.
I saw that in all of your documentation you're using only the name sqs_extended_client in order to access the extended client.
I wanted to make sure this method is valid and that the session of _sqs_extended_client will be overridden by your library and create an extended client instead of a regular one.

In addition, since my IDE doesn't recognize _sqs_extended_client, it doesn't auto-complete any of the client's methods or variables I can call or override.
I'd like to make sure that I can override the client's s3_client field in the following way:
_sqs_extended_client.s3_client = client(service_name='s3', region_name=aws_region)
and that I don't need to call any of the getters/setters defined in the library's client.py file.
Thanks!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions