Services¶
- pelican.util.services.encode(message, content_type)[source]¶
Encode the body of a message for RabbitMQ.
- Parameters:
message (Any) – a decoded message
content_type (str | None) – the message’s content type
- Return type:
bytes
- pelican.util.services.decode(body, content_type)[source]¶
Decode the body of a message from RabbitMQ.
- Parameters:
message – an encoded message
content_type (str | None) – the message’s content type
body (bytes)
- Return type:
Any
- pelican.util.services.consume(*args, prefetch_count=1, **kwargs)[source]¶
Consume messages from RabbitMQ.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
None
- pelican.util.services.publish(*args, **kwargs)[source]¶
Publish a message to RabbitMQ.
- Parameters:
args (Any)
kwargs (Any)
- Return type:
None
- pelican.util.services.get_cursor(name='')[source]¶
Connect to the database, if needed, and return a database cursor.
- Return type:
cursor
- class pelican.util.services.phase[source]¶
- CONTRACTING_PROCESS = 'CONTRACTING_PROCESS'¶
- DATASET = 'DATASET'¶
- TIME_VARIANCE = 'TIME_VARIANCE'¶
- CHECKED = 'CHECKED'¶
- DELETED = 'DELETED'¶
- pelican.util.services.initialize_dataset_state(dataset_id)[source]¶
Initialize a dataset’s progress.
- Parameters:
dataset_id (int) – the dataset’s ID
- Return type:
None
- pelican.util.services.update_dataset_state(dataset_id, phase, state, size=None)[source]¶
Update a dataset’s progress to the given phase and state.
- Parameters:
dataset_id (int) – the dataset’s ID
phase (str) – the phase to be set
state (str) – the state to set
size (int | None) – number of data items to process
- Return type:
None
- pelican.util.services.initialize_items_state(dataset_id, item_ids)[source]¶
Initialize data items’ progress.
- Parameters:
dataset_id (int) – the dataset’s ID
item_ids (list[int]) – the data items’ IDs
- Return type:
None
- pelican.util.services.update_items_state(dataset_id, item_ids, state)[source]¶
Update data items’ progress to the given state.
- Parameters:
dataset_id (int) – the dataset’s ID
item_ids (list[int]) – the data items’ IDs
state (str) – the state to set
- Return type:
None
- pelican.util.services.get_processed_items_count(dataset_id)[source]¶
Return the number of items processed.
- Parameters:
dataset_id (int) – the dataset’s ID
- Return type:
int