Google-cloud-dotnet: Need help for Setting timeout in Firestore

Created on 3 Sep 2018  路  7Comments  路  Source: googleapis/google-cloud-dotnet

I'm look for setting a timeout in case of cable connected but unable to access internet. as I see in this document.
https://jskeet.github.io/google-cloud-dotnet/docs/Google.Cloud.Firestore.Data/api/Google.Cloud.Firestore.V1Beta1.FirestoreSettings.html
Default timeout was 10 mins. and I try but I can't change the setting (get only, I can't set).

this is what I try for now but I don't know how to set that. Could you please show me an example of how to?
`FirestoreSettings fs = new FirestoreSettings();

var t = fs.WriteSettings.Timing.Expiration.Timeout;`

firestore question

All 7 comments

Configuring timings can be tricky, I agree - there are lots of different options to consider, including the basic "do you want an expiration or a retry". Here's an example that uses a flat 10 second timeout:

var settings = FirestoreSettings.GetDefault();
var timing = CallTiming.FromTimeout(TimeSpan.FromSeconds(10));

// CallSettings itself is immutable, but there are many "with" methods
// that create a new instance based on an existing one, but with the
// given modification.
settings.WriteSettings = settings.WriteSettings.WithCallTiming(timing);

// Once we've got the settings, we can create a client
var client = FirestoreClient.Create(settings: settings);

// Once we've got the client, we can create a FirestoreDb
var db = FirestoreDb.Create(client: client);

Does that help?

Thank you @jskeet that help me a lot but how to set a Project Id?

Just pass it into the FirestoreDb.Create method as normal:

var db = FirestoreDb.Create("my project ID", client: client);

or

var db = FirestoreDb.Create(projectId: "my project ID", client: client);

@jskeet Thank you so much. It really work.

Great! I'll close this issue now; please feel free to raise new issues for different matters, or add more comments here if you get stuck again on this. (It's entirely feasible!)

@jskeet Sorry to ask but how I secure credential json file in production stage?

@Watanyu: That's a bit beyond the scope of questions suitable for this repo, and certainly away from the topic of this issue. It will depend very much on where you're deploying. On GCP you wouldn't need a credential file at all, for example - you can use the ambient credentials of the machine you're deployed on. On other platforms, the best way of securing information will depend on that platform. I suggest you do research about the platform you're actually interested in, and ask a new question on Stack Overflow (with appropriate context) if you have problems doing that.

Was this page helpful?
0 / 5 - 0 ratings