Skip to content

Commit e69ebca

Browse files
committed
docs: update writing connectors
1 parent fe90c77 commit e69ebca

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

docs/api/connectors.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,11 @@ handled in code separately from `name` being a valid string.
5050
A connector that implements execution requires a few more methods:
5151

5252
```py
53-
class LocalConnector(BaseConnector):
53+
class MyConnector(BaseConnector):
5454
handles_execution = True
5555

5656
@staticmethod
5757
def make_names_data(_=None):
58-
# Unlike InventoryConnector above, this connector can only return one host each invocation of make_names_data().
59-
6058
... # see above
6159

6260
def run_shell_command(
@@ -113,6 +111,19 @@ class LocalConnector(BaseConnector):
113111
Returns:
114112
bool: indicating success or failure.
115113
"""
114+
115+
116+
# The following two optional methods can be used to hook into the connect/disconnect steps:
117+
def connect(self) -> None:
118+
"""
119+
Connect this connector instance. Should raise pyinfra.api.exceptions.ConnectError exceptions
120+
to indicate failure.
121+
"""
122+
123+
def disconnect(self) -> None:
124+
"""
125+
Disconnect this connector instance, should never fail.
126+
"""
116127
```
117128

118129
## Where to make changes

0 commit comments

Comments
 (0)