Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent session support #107

Open
4 tasks
ir4y opened this issue Aug 4, 2023 · 1 comment
Open
4 tasks

Persistent session support #107

ir4y opened this issue Aug 4, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@ir4y
Copy link
Member

ir4y commented Aug 4, 2023

  • Add optinal http session parameter to the constructor
  • When we do a request
    async with aiohttp.ClientSession(headers=headers) as session:
    we should check if session is provided.
    If there is no session, the library creates a new session for this call (current behavior). When session is provided do request should use it instead of creating a new one.
  • Implement attach functional and describe best practices for usage AsyncFHIRClient with aiohttp.
class AsyncFHIRClient:
    ...
    @classmethod
    async def attach(
        cls: type["AsyncFHIRClient"], app: aiohttp.web_app.Application
    ) -> AsyncGenerator:
        session = aiohttp.ClientSession()
        client = cls(session=session)
        app[cls.key] = client
        yield
        await session.close()
    ...
app = web.Application()
app.cleanup_ctx.append(AsyncFHIRClient.attach)
def create_app(sdk: SDK):
    app = web.Application()
    app.cleanup_ctx.append(AidboxClient.attach)
    app.cleanup_ctx.append(init)
    app.update(
        settings=sdk.settings,
        sdk=sdk,
    )
    setup_routes(app)
    return app
@ruscoder
Copy link
Member

Related #93

@ruscoder ruscoder added the enhancement New feature or request label Aug 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants