Skip to content

Commit 8e08bf3

Browse files
committed
Support marking sessions with a TTL (fix #52)
1 parent a947ec8 commit 8e08bf3

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

backslash/client.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def report_session_start(self, logical_id=NOTHING,
4545
keepalive_interval=NOTHING,
4646
subjects=NOTHING,
4747
infrastructure=NOTHING,
48+
ttl_seconds=NOTHING,
4849
):
4950
"""Reports a new session starting
5051
@@ -59,6 +60,7 @@ def report_session_start(self, logical_id=NOTHING,
5960
'keepalive_interval': keepalive_interval,
6061
'subjects': subjects,
6162
'infrastructure': infrastructure,
63+
'ttl_seconds': ttl_seconds,
6264
}
6365
if parent_logical_id is not None or is_parent_session:
6466
supports_parallel = (self.api.info().endpoints.report_session_start.version >= 2)

backslash/contrib/slash_plugin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ def get_name(self):
111111

112112
def get_config(self):
113113
return {
114+
"session_ttl_days": 0 // Doc(
115+
'Optional number of days after which this session will be discarded '
116+
'from Backslash') // Cmdline(arg='--session-ttl-days', metavar='DAYS'),
117+
118+
114119
"session_labels": [] // Doc('Specify labels to be added to the session when reported') \
115120
// Cmdline(append="--session-label", metavar="LABEL"),
116121
}
@@ -181,7 +186,11 @@ def _get_initial_session_metadata(self):
181186
return returned
182187

183188
def _get_extra_session_start_kwargs(self):
184-
return {}
189+
returned = {}
190+
ttl_seconds = slash_config.root.plugin_config.backslash.session_ttl_days * 24 * 60 * 60
191+
if ttl_seconds:
192+
returned['ttl_seconds'] = ttl_seconds
193+
return returned
185194

186195
@slash.plugins.register_if(_HAS_TEST_AVOIDED)
187196
@handle_exceptions

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Changelog
22
=========
33

4+
* :feature:`52` Support reporting sessions with a specific TTL, marking them for future deletion on the server
45
* :feature:`51` Report local and remote SCM branches if supported
56
* :release: `2.30.0 <8-8-2017>`
67
* :feature:`50` Added session_webapp_url property to the Slash plugin

0 commit comments

Comments
 (0)