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

[FR]: Support for io.Writer Interface in Firebase Go SDK for Realtime Database Streaming #602

Open
danieltaub96 opened this issue Feb 1, 2024 · 0 comments

Comments

@danieltaub96
Copy link

danieltaub96 commented Feb 1, 2024

Environment
Operating System version: osx
Firebase SDK version: v4
Firebase Product: database (realtime database)
Feature Request Description
I propose adding support for the io.Writer interface in the Firebase Go SDK to allow streaming data directly from the Realtime Database to a writer (e.g., file, buffer). The current implementation requires loading the entire response into memory, which is not efficient for large data sets.

Problem
When working with large datasets in the Realtime Database, the SDK's current implementation, which loads the entire database into memory, can lead to high memory usage and potential performance issues. This limitation is particularly challenging when dealing with large data streams or when operating in resource-constrained environments.

func StreamDataToWriter(dbRef *db.Ref, writer io.Writer) error {
    // Example implementation using the proposed feature
    // ...
}

// Usage example
file, err := os.Create("output.json")
if err != nil {
    // handle error
}
defer file.Close()

dbRef := client.NewRef("path/to/data")
err = StreamDataToWriter(dbRef, file)
if err != nil {
    // handle error
}

Additional Context
This enhancement would be beneficial for applications that process large amounts of data and need to minimize memory footprint. It aligns with Go's idiomatic use of interfaces and streaming I/O operations, promoting efficiency and flexibility in handling data streams.

@danieltaub96 danieltaub96 changed the title FR [FR]: Support for io.Writer Interface in Firebase Go SDK for Realtime Database Streaming Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants