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

Storage interface for thumbnail #601

Open
quantranhong1999 opened this issue Mar 13, 2023 · 5 comments
Open

Storage interface for thumbnail #601

quantranhong1999 opened this issue Mar 13, 2023 · 5 comments
Labels

Comments

@quantranhong1999
Copy link
Member

quantranhong1999 commented Mar 13, 2023

Why

The idea is to have an abstraction for thumbnail storage so it can be generic with implementations (maybe not for now as only S3, but other implementations in the future).

How

public interface ThumbnailStore {
    Publisher<Void> save(ThumbnailBlobId blobId, byte[] payload);

    Publisher<byte[]> readBytes(ThumbnailBlobId blobId);

    Publisher<Boolean> delete(ThumbnailBlobId blobId);
}

public class BlobStoreThumbnailStore implements ThumbnailStore {
    private final BlobStoreDAO blobStoreDAO;

    @Inject
    public BlobStoreThumbnailStore(BlobStoreDAO blobStoreDAO) {
        this.blobStoreDAO = blobStoreDAO;
    }

    @Override
    public Publisher<Void> save(ThumbnailBlobId blobId, byte[] payload) {
    }

    @Override
    public Publisher<byte[]> readBytes(ThumbnailBlobId blobId) {
    }

    @Override
    public Publisher<Boolean> delete(ThumbnailBlobId blobId) {
    }
}

public class ThumbnailBlobId {
    enum SIZE {
        SMALL,
        MEDIUM
    }

    public static class Factory {
        private final BlobId.Factory blobIdFactory;

        @Inject
        public Factory(BlobId.Factory blobIdFactory) {
            this.blobIdFactory = blobIdFactory;
        }

        public ThumbnailBlobId forAttachment(BlobId originalAttachmentBlobId, SIZE size) {
            ...
        }
    }

    private final BlobId blobId;

    private ThumbnailBlobId(BlobId blobId) {
        this.blobId = blobId;
    }
}

DoD

  • Unit tests
@chibenwa
Copy link
Member

S3ThumbnailStore -> BlobStoreThumbnailStore

@chibenwa
Copy link
Member

Is the thumbnail store responsible of generating the thumbnail ?

Or should it allow storing both small and medium size?

@quantranhong1999
Copy link
Member Author

Is the thumbnail store responsible of generating the thumbnail ?

No, my design tends to make ThumbnailStore only responsible for storing. We can let the thumbnail client handles generating the thumbnail.

Or should it allow storing both small and medium size?

As it stands now, it allows, with 2 separate request: 1 for small and 1 for medium.

ThumbnailBlobId is an abstraction layer so the ThumbnailStore do not need to care about the size of the thumbnails do we use (e.g in the future we add or remove the sizes).

That is my idea.

@Arsnael
Copy link
Member

Arsnael commented Mar 14, 2023

No medium for now

@Arsnael
Copy link
Member

Arsnael commented Mar 14, 2023

Thumbnail blob id should be the jmap blob id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants