stiqueue package

Submodules

stiqueue.sqclient module

This module implements a simple client for interacting with a message queue server.

Classes:

SQClient: A client that connects to the message queue server to enqueue, dequeue, and check the count of messages.

class stiqueue.sqclient.SQClient(host='127.0.0.1', port=1234, logger=None, buff_size=None, ack_required=True)[source]

Bases: object

A client that connects to a message queue server for enqueuing, dequeuing, and retrieving the count of messages.

host

The server’s host address.

Type:

str

port

The port number to connect to the server.

Type:

int

socket

The client socket to communicate with the server.

Type:

socket.socket

buff_size

Buffer size for sending and receiving messages.

Type:

int

logger

Logger for printing messages.

Type:

logging.Logger

ack_required

Indicates whether an acknowledgment is required after the client receives the message.

Type:

bool

ack()[source]

Sends an acknowledgement request to the server.

cnt()[source]

Sends a “count” request to the server and receives the count of messages in the queue.

Returns:

The count of messages in the queue.

Return type:

bytes

connect()[source]

Establishes a connection to the messaging queue server.

deq()[source]

Sends a “dequeue” request to the server and receives the dequeued message.

Returns:

The dequeued message from the server.

Return type:

bytes

disconnect()[source]

Closes the connection to the server.

enq(msg)[source]

Sends an “enqueue” request to the server.

Parameters:

msg (bytes or str) – The message to enqueue. If not in bytes, it will be encoded.

send_with_action(msg, action, recv=False)[source]

Sends a message with a specified action to the server.

Parameters:
  • msg (bytes or str) – The message to send. If not in bytes, it will be encoded.

  • action (bytes) – The action command (e.g., “enq”, “deq”, “cnt”).

  • recv (bool) – Whether to expect a response from the server. Defaults to False.

Returns:

The server’s response if recv is True, otherwise None.

Return type:

bytes

stiqueue.sqserver module

Module contents