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

Broker class and necessary configuration #16

Closed
wants to merge 3 commits into from

Conversation

brngylni
Copy link
Contributor

@brngylni brngylni commented Jun 4, 2024

Regarding to #14 @abompard

@gridhead gridhead self-assigned this Jun 10, 2024
@gridhead gridhead added the enhancement New feature or request label Jun 10, 2024
@@ -4,13 +4,15 @@

from functools import cache
from pathlib import Path

import os
from pydantic import BaseModel, ConfigDict, DirectoryPath
from pydantic_settings import BaseSettings


DEFAULT_CONFIG_FILE = _config_file = "/etc/webhook-to-fedora-messaging/webhook-to-fedora-messaging.cfg"
Copy link
Member

Choose a reason for hiding this comment

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

I see that you are using the INI-styled configuration here. Could you please include a default configuration with placeholder values for folks to get started with?

Copy link
Member

Choose a reason for hiding this comment

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

Also, @abompard should we stick to an INI-styled configuration or use a more profound TOML-styled configuration? I am fine with either but I wanted to hear your opinion on this.

Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't use pydantic anyway, because Flask has its own configuration system.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, I got bamboozled seeing all the Pydantic stuff here and assumed that it was used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see that you are using the INI-styled configuration here. Could you please include a default configuration with placeholder values for folks to get started with?

Default configuration for constants as a different file? Or should this one stay the same and just an example config as a different file?

@gridhead
Copy link
Member

@brngylni Please refer to #2 (comment) for how commit messages should be written.

Copy link
Member

@gridhead gridhead left a comment

Choose a reason for hiding this comment

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

@abompard, this is not in @brngylni's changes but can we please use context-aware modules for storing configuration instead of global variables?

Take for instance, the section https://github.com/fedora-infra/webhook-to-fedora-messaging/pull/16/files#diff-00c1df60e290e533baec34ac9f6abd4db0fa8b99f04485315dff43023f8049b6R44-R47, could simply be a module-wide variable that can be referenced and changed throughout the project with the use of the following.

In the configuration initialization module named something.py,

from webhook_to_fedora_messaging import config

config.some_variable = "SOMETHING"

In the configuration using module named something_else.py,

from webhook_to_fedora_messaging import config

def do_something() -> str:
    return config.some_variable

As long as we do not import the variable like the following cases.

In the configuration initialization module named something.py,

from webhook_to_fedora_messaging.config import some_variable

some_variable = "SOMETHING"

In the configuration using module named something_else.py,

from webhook_to_fedora_messaging.config import some_variable

def do_something() -> str:
    return some_variable

We should be able to ensure that the variable is not instantiated with the default value and that the variable retains the value set to it during the runtime.

@gridhead gridhead linked an issue Jun 10, 2024 that may be closed by this pull request
@brngylni
Copy link
Contributor Author

brngylni commented Jun 10, 2024

@abompard, this is not in @brngylni's changes but can we please use context-aware modules for storing configuration instead of global variables?

Take for instance, the section https://github.com/fedora-infra/webhook-to-fedora-messaging/pull/16/files#diff-00c1df60e290e533baec34ac9f6abd4db0fa8b99f04485315dff43023f8049b6R44-R47, could simply be a module-wide variable that can be referenced and changed throughout the project with the use of the following.

In the configuration initialization module named something.py,

from webhook_to_fedora_messaging import config

config.some_variable = "SOMETHING"

In the configuration using module named something_else.py,

from webhook_to_fedora_messaging import config

def do_something() -> str:
    return config.some_variable

As long as we do not import the variable like the following cases.

In the configuration initialization module named something.py,

from webhook_to_fedora_messaging.config import some_variable

some_variable = "SOMETHING"

In the configuration using module named something_else.py,

from webhook_to_fedora_messaging.config import some_variable

def do_something() -> str:
    return some_variable

We should be able to ensure that the variable is not instantiated with the default value and that the variable retains the value set to it during the runtime.

I can switch the structure to this if you both agreed on this @abompard @gridhead

@brngylni brngylni closed this Jun 10, 2024
@brngylni brngylni deleted the dev_broker branch June 10, 2024 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build the Fedora Messaging broker
3 participants