-
Notifications
You must be signed in to change notification settings - Fork 24
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
Feature/republish invoices #350
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #350 +/- ##
==========================================
- Coverage 54.12% 53.05% -1.08%
==========================================
Files 50 51 +1
Lines 3100 3163 +63
==========================================
Hits 1678 1678
- Misses 1239 1302 +63
Partials 183 183
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@@ -50,7 +50,7 @@ func main() { | |||
defer rabbitmqClient.Close() | |||
|
|||
result := []models.Invoice{} | |||
err = dbConn.NewSelect().Model(&result).Where("id > ?", startId).Where("id < ?", endId).Scan(context.Background()) | |||
err = dbConn.NewSelect().Model(&result).Where("settled_at > ?", startDate).Where("settled_at < ?", endDate).Scan(context.Background()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we only publish settled invoices, correct? thus it's ok to check settled there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If settled_at
is between those 2 values, then it's settled.
if dryRun { | ||
continue | ||
} | ||
err = svc.RabbitMQClient.PublishToLndhubExchange(context.Background(), inv, svc.EncodeInvoiceWithUserLogin) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it OK to flood the queue? or do we need some slight delay?
but I guess it should be OK.
republish_invoices/main.go
Outdated
logrus.Error(err) | ||
} | ||
} | ||
logrus.Infof("Published %d invoices", len(result)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we count which ones did not have an error to be able to see if all have been published.
republish_invoices/main.go
Outdated
} | ||
err = svc.RabbitMQClient.PublishToLndhubExchange(context.Background(), inv, svc.EncodeInvoiceWithUserLogin) | ||
if err != nil { | ||
logrus.Error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is an exception and could be a sentry notification? (though this floods sentry) - should we cancel if the publishing fails?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think we should cancel.
"github.com/getAlby/lndhub.go/rabbitmq" | ||
"github.com/joho/godotenv" | ||
"github.com/kelseyhightower/envconfig" | ||
"github.com/sirupsen/logrus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we use a new logger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the same logger. It's what we use under the hood.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does it work? we initialize one here that we then use I think: https://github.com/getAlby/lndhub.go/blob/main/main.go#L80
rabbitmq.WithLndInvoiceExchange(c.RabbitMQLndInvoiceExchange), | ||
rabbitmq.WithLndHubInvoiceExchange(c.RabbitMQLndhubInvoiceExchange), | ||
rabbitmq.WithLndInvoiceConsumerQueueName(c.RabbitMQInvoiceConsumerQueueName), | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a function like getRabbitmqClient
to make sure we have the same client config everwhere?
generally I would like to move towards JSON logging which helps querying log entries. |
No description provided.