Skip to content

Generalize bufferWriter for non-local files usage #2178

@eliyaoo32

Description

@eliyaoo32

Description

Hi, currently the bufferWriter is dedicated to be written to a file in the hard-disk / local filesystem.
There are cases (Such the one I face) where a little bit of hard-disk space is available (no more than few MBs), but we do have access to a distributed file system / object storage (Such as: S3 file, GCS file, etc...).

I suggest to make the bufferWrite as an interface:

type bufferedWriter interface {
	Write(p []byte) (n int, err error)
	WriteString(s string) (n int, err error)
	Reader() (io.Reader, error)
	Sync() (err error)
	Flush() error
	Close() error
}

To have backward-compability , it will use the current implementation of bufferedWriter as a default struct.
But in the function: NewStreamWriter as an option it can get BufferedWriter as a parameter and use it.
i.e.

NewStreamWriter(sheetName, WithBufferedWriter(anotherImplementation{}))

I'm ready to contribute this change since I need it, but happy to hear what the owners of this project think about it.

Additional context

No response

Validations

  • Check that there isn't already an issue that requests the same feature to avoid creating a duplicate.

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