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

Staging #103

Merged
merged 21 commits into from
Sep 28, 2020
Merged

Staging #103

merged 21 commits into from
Sep 28, 2020

Conversation

angrave
Copy link
Collaborator

@angrave angrave commented Sep 28, 2020

staging to master

angrave and others added 21 commits September 23, 2020 22:05
…hentication still throws and exception and immediately fails)
Add entities and endpoints for EPubs and Images
…dias

Filter out null medias for GetAllWatchedMediaForUser
@angrave angrave requested a review from robkooper September 28, 2020 02:33
@angrave angrave merged commit e53313c into master Sep 28, 2020
Copy link
Collaborator

@robkooper robkooper left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some generic comments.

string[] keyregion = subscriptionKey.Split(',');
if (keyregion.Length != 2)
{
throw new Exception("AZURE_SUBSCRIPTION_KEYS should be in the form key,region;key,region");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add the offending line here in the log message.

Copy link
Collaborator Author

@angrave angrave Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was no logger in this class! Will fix though in a future commit

foreach (string subscriptionKey in subscriptionKeys.Split(';'))
{
if (!subscriptionKeys.Contains(","))
{
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe logging.debug, so we can see something got ignored.

};
_logger.LogInformation($"Connection to RabbitMQ server {factory.HostName} with user {factory.UserName} on port {factory.Port}...");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment, not sure if this is an issue;
1 connection per application, this is long lived
1 channel per thread, from the documentation "Channel instances must not be shared by threads that publish on them."

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made a new issue--
#104

_logger.LogInformation(" [*] Waiting for messages, queueName - {0}", queueName);

var consumer = new EventingBasicConsumer(_channel);
consumer.Received += async (model, ea) =>
{
// This object exists so that we can wrap all OnConsumes with a try-finally here
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One problem I have seen in the past with RabbitMQ, if your job takes to long to execute, the heartbeat will timeout (that is done inside the BasicConsume function (I believe, in my case it was python code). This would result in closed connections.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what do you recommend?

Copy link
Collaborator

@robkooper robkooper Sep 28, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what we did was complex, not sure it is the best yet:

worker = None

while(consumeMessage(timeout = 100ms)) {
  if worker and worker.finished:
     channel.ack
  if newjob and worker = None
     worker = new Job(finished=False)
}

Job() {
  finished = False
  run():
     do some work
     finished=True

you consume a message, start a new thread, go back to consumeMessage so you can send heartbeat. When job is finished Ack the message and get a new message. If you have. a list of workers, you might be able to handle multiple in parallel (just need to push the msg to the worker so you know what job to ack).

var configurations = CTDbContext.GetConfigurations();
return "Server=" + configurations["POSTGRES_SERVER_NAME"] + ";Port=5432;Database="
+ configurations["POSTGRES_DB"] + ";User Id=" + configurations["ADMIN_USER_ID"] + ";Password=" + configurations["ADMIN_PASSWORD"] + ";MaxPoolSize=1000;";
return "Server=" + configurations["POSTGRES_SERVER_NAME"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are building the URI here, can we not just pass in the URI as an argument. That way we can add MaxPoolSize as part of the configuration and there is no need to recompile the code.

@@ -17,6 +18,9 @@ public class AppSettings
public string ADMIN_USER_ID { get; set; }
public string ADMIN_PASSWORD { get; set; }
public string RabbitMQServer { get; set; }

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should be consistent with variables like this. I think it be good to look at a linter that checks formatting (yes I care about that).

See

Might be interesting to look at:
https://marketplace.visualstudio.com/items?itemName=ChrisDahlberg.StyleCop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants