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

More powerful and configurable plugin system #65

Open
vladcalin opened this issue Apr 26, 2017 · 0 comments
Open

More powerful and configurable plugin system #65

vladcalin opened this issue Apr 26, 2017 · 0 comments

Comments

@vladcalin
Copy link
Owner

The plugin system should rely on a BasePlugin class that will be inherited by all plugins.

Example

class ExamplePlugin(BasePlugin):
    name = "example"
    requires = [
        ConfigValue("db_engine", default="test"),
        ConfigValue("db_user", required=True),
        ConfigValue("db_password", required=True)
    ]
    
    def initialize(self):
        self.microservice.database = crate_db(
            self.get_config_value("db_engine"),
            self.get_config_value("db_user"),
            self.get_config_value("db_password")
        )
    def finalize(self, microservice):
        self.microservice.database.close()

The following method should be available for every plugin

  • intialize - on service initialization
  • finalize - on service shutdown
  • on_method_call - called with a single method call
  • on_method_response - called with a single response
  • on_request - called for a user request (be it a single method call or a batch request)
  • on_response - called for a http request
  • on_internal_error - called for internal errors from methods
  • on_jsonrpc_error - called for specific jsonrpc errors such as method not found, parse error, etc
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

1 participant