Skip to content

Commit

Permalink
bugfix: already registered plugin was not being set to active on refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniszewski committed Jan 30, 2020
1 parent b95cd89 commit aeb2acb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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

0 comments on commit aeb2acb

Please sign in to comment.