rzane / file_store

🗄️ A unified interface for file storage backends
MIT License
19 stars 3 forks source link

Reimplement FileStore as a protocol #16

Closed rzane closed 3 years ago

rzane commented 3 years ago

In previous versions, we had a behavior module called FileStore.Adapter. Each adapter would implement this behavior. The top-level FileStore module existed in order to delegate to the appropriate adapter based on the provided configuration. All of the functions defined in the behavior had to be repeated in the FileStore module.

FileStore is now a protocol, and each adapter implements the protocol. This helps to avoid repetitive declaration of functions. It also means that each adapter's implementation is private and won't be called directly.

Breaking Changes

  1. FileStore.new(adapter: Adapter, ...config) is now Adapter.new(config)
  2. If you were previously calling any of the undocumented functions defined in the adapter itself, those are gone now and you won't be able to call them.
  3. The top-level FileStore is no longer a struct.

Before

FileStore.new(adapter: FileStore.Adapters.Disk, storage_path: "/path/to/storage")
# %FileStore{...}

After

FileStore.Adapters.Disk.new(storage_path: "/path/to/storage")
# %FileStore.Adapters.Disk{...}