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

オブジェクトストレージの実装 #17

Merged
merged 17 commits into from
Dec 17, 2023
Merged

オブジェクトストレージの実装 #17

merged 17 commits into from
Dec 17, 2023

Conversation

itt828
Copy link
Member

@itt828 itt828 commented Dec 16, 2023

書いてから思ったけどmysqlにid保存する必要なかったかも

@itt828
Copy link
Member Author

itt828 commented Dec 16, 2023

Image(年賀状のスタンプ)は多分ファイル名が必要になるからいるかも

(追記)いらんか

@itt828 itt828 marked this pull request as ready for review December 16, 2023 14:25
Comment on lines +27 to +29
pub fn new(bucket: &Bucket) -> Self {
Self(bucket.clone())
}
Copy link
Member

Choose a reason for hiding this comment

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

CardRepositoryConfigと同じようなやつが欲しい

struct Config {
    pub bucket_name: String,
    pub region: String,
    pub credentials: String, // ?
}


#[async_trait::async_trait]
pub trait ImageRepository {
async fn save_png(&self, card_id: Uuid, content: &[u8]) -> Result<(), RepositoryError>;
Copy link
Member

Choose a reason for hiding this comment

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

bytes::BytesDeref<Target=[u8]>持ってるのでそちらを

&self,
id: Uuid,
mime_type: &str,
content: &[u8],
Copy link
Member

Choose a reason for hiding this comment

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

bytes::Bytes

}
async fn delete_svg(&self, id: Uuid) -> Result<(), RepositoryError> {
let bucket = &self.0;
let key = id.to_string() + ".svg";
Copy link
Member

Choose a reason for hiding this comment

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

uuid::UuidDisplay実装してるのでformat!使えばちょっといい感じになるかも?まあこのままでも全然

@@ -103,7 +101,7 @@ impl CardRepository for CardRepositoryImpl {
}
}

async fn save_card(&self, params: &SaveCardParams) -> Result<(), DbErr> {
async fn save_card(&self, params: &SaveCardParams) -> Result<(), RepositoryError> {
// TODO: 画像の保存
Copy link
Member

Choose a reason for hiding this comment

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

TODO消せるはず?

Comment on lines 14 to 15
#[error("NotFound")]
NotFound,
Copy link
Member

Choose a reason for hiding this comment

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

NotFound消えて欲しい
deleteのとこで使ってそう

match image {
Ok(x) => Ok(Some((
x.headers().get("content-type").unwrap().to_string(),
x.to_vec(),
Copy link
Member

Choose a reason for hiding this comment

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

バイナリデータはbytes::Bytesで揃えたいので、Bytes::from(x.to_vec())とかで 🙏

@H1rono
Copy link
Member

H1rono commented Dec 16, 2023

書き忘れてた、compose.yamlにs3のモックが欲しい

@itt828
Copy link
Member Author

itt828 commented Dec 17, 2023

bucketが自動で作成されないので手動で作成する
bucket_nameは環境変数に合わせてbucket
↓エラーメッセージ

s3-init-1  | mc: <ERROR> Unable to initialize new alias from the provided credentials. Get "http://minio:9000/probe-bsign-(hoge)/?location=": dial tcp: lookup minio on 127.0.0.11:53: no such host.

@H1rono H1rono merged commit fd55ea9 into main Dec 17, 2023
2 checks passed
@H1rono H1rono deleted the feat/objectStorage branch December 17, 2023 02:21
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