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

Code maintenance: accessing global settings properties from session objects #1302

Closed
confluence opened this issue Aug 29, 2023 · 1 comment · Fixed by #1321
Closed

Code maintenance: accessing global settings properties from session objects #1302

confluence opened this issue Aug 29, 2023 · 1 comment · Fixed by #1321
Assignees
Labels
code maintenance For issues relating to code maintenance and quality
Milestone

Comments

@confluence
Copy link
Collaborator

We currently pass config settings values into session objects in two completely different ways:

  1. Using static functions to set static properties on the Session class:
if (settings.wait_time >= 0) {
    Session::SetExitTimeout(settings.wait_time);
}

if (settings.init_wait_time >= 0) {
    Session::SetInitExitTimeout(settings.init_wait_time);
}
  1. Passing them into the Session constructor:
_sessions[session_id] = new Session(ws, loop, session_id, address, _settings.top_level_folder, _settings.starting_folder,
        _file_list_handler, _settings.read_only_mode, _settings.enable_scripting);

2 doesn't really make sense. These properties don't change per session; they're global properties which remain unchanged for the lifetime of the backend. They should all be static.

Rather than duplicating most or all settings values as static properties on Session, however, I think it would be cleaner for us to turn ProgramSettings itself into a singleton which is initialised in Main and can be imported from any part of the code and used to access the settings properties directly.

@kswang1029 kswang1029 added the code maintenance For issues relating to code maintenance and quality label Sep 13, 2023
@confluence
Copy link
Collaborator Author

Clarification: there should be a single ProgramSettings object which is initialised and made accessible through some kind of static function. Code which needs to access the settings should then refer to the settings object properties directly. That will remove the need to copy these values and pass them around explicitly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code maintenance For issues relating to code maintenance and quality
Projects
No open projects
Status: PR test and review
Status: PR test and review
Development

Successfully merging a pull request may close this issue.

3 participants