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: collect shared logic for blob storage and minio #27

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chuang8511
Copy link
Member

@chuang8511 chuang8511 commented Nov 14, 2024

Because

  • blob storage will be used in different service

This commit

  • collect get and upload data function

Note

  • For minio pkg, the current pkg is not fit with the current design of blob storage. We will refactor that part with run logging.
  • We will need to add the test code

Copy link

linear bot commented Nov 14, 2024

Copy link
Collaborator

@jvallesm jvallesm left a comment

Choose a reason for hiding this comment

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

A little comment on this but not a blocker. Did you extract this code from any service (because another one needs to use it) or is it something several services will use in the future?


if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
return fmt.Errorf("upload failed with status %d: %s", resp.StatusCode, string(body))
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I'd add the body (even the status code) as a separate log. You want to keep errors that come from the same path as consistent as possible. That allows you, e.g., to group errors to see how frequent an incident is.

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 am not sure if I got it correctly.
Do you mean like this?

Copy link
Collaborator

@jvallesm jvallesm Nov 16, 2024

Choose a reason for hiding this comment

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

Sort of, I'd align with the logger package we use in other repos:

	err := fmt.Errorf("failed to upload file")
	logger.Error("Failed to upload file to MinIO",
		zap.Binary("body", body),
		zap.Int("status", resp.StatusCode),
		zap.Error(err),
	)
	return err

Copy link
Member Author

Choose a reason for hiding this comment

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

@chuang8511
Copy link
Member Author

Did you extract this code from any service (because another one needs to use it) or is it something several services will use in the future?

I think UploadFile will be used in model-backend & pipeline-backend. So, I extracted it.
Is this what you are asking?

@jvallesm
Copy link
Collaborator

Did you extract this code from any service (because another one needs to use it) or is it something several services will use in the future?

I think UploadFile will be used in model-backend & pipeline-backend. So, I extracted it. Is this what you are asking?

Yeah, my question was if this had been copied from somewhere (e.g. api-gateway plugin) or if it was new code. Basically I wanted to know which will be the current and future clients for this code. Thanks for the answer, it's clear 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants