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

Add Module specific configuration and more error checking into config file #23

Open
graymalkin opened this issue Feb 16, 2015 · 11 comments

Comments

@graymalkin
Copy link
Collaborator

#2 being fixed now means we can specify servers, and logins in a non-code file, which is nice. However it's a little fragile and doesn't have all the defaults it should.

It would also be nice if you could pass through configs to various plugins. E.g. mongo db settings to markov, again with sensible defaults.

Similarly it should be extensible. Potentially with a global list of API keys, accessible by other plugins to safely grab a key without needing to in-line it in code, or have a custom solution.

This could also be per-server, where instead of a list of auto-load plugin names, there's a list of plugin configs.

{
    /* other config lines ... */
    "Plugins": [
        {
            "Name" : "markov",
            "DBName" : "markov"
        },
        {
            "Name" : "seval",
            "timeout" : 3
        }
    ]
}
@ellxc
Copy link
Owner

ellxc commented Mar 30, 2015

this could be passed to any functions marked with the onload wrapper when a module is being loaded. would require a slight change to the wrapper, and a change to the plugin loading system, but it shouldn't be too difficult.

@graymalkin
Copy link
Collaborator Author

Perhaps it could be a little more clever. With a dict along the lines of

{
    /* other config lines ... */
    "Plugins": [
        "markov" : {
            "DBName" : "markov"
        },
        "seval" : {
            "timeout" : 3
        }
    ]
}

You can name custom dicts to pass into each plugin as a config rather than passing the whole thing as a global -- this would keep the data compartmentalised and prevent plugins from being able to access configs they don't have any business reading (reduces exploitation surface area if nothing else).

@ellxc
Copy link
Owner

ellxc commented Mar 31, 2015

also allowing plugins to write back to the config might be interesting

@graymalkin
Copy link
Collaborator Author

Perhaps a the plugins could keep the same dict of settings about, and a save() could collect all the dictionaries and spit them back out into the settings.json file?

@ellxc
Copy link
Owner

ellxc commented Mar 31, 2015

performing an update on the settings would probably be better, so if no settings are returned keep current ones, else replace any settings with the ones returned. and maybe a None value to unset the setting?

@graymalkin
Copy link
Collaborator Author

I think that over complicates the problem, doesn't it?

@ellxc
Copy link
Owner

ellxc commented Apr 1, 2015

every plugin that would use a config would have to return all it's settings again, which sounds like a lot of hassle if it has many settings

@graymalkin
Copy link
Collaborator Author

It would just need a generalised method which returns the settings. It could be done up in the wrapper.

@graymalkin
Copy link
Collaborator Author

And if the settings themselves are a dict, it's not like you'd need 1000 different fields in the plugin. It'd just be

bar = self.settings["key"]
self.settings["key"] = foo

@ellxc
Copy link
Owner

ellxc commented Apr 1, 2015

plugin receives {"pw":"qwerty","usr":"bob","mode":"vebose"}
plugin sends back {"mode":"simple"}
config saved: {"pw":"qwerty","usr":"bob","mode":"simple"}
pw and usr settings are kept the same.
that's my idea anyway

@graymalkin
Copy link
Collaborator Author

what is this, fucking Erlang?

config() ->
    receive
        {"mode", "simple"} -> simple_mode();
        All -> set_config(All)
    end.

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

No branches or pull requests

2 participants