![Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility](https://cdn.sanity.io/images/cgdhsj6q/production/97774ea8c88cc8f4bed2766c31994ebc38116948-1664x1366.png?w=400&fit=max&auto=format)
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
StiQueue is a lightweight messaging queue system designed to be simple, flexible, and easy to use.
StiQueue, short for "stick queue," is inspired by the simplicity of a stick figure. Just as a stick figure represents minimalism and clarity, StiQueue is a lightweight messaging queue system designed to be simple, flexible, and easy to use.
Explore the full StiQueue Documentation for in-depth code references and usage guides.
SQServer
is the core of StiQueue and manages the messaging queue. It can be run directly with minimal setup.
Once the code is downloaded, you can start the server with:
PYTHONPATH=src python -m stiqueue.sqserver --host 0.0.0.0 --port 1234 --debug
💡 The --debug
flag is useful during the first run to monitor incoming and outgoing messages.
Below are the available command-line options for the server:
usage: StiQueue Server [-h] [--debug] [--host HOST] [--port PORT] [--buff-size BUFF_SIZE]
A message queue server
options:
-h, --help show this help message and exit
--debug Showing debug messages
--host HOST The host address of the server
--port PORT The port to listen on
--buff-size BUFF_SIZE The size of the buffer
--log LOG The log file
The SQClient
allows you to interact with the server to enqueue (send) and dequeue (receive) messages.
Ensure the host and port of the client match the server configuration.
Blocking Dequeue: The deq method is blocking, which is more resource-efficient than polling.
from stiqueue import SQClient
client = SQClient()
client.enq("Hello, World!")
msg = client.deq().decode()
print("Received:", msg)
Often, the client that sends the messages is different from the one receiving them. For instance, one client (or app) might send requests, while another client fetches these messages or requests when a resource becomes available. It is also helpful to use a Thread Pool, such as TPool, to manage the number of running threads.
The following methods are supported by stiqueue
:
enq(msg: bytes)
: Adds a message to the queue.deq() -> bytes
: Retrieves the next message from the queue (blocking call).cnt() -> int
: Returns the number of messages currently in the queue.peek(n: int = 0, sep: str = ",") -> bytes
: Retrieves up to n
messages from the queue without removing them.
n=0
, returns all available messages.n
messages, separated by sep
.b""
).Note: When
ack_required=True
and the client process crashes after callingdeq
, messages are automatically re-queued to ensure they are not lost.
The following is a simple example of how to use the SQClient
to enqueue and dequeue messages from the server:
from stiqueue import SQClient
# Initialize the client
client = SQClient()
# Enqueue messages
client.enq(b"First message")
client.enq(b"Second message")
# Dequeue and process messages
print(client.deq().decode()) # Output: First message
print(client.deq().decode()) # Output: Second message
Note: The decode()
method is used because the deq()
method returns the messages as bytes
,
which need to be decoded to a string for readability.
You can integrate a thread pool, such as TPool, for managing concurrent client operations.
StiQueue is designed to be flexible and extensible. You can add custom functionality to the server or client as needed. Examples of extending StiQueue are available in the examples directory.
Run the unit tests to ensure everything is working as expected.
python -m unittest discover
Replace <test_file_name>
with the desired test file:
python -m unittest tests.<test_file_name>
FAQs
StiQueue is a lightweight messaging queue system designed to be simple, flexible, and easy to use.
We found that stiqueue demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.