google-cloud-dotnet icon indicating copy to clipboard operation
google-cloud-dotnet copied to clipboard

Firestore: Support for real-time updates

Open pauloevpr opened this issue 9 years ago • 45 comments

Is there any roadmap to add support for real-time updates?

pauloevpr avatar Nov 04 '17 12:11 pauloevpr

I don't know - I believe the expectation is that that's more of a mobile concern, whereas the current API is expected to be used server-side.

jskeet avatar Nov 04 '17 13:11 jskeet

Thank you very much for your reply. I get your point, but there are some use cases where real-time support would be extremely useful, even on the server-side. For example, when:

  • Integrating with custom server applications (in scenarios where Cloud Functions can't handle the business logic)
  • Integrating with web services such as Asp.Net and Asp.Net Core
  • Implementing client libraries for platforms which are not currently officially supported by Google, such as Xamarin, WPF, UWP and Windows Forms

Without real-time support, the API seems incomplete, especially because Firestore's RPC documentation does mention support for real-time updates through the Listen function of the service interface.

pauloevpr avatar Nov 05 '17 17:11 pauloevpr

I'll pass your comment back to the team - I'm only doing the C# API for it, following the direction given by the main Firestore team.

jskeet avatar Nov 05 '17 17:11 jskeet

Thank you very much. I appreciate your help.

pauloevpr avatar Nov 05 '17 19:11 pauloevpr

Hi, Sebastian here from the Firestore client team. We are currently offering realtime support in the mobile clients for the Web, iOS, Android. We also launched the Node Server SDK with realtime support.

Since we are currently offering Firestore Server SDKs for Node, Go, Python & Java (with C# and others in the works), we first wanted to gauge what the demand for realtime support for these server languages was. Our users have since indicated that they do want to see realtime support in all of these languages, and hence we are treating this as a high priority item on our immediate roadmap. While I can't provide a timeline, expect to see realtime support across all of our SDKs in the not so distant future.

schmidt-sebastian avatar Nov 06 '17 18:11 schmidt-sebastian

Great news! Thank you very much for your feedback.

pauloevpr avatar Nov 06 '17 18:11 pauloevpr

Will leave this issue open as a placeholder to indicate that we're intending to do it. I'll mark it as P2+, but that just means it's not imminent (i.e. working to get it in the next release). It doesn't mean it's not important :)

jskeet avatar Nov 06 '17 19:11 jskeet

Nearly end of the year and still no support for C# while all the admin SDK got update last week

And not even a roadmap was solid

Thaina avatar Dec 25 '17 09:12 Thaina

No support for this specific API call yet, no. We'll get there, but we're doing lots of other work too.

jskeet avatar Dec 25 '17 11:12 jskeet

From a server side perspective this would be very useful for integrating data collected by mobile devices into line of business systems.

I take it the heavy lifting for this is in the protocol, and there does not exist yet anything in Google.Cloud.Firestore.V1Beta1 to support this? If support is in V1Beta1 it should be fairly trivial to add an onSnapshot method to QuerySnapshot.

recyclethis avatar Dec 28 '17 15:12 recyclethis

It's far from trivial to provide the kind of support we want to provide. We would rather take time and do it properly than rush a shoddy option. You can use the client property to get the raw gRPC if you want in the meantime. We will attend this feature request over time, but will resist calls to rush.

jskeet avatar Dec 28 '17 15:12 jskeet

Thanks @jskeet. I'll look at FirestoreClient.Listen to achieve this. Maybe I will be able to create extension methods on QuerySnapshot and DocumentSnapshot until support is officially added. There is a snippet which lays out the groundwork.

recyclethis avatar Dec 28 '17 17:12 recyclethis

For anyone else who drops by here, I've played around with Google.Cloud.Firestore.V1Beta1 to create some very basic support for listen. It's not complete, and it's not terribly pretty yet, but it will listen for document and query changes. Checkout the FirebaseDocumentListener class. Now that the holidays are over, I'm not sure I'll have much more time for it so I'm uploading it as is.

cleversolutions avatar Jan 02 '18 20:01 cleversolutions

Note that there is now also a reference implementation in Java (https://github.com/GoogleCloudPlatform/google-cloud-java/pull/2665)

schmidt-sebastian avatar Jan 02 '18 20:01 schmidt-sebastian

I've updated my FirebaseDocumentListener to include an extension method for Query. Since I'm working outside of Google.Cloud.Firestore I've had to use some reflection to access internal methods and properties. You can now use the listener like this:

            //Create our database connection
            FirestoreDb db = FirestoreDb.Create(projectId);

            //Create a query
            CollectionReference collection = db.Collection("cities");
            Query qref = collection.Where("Capital", QueryOperator.Equal, true);

            //Listen to realtime updates
            FirebaseDocumentListener listener = qref.AddSnapshotListener();

                       //Listen to document changes
            listener.DocumentChanged += (obj, e) =>
            {
                var city = e.DocumentSnapshot.Deserialize<City>();
                Console.WriteLine(string.Format("City {0} Changed/Added with pop {1}", city.Name, city.Population));
            };

            //Listen to errors
            listener.Error += (obj, e) =>
            {
                Console.WriteLine("Error => " + e.Message);
            };

cleversolutions avatar Jan 03 '18 21:01 cleversolutions

I just found this thread today - I am working on a large project in Angular and we would like also offer a C# Desktop application for this project. All of my data resides in Firestore. Is their a library yet for Firestore in C#? I saw a mention above for a Google.Cloud.Firestore.V1Beta1. Is this the current library for C#? Is it still in beta? I really don't need real time listening functions in the desktop app, however, it would be a nice feature.

Thanks in advance

Ronnie

RonnieShawDeveloper avatar Jan 21 '18 14:01 RonnieShawDeveloper

The library you want to use is Google.Cloud.Firestore which provides a much higher level abstraction than Google.Cloud.Firestore.V1Beta1 - but both the library and the underlying API are still in beta.

jskeet avatar Jan 21 '18 15:01 jskeet

OK - Thanks - Yeah, I have been working on this all morning - There are no clear videos or explanations on how to integrate this into a C# project... such as, showing a step by step video on setting up the project in GCP, connecting the Firestore API and setting/Downloading the json file, setting up the environmental variables, etc... so I am in the process of creating such a video... will post shortly... should answer a lot of questions and save new people some time.

RonnieShawDeveloper avatar Jan 21 '18 19:01 RonnieShawDeveloper

@ArtificialInsights Please know that I'm extremely interested in those videos. I hope that, even if I'm the only one who watches, you'll still be releasing them.

I've set the authentication JSON file as an Environment Variable but my application still won't authenticate. I'd appreciate some more granular instructions.

I'm honestly surprised by the lack of C# support from Google. For what it's worth, I don't really need realtime listening either -- but I'd still like to be able to create, modify and delete/remove collections/documents/subcollections from the desktop application.

Thanks!

SimplifyMSP avatar Jan 26 '18 04:01 SimplifyMSP

@SimplifyMSP: You should be able to use Google.Cloud.Firestore from a desktop application. Are there features that you consider to be missing, or is it just the auth issue that you're facing?

jskeet avatar Jan 26 '18 06:01 jskeet