Skip to content

Use functional options for NewFileSystem #238

@funkyshu

Description

@funkyshu

vfs is not consistent on how configuration is is passed. We created the vfs.Options empty interface type but don't explicitly require how to use it and always end up just casting it as the version-specific variant. Some backends don't need configuration at all. Others accept env vars are use a set of chain-able function like WithOptions or WithClient.

Though NewFileSystem isn't enforceable, we should use the functional options system that i've used for various functions like Delete and NewFile.

The Retry function in the vfs.FileSystem interface was instituted as a common way to use a retry wrapper. However, it's only ever been implemented to the gs backend. Other backends have their own internal retry functionality while other have none but either way, Retry in those cases always returns a no-op retrier and is never even called internally. Also it has little to no value externally. Retrier configuration could just as easily be passed either within a backend option or as its own type via the NewFileSystem functional option.

Proposed

  • create a function option interface for NewFileSystem
  • implement backend-specific functional options to replace chain-able functions
  • deprecate vfs.Options
  • deprecate vfs.Retry and related types

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions