Skip to content

fix operator queue and redis#17

Merged
dylanmcreynolds merged 2 commits intomainfrom
operator_fixes
Apr 2, 2026
Merged

fix operator queue and redis#17
dylanmcreynolds merged 2 commits intomainfrom
operator_fixes

Conversation

@dylanmcreynolds
Copy link
Copy Markdown
Collaborator

Small fixes to operators

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to adjust operator/listener interactions (queue notification) and make small Redis listener instantiation changes.

Changes:

  • Add Operator.notify() to enqueue messages onto the operator’s internal listener queue.
  • Modify RedisListener construction helpers (__init__, from_client) and add a redis_listener_factory() helper.
  • Remove passing operator into RedisListener initialization (as currently implemented).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/arroyopy/redis.py Refactors RedisListener initialization and introduces a factory helper.
src/arroyopy/operator.py Adds a queue-based notification method (notify) for incoming messages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 13 to 16
def __init__(self, redis_client: Redis, redis_channel_name: str):
self.stop_requested = False
self.redis_client: Redis = redis_client
self.redis_channel_name = redis_channel_name
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RedisListener no longer stores an operator (operator arg removed from init/from_client), but start() still calls self.operator.process(...). This will raise AttributeError at runtime and also breaks config-based instantiation that injects an operator kwarg (see config.py:155-156). Restore passing/storing the operator (or refactor start() to enqueue via operator.notify / a provided queue) and keep the constructor/from_client signatures consistent with that approach.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +50
def redis_listener_factory(
redis_uri: str, redis_channel_name: str, operator: Operator = None
) -> RedisListener:
redis_client = Redis(redis_uri)
return RedisListener(redis_client, redis_channel_name)
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis_listener_factory accepts an operator parameter but never uses it, and it returns a RedisListener that (per current implementation) has no operator set, so the produced listener cannot function. Either remove the unused parameter or pass it through and ensure the listener is fully initialized (consistent with how listeners are instantiated elsewhere).

Copilot uses AI. Check for mistakes.
def __init__(
self, redis_client: Redis, redis_channel_name: str, operator: Operator
):
def __init__(self, redis_client: Redis, redis_channel_name: str):
Copy link

Copilot AI Apr 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type annotation for redis_channel_name is str, but existing usage/tests pass bytes (e.g. REDIS_CHANNEL_NAME = b"arroyo"). Consider widening the type (e.g. str | bytes) to match how redis-py channels are used and avoid misleading type checking.

Copilot uses AI. Check for mistakes.
@dylanmcreynolds dylanmcreynolds merged commit 824904d into main Apr 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants