Skip to content

Add generic BlobPersistence plugin for Azure/GCS support#47

Closed
PabloSzx wants to merge 3 commits into
yjs:masterfrom
PabloSzx:feat/blob-persistence
Closed

Add generic BlobPersistence plugin for Azure/GCS support#47
PabloSzx wants to merge 3 commits into
yjs:masterfrom
PabloSzx:feat/blob-persistence

Conversation

@PabloSzx
Copy link
Copy Markdown
Contributor

@PabloSzx PabloSzx commented Apr 1, 2026

Summary

  • Adds a new BlobPersistence plugin (src/plugins/blob.js) that accepts a simple adapter interface (put/get/del/init?), allowing callers to bring their own cloud SDK (Azure Blob Storage, GCS, etc.) without adding new dependencies to yhub
  • Adds ./plugins/blob package export
  • Fixes S3 types export path typo (dist/src/storage/s3.d.tsdist/src/plugins/s3.d.ts)
  • Adds Azure/GCS env var guidance to .env.template

Motivation

We need to deploy yhub to environments with Azure Blob Storage and GCS natively, where S3-compatible storage is not available. The existing plugin architecture already supports this — BlobPersistence is a thin adapter that implements PersistencePlugin and delegates all cloud-specific logic (auth, retries, 404 handling) to the caller-provided adapter.

No changes to existing files (s3.js, persistence.js, types.js, index.js) — S3PersistenceV1 remains unchanged.

Usage

import { BlobPersistence } from '@y/hub/plugins/blob'

const plugin = new BlobPersistence('AzureBlob:v1', {
  init: () => container.createIfNotExists(),
  put: (path, data) => container.getBlockBlobClient(path).upload(data, data.length),
  get: async (path) => { /* ... return Buffer or null */ },
  del: (path) => container.getBlockBlobClient(path).deleteIfExists()
})

createYHub({ persistence: [plugin], ... })

Test plan

  • npm run lint passes (standard + tsc)
  • Existing tests still pass (no changes to S3 plugin or core)
  • Smoke test: instantiate BlobPersistence with an in-memory adapter, verify store/retrieve/delete

PabloSzx added 3 commits April 1, 2026 10:35
Adds a new persistence plugin that accepts a simple adapter interface
(put/get/del/init) so callers can bring their own cloud SDK. Also fixes
the S3 types export path typo in package.json.
Adds module-level docs explaining the relationship to S3PersistenceV1,
complete Azure and GCS usage examples, and detailed JSDoc for the
BlobAdapter interface and all public methods.
Documents the generic BlobPersistence plugin alongside S3PersistenceV1,
including the BlobAdapter interface, usage example, and behavior notes.
@PabloSzx PabloSzx marked this pull request as ready for review April 1, 2026 14:51
@dmonad
Copy link
Copy Markdown
Member

dmonad commented Apr 6, 2026

Thanks for the PR @PabloSzx

This wrapper makes it slightly more convenient to write a custom blob storage adapter. The implementation looks solid. However, the overall design looks very similar to the existing plugin interface for custom storage adapters.

I'd rather like to maintain a specific Azure blob adapter. I'm sure there will be a bunch of edge-cases to catch - similarly to the s3 adapter.

At this point I don't want to maintain another abstraction - sorry!

@dmonad dmonad closed this Apr 6, 2026
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