charm-lib-contextual-status
Contextual status handling for charmed operators.
The goal of this library is to provide a mechanism for code within charm libraries to raise status conditions, such as Blocked or Waiting statuses, without relying on exceptions or other constructs that might otherwise interfere with the flow control of Python code.
This is accomplished by having the charm create a background status context with:
import charms.contextual_status as status
with status.context(self.unit):
some_lib.do_work()
Within a status context, it's possible for code to emit status conditions:
status.add(MaintenanceStatus("Doing something"))
if some_failure_condition:
status.add(BlockedStatus("Failed to do something"))
When a MaintenanceStatus is added to a status context, it is immediately
set as the unit status, so that the charm can provide status updates during
in-progress work.
When a BlockedStatus or WaitingStatus is added to a status context, it is
stored within the context for later. Multiple statuses can be added this way.
When a status context is closed, the unit status is set based on a simple
priority system: Blocked status is higher precedence than Waiting, and
within those groups, the earliest emitted status is preferred. If no Blocked
or Waiting statuses were emitted within the context, then the unit status is
set to Active.
The on_error decorator can be used to set status when an exception is raised:
@status.on_error(BlockedStatus("Failed to do something"))
def do_something():
status.add(MaintenanceStatus("Doing something"))
# ...
Metadata
Release files for charms.contextual-status 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| charms_contextual_status-0.0.1.tar.gz | 43.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| charms_contextual_status-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.5 kB
Release files / charms_contextual_status-0.0.1.tar.gz
| Download URL | charms_contextual_status-0.0.1.tar.gz |
|---|---|
| Size | 43.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ad9d6796a035fed39f53c6a8a8711ffbd8167d025e6e72490317835d3b83b0a
|
|
BLAKE2b-256 checksum How to use checksums |
73a3d19b24ba65a712cc031e04d9f8f289f4cea1665a207effd2b92a8ff90a07
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / charms_contextual_status-0.0.1-py3-none-any.whl
| Download URL | charms_contextual_status-0.0.1-py3-none-any.whl |
|---|---|
| Size | 9.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d1a0d0a76439eb5d008d44424fe1b09eab73c6e6ad964b546c727b3b10195efe
|
|
BLAKE2b-256 checksum How to use checksums |
e10e70b4bbe6e2fa9fdf9c9191249d8ee1439a4a3ef185f57c3f62030f9fe23d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|