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: Asset cleanup #5152

Merged
merged 8 commits into from
Jun 27, 2024
Merged

feat: Asset cleanup #5152

merged 8 commits into from
Jun 27, 2024

Conversation

k-anshul
Copy link
Member

@k-anshul k-anshul commented Jun 26, 2024

closes #5144

@k-anshul k-anshul self-assigned this Jun 26, 2024
admin/admin.go Outdated
@@ -31,6 +32,7 @@ type Service struct {
Email *email.Client
Github Github
AI ai.Client
AssetsBucket *storage.BucketHandle
Copy link
Contributor

Choose a reason for hiding this comment

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

Can just be called Assets (e.g. like it's Email, not EmailClient, etc.)

Copy link
Member Author

Choose a reason for hiding this comment

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

I can change it here to keep it consistent with other variable names.
Overall I am skeptical on this practice.
One argument given by Rob Pike to use capital names for exported variable in golang is that I don't need to look at variable's definition to determine whether its an exported or local. I would extend the argument to here that I don't need to look at the variable definition to determine what it does. Sadly Email or AI provides no such information.
The variable names should be somewhat self explanatory when used in such bigger contexts like Service.

Copy link
Contributor

@begelundmuller begelundmuller Jun 27, 2024

Choose a reason for hiding this comment

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

I think you may have misunderstood that argument. See the section on variable names in the style guide. It states:

Omit types and type-like words from most variable names.

With the argument that:

The compiler always knows the type of a variable, and in most cases it is also clear to the reader what type a variable is by how it is used.

IMO it makes sense and is in line with ideas of domain driven design. Basically, you name things for what they are used for, not their implementation details. In this case, it's a variable that gives you access to Assets – whether it's a bucket, or a directory handle, or an interface, does not need to be reflected in the name unless there is ambiguity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Basically, you name things for what they are used for, not their implementation details.

AssetHandle or AssetsBucket is not an implementation detail IMO. AssetsGCSHandle would be.
It gives a subtle hint about what they are used for.
With just Assets I can't possible guess what it is used for. Is it a cache ?

admin/admin.go Outdated Show resolved Hide resolved
admin/database/postgres/postgres.go Outdated Show resolved Hide resolved
admin/server/admin_rbac_test.go Outdated Show resolved Hide resolved
cli/pkg/mock/server.go Outdated Show resolved Hide resolved
admin/database/postgres/postgres.go Outdated Show resolved Hide resolved
admin/database/postgres/migrations/0031.sql Outdated Show resolved Hide resolved
admin/worker/delete_unsued_assets.go Outdated Show resolved Hide resolved
admin/worker/delete_unsued_assets.go Outdated Show resolved Hide resolved
admin/worker/delete_unsued_assets.go Outdated Show resolved Hide resolved
admin/admin.go Outdated Show resolved Hide resolved
@k-anshul k-anshul merged commit edec171 into main Jun 27, 2024
4 checks passed
@k-anshul k-anshul deleted the asset_cleanup branch June 27, 2024 11:43
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.

Add a background task to cleanup assets bucket
2 participants