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

bugfix: already registered plugin was not being set to active on refresh #352

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions synse_server/plugin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Management and access logic for configured plugin backends."""

import time
from typing import List, Tuple, Union
from typing import Dict, List, Tuple, Union

from synse_grpc import client, utils

Expand All @@ -21,7 +21,7 @@ class PluginManager:
snapshot of currently registered plugins.
"""

plugins = {}
plugins: Dict[str, 'Plugin'] = {}

def __iter__(self) -> 'PluginManager':
self._snapshot = list(self.plugins.values())
Expand Down Expand Up @@ -109,7 +109,7 @@ def register(self, address: str, protocol: str) -> str:
self.plugins[plugin.id] = plugin
logger.info(_('successfully registered plugin'), id=plugin.id, tag=plugin.tag)

plugin.mark_active()
self.plugins[plugin.id].mark_active()
return plugin.id

@classmethod
Expand Down
6 changes: 5 additions & 1 deletion tests/unit/test_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ def test_register_duplicate_plugin_id(self, mocker):
# --- Test case -----------------------------
m = plugin.PluginManager()
m.plugins = {
'123': 'placeholder',
'123': plugin.Plugin(
{'id': 'foo', 'tag': 'foo'},
{},
client.PluginClientV3('foo', 'tcp'),
),
}

plugin_id = m.register('localhost:5432', 'tcp')
Expand Down