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

feat: add finalizer #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat: add finalizer #93

wants to merge 1 commit into from

Conversation

godu
Copy link
Contributor

@godu godu commented Jan 10, 2025

Destroy client after layer lifecycle to release idle connections.

Copy link

changeset-bot bot commented Jan 10, 2025

⚠️ No Changeset found

Latest commit: e398a5e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@godu
Copy link
Contributor Author

godu commented Jan 10, 2025

I'm not sure what the major change is.

Scope is added as a requirement, which seems annoying enough to make it a non-trivial update.

@floydspace
Copy link
Owner

thanks @godu I will carefully review it and diside if it should be major.
I would not like to do major update yet though

Copy link
Owner

@floydspace floydspace left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @godu , I like this change, but please consider my comments

packages/client-account/src/AccountClientInstance.ts Outdated Show resolved Hide resolved
(config) =>
Effect.acquireRelease(Effect.succeed(new AccountClient(config)), (client) =>
Effect.sync(() => client.destroy()),
),
);

/**
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can use Layer.scoped when constructing instance layer

export const AccountClientInstanceLayer = Layer.scoped(
  AccountClientInstance,
  makeAccountClientInstance,
);

in this way we can avoid introducing breaking change

additionally we can add AccountClientInstanceLayerScoped and defaultLayerScoped and other pairs, it is normal practice in effect ecosystem. if you want to control scope you use scoped version of layer.

packages/client-account/test/Account.test.ts Outdated Show resolved Hide resolved
scripts/codegen-client.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants