Skip to content

Commit

Permalink
Allow simpler passing for individual host classes
Browse files Browse the repository at this point in the history
Most used of Broker are for simple (single host type per operation) cases.
Becuase of this, most users passing in custom host classes are passing in a single class.
In these cases, it makes more sense to allow for an easier way to pass along the class than to specify it via key/Class mappings.
  • Loading branch information
JacobCallahan committed Aug 5, 2022
1 parent 032ea55 commit 80f92d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ from broker.hosts import Host
class MyHost(Host):
...

with Broker(..., host_classes={'host': MyHost}) as my_host:
with Broker(..., host_class=MyHost) as my_host:
...
```

Expand Down
5 changes: 4 additions & 1 deletion broker/broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ def __init__(self, **kwargs):
nick = kwargs.pop("nick")
kwargs = helpers.merge_dicts(kwargs, helpers.resolve_nick(nick))
logger.debug(f"kwargs after nick resolution {kwargs=}")
if "host_classes" in kwargs:
# Allow users to more simply pass a host class instead of a dict
if "host_class" in kwargs:
self.host_classes["host"] = kwargs.pop("host_class")
elif "host_classes" in kwargs:
self.host_classes.update(kwargs.pop("host_classes"))
# determine the provider actions based on kwarg parameters
self._provider_actions = {}
Expand Down

0 comments on commit 80f92d5

Please sign in to comment.