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

change in validation and set_python_target function #1335

Conversation

gourav-kandoria
Copy link
Contributor

No description provided.

Comment on lines +846 to +847
},
{
Copy link
Member

Choose a reason for hiding this comment

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

These should be on the same line...

Comment on lines +875 to 880
}, {
.name = nxt_string("factory"),
.type = NXT_CONF_VLDT_STRING,
// need to add validator here which specify it needs to be mutually exclusive
// with callable option. not sure at present how
},
Copy link
Member

Choose a reason for hiding this comment

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

You may as well put this above prefix so the order matches as above...

}

obj = PyDict_GetItemString(PyModule_GetDict(module), callable);
if (nxt_slow_path(obj == NULL)) {
nxt_alert(task, "Python failed to get \"%s\" from module \"%s\"",
callable, module_name);
Copy link
Member

Choose a reason for hiding this comment

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

What is the value of callable now?

Comment on lines +452 to +467
if (!factory_found) {
value = nxt_conf_get_object_member(conf, &callable_str, NULL);
if (value == NULL) {
callable = nxt_alloca(12);
nxt_memcpy(callable, "application", 12);

} else {
nxt_conf_get_string(value, &str);

callable = nxt_alloca(str.length + 1);
nxt_memcpy(callable, str.start, str.length);
callable[str.length] = '\0';
}
obj = PyDict_GetItemString(PyModule_GetDict(module), callable);
}

Copy link
Member

Choose a reason for hiding this comment

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

I have a feeling all this logic could be cleaned up and possibly removing the need for the factory_found boolean...

Copy link
Member

@ac000 ac000 left a comment

Choose a reason for hiding this comment

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

Thanks for the patch!

However the commit message is missing (a few things)

  1. A description of what this patch does
  2. Why it's needed
  3. Examples of valid config using this new feature

I'm guessing it's in relation to #1106

It could do with a more accurate subject, python: Add 'factory' support or some such...

However this doesn't seem to implement @callahad's suggestion. Some text describing the reasoning wouldn't go amiss...

@callahad
Copy link
Collaborator

It does match my earlier suggestion of

If you have a patch, would you mind opening a pull request? Even if it's unpolished, having something concrete is a great starting point.

😆

Great way to get the ball rolling; thank you @gourav-kandoria! Are you up for refining this to match the later proposal (a separate factory boolean in the config?)

@gourav-kandoria
Copy link
Contributor Author

@callahad @ac000 oh my bad really sorry . @callahad I had these changes earlier in my local. raised pr with those changes.
here is new pr as you suggested in issue comments
https://github.com/nginx/unit/pull/1336/files

@callahad
Copy link
Collaborator

Great, thank you! Closing in favor of #1336

@callahad callahad closed this Jun 19, 2024
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.

3 participants