magnet.ic package
Submodules
magnet.ic.field module
- class magnet.ic.field.Charge(magnet: Magnet)[source]
Bases:
object
- async emp(name=None)[source]
Deletes the specified stream if the name matches the current stream, or prints an error message if the name doesn’t match or the stream doesn’t exist.
- Args:
name (str, optional): The name of the stream to delete. Defaults to None.
- async excite(job: dict = {})[source]
Publishes data to the NATS server using the specified category and payload.
- Args:
job (dict, optional): The data to be published. Defaults to {}.
- async pulse(payload: Payload | GeneratedPayload | EmbeddingPayload | JobParams = None, v=False)[source]
Publishes data to the NATS server using the specified category and payload.
- Args:
payload (dict): The data to be published.
- class magnet.ic.field.Resonator(magnet: Magnet)[source]
Bases:
object
- async info()[source]
Retrieves information about a consumer in a JetStream stream.
- Parameters:
session – A string representing the session name of the consumer. If not provided, information about all consumers in the stream will be retrieved.
- Returns:
None
- async listen(cb=<built-in function print>, job_n: int = None, generic: bool = False, verbose=False)[source]
- async off()[source]
Unsubscribes from the category and stream and disconnects from the NATS server.
- Returns:
None
- async on(job: bool = None, local: bool = False, bandwidth: int = 1000)[source]
Connects to the NATS server, subscribes to a specific category in a stream, and consumes messages from that category.
- Args:
category (str, optional): The category to subscribe to. Defaults to ‘no_category’. stream (str, optional): The stream to subscribe to. Defaults to ‘documents’. session (str, optional): The session name for durable subscriptions. Defaults to ‘magnet’.
- Returns:
None
- Raises:
TimeoutError: If there is a timeout error while connecting to the NATS server. Exception: If there is an error in consuming the message or processing the callback function.
- async worker(cb=<built-in function print>)[source]
Consume messages from a specific category in a stream and process them as jobs.
- Args:
cb (function, optional): The callback function to process the received messages. Defaults to print.
- Returns:
None
- Raises:
Exception: If there is an error in consuming the message or processing the callback function.