Google Scheduled Cloud Function running more than once [closed] - firebase

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 days ago.
Improve this question
I have a Google Cloud Function scheduled to run every day at 00:10 AM, but today the function runned 10 times. I'm using the same approach for more than a year and its the first time this happened. Has someone had the same problem today?
Function
Function log
I'm just concerned about the problem.
Edit:
Thanks for all the comments here. I think its a new "bug" or just a new characteristic of pubsub schedule. In my configs its already. My function was created as bellow:
exports.processarIndicadoresDiaMoldtool = functions.runWith({ memory: '4GB', timeoutSeconds: 540 }).pubsub.schedule('10 0 * * *')
.timeZone('America/Sao_Paulo')
My Pub/Sub retry config are set to 0:
Today the same thing happened in another cloud scheduled function =/
My solution so far was to try make my function idempotent. I ve creat a log in my firestore database to verify when the function was already runned.
//this.nome = function's name
//this.dia = last day the function has runned - I saw some solutions with eventId too
async getFuncaoProcessada() {
const docFuncao = await db.collection("Processamentos")
.doc(this.nome).get();
if(docFuncao.exists){
let dadosFuncao = docFuncao.data();
if(dadosFuncao.dia == this.dia){
return true;
}
}
return false;
}
Thanks a lot for the help.

Related

What datatype in C# should I use if mapping a database column of type money? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 months ago.
Improve this question
I am using Insight.Database version 6.3.10 for SQL Server ORM, using C# as the client. I have a run into an issue where the mapping does not return a correct value for money column data type. I am using decimal in C# client. Below is the sample code:
DROP TABLE IF EXISTS dbo.MyTestTable;
CREATE TABLE dbo.MyTestTable
(
AmountToAllocate MONEY
)
GO
INSERT INTO dbo.MyTestTable VALUES(177279.73)
GO
CREATE OR ALTER PROC [dbo].[MyTestProc]
AS
BEGIN
SELECT TOP 1 m.AmountToAllocate FROM dbo.MyTestTable m
END
GO
I have an object in C# client:
public class MyTestResponse
{
public decimal AmountToAllocate { get; set; }
}
Now, if I execute the store proc with Insight.Database, the returned object has AmountToAllocate property, but its value is 0, instead of 177279.73.
I have no idea what went wrong, and why the mapping does not work properly.
Does anyone know how to resolve it? Thank you
Despite you solving your own problem, for reference for anyone else in the future, you can find all of the SQL Server data type mappings in C# in SQL Server Data Type Mappings.
Money maps to Decimal.

Firebase Authentication: get user latest data after login [duplicate]

This question already has an answer here:
Can I get updated emailVerified without logging out?
(1 answer)
Closed 2 years ago.
I need to get the latest user data like - emailVerified, displayName, and profilePhoto. User is already logged-in. I want some sort of event or may be a call to server to see, latest value of user profile data.
firebase.auth().currentUser.emailVerified
I was trying this, but its returning the value from local (cached values at login), not the latest value from server.
One question is already there, but not answered. :(
how to get the latest firebase user authentication data from server?
You need to call the reload() method, which is asynchronous and returns a Promise.
firebase.auth().currentUser.reload()
.then(() => {
if (firebase.auth().currentUser.emailVerified) {
//...
} else {
//...
}
});

HTTP service doesn't work [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 4 years ago.
Improve this question
I'm trying to implement a RPC server in Go using Hprose. It worked fine but then after adding some more functions it didn't :/
Funny thing is that it doesn't work even on other http libraries such as fasthttp. The ListenAndServe() method just seems to be stuck somewhere during execution as it never returns. What might be causing this?
package main
import (
"net/http"
"fmt"
"github.com/hprose/hprose-golang/rpc"
log "logutil"
)
func main() {
log.InitializeLogger()
InitializeEthClient()
InitializeClients()
server := rpc.NewHTTPService()
// TxtStorage functions
server.AddFunction("DeployTxtStorage", DeployNewTxtStorage)
server.AddFunction("GetPackedData", GetPackedData)
server.AddFunction("GetReputation", GetReputation)
server.AddFunction("GetEventsForReputation", GetEventsForReputation)
server.AddFunction("GetEventsForData", GetEventsForData)
// Clients functions
server.AddFunction("RegisterClient", RegisterClient)
log.Info("Registered server functions!")
err := http.ListenAndServe(":8080", server)
fmt.Println(err)
log.Info("Waiting for incoming connections...")
log.WriteAway()
}
ListenAndServe is blocking, it won't return unless it hits an error. You seem to be expecting your final lines to print out
Waiting for incoming connections...
But that will never happen as the server is running. Are you sure it isn't just working as expected?

ASP.NET to call my method every hour [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I want to send email remainder. I created a method that will send emails to the users that have an appointment in the next hour. Right now i have to call my method manually. But i want to use HangFire( or if you have a better suggestion) to call my method every hour( 3:00 PM, 4:00 PM, and so on). I don't want to use Windows task scheduler because i won't have access to the server in the future.
//[HttpPost("lll/reminder")]
public IActionResult EventReminder()
{
var date = DateTime.Now;
var events = eventRepository.GetEventsByDateTimeNow();
foreach(Event evnt in events)
{
var usr = userRepository.GetUserById(evnt.AttendeeId);
var message = new MimeMessage();
message.From.Add(new MailboxAddress("", ""));
message.To.Add(new MailboxAddress("User", usr.Email));
message.Subject = "Remainder";
message.Body = new TextPart("html")
{
Text = "message"
};
using (var client = new SmtpClient())
{
client.Connect("smtp.gmail.com", 587, false);
client.Authenticate("", "");
client.Send(message);
client.Disconnect(true);
}
}
return Ok();
}
This is the method. It's working but i have to call it manually. So, any ideas?
As you've already mentioned, HangFire can help you with this. They have several examples directly on their home page. The one you want is probably the 'recurring job':
Recurring jobs
Recurring jobs fire many times on the specified CRON schedule.
RecurringJob.AddOrUpdate(
() => Console.WriteLine("Recurring!"),
Cron.Daily);
You can setup and configure hangfire a variety of ways, but the most simple is to simply add it to your Startup.cs file.
I'd recommend you follow the quick start guide, since your use case appears fairly straight forward, running the 'server' in the web app is probably good enough for many small sites/apps and use cases.
There are ways to help improve running the server in the web app itself. That said, if you need something extremely robust, setting up the 'server' as a Windows Service or other 'out of process' process is probably time well spent and something hangfire easily supports as well.

React-native : Firebase how to get all the data [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
Hi guys how can I request all the data form this kind of DB structure?
I tried this but it's not working:
var recentPostsRef = firebase.database().ref('/store');
You are on the right track, but missing the retrieval part where .then() is used with a callback:
var recentPostsRef = firebase.database().ref('/store');
recentPostsRef.once('value').then(snapshot => {
// snapshot.val() is the dictionary with all your keys/values from the '/store' path
this.setState({ stores: snapshot.val() })
})
The firebase.database.Reference documentation has a lot of good examples and explanations that can help.

Resources