Skip to content

Add CallableService and ServiceLike abstraction#102

Merged
tobyclemson merged 5 commits into
mainfrom
cc-callable-service
Apr 29, 2026
Merged

Add CallableService and ServiceLike abstraction#102
tobyclemson merged 5 commits into
mainfrom
cc-callable-service

Conversation

@CorinChappy
Copy link
Copy Markdown
Contributor

@CorinChappy CorinChappy commented Apr 27, 2026

This PR is extracted from #98

Copilot AI review requested due to automatic review settings April 27, 2026 10:47
Copy link
Copy Markdown

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

Adds a lightweight abstraction for treating async callables as Service instances, along with a default Service.name derived from the class name. Updates existing service-manager unit tests to avoid clashing with the new Service.name attribute and introduces new unit tests for CallableService and adapters.

Changes:

  • Add Service.name base property derived from the class name.
  • Introduce CallableService, ServiceLike, and as_callable_service adapter.
  • Update unit tests and add new tests covering the new abstractions.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/logicblocks/event/processing/services/types.py Adds default Service.name implementation.
src/logicblocks/event/processing/services/callable.py Introduces ServiceLike, CallableService, and as_callable_service.
src/logicblocks/event/processing/services/__init__.py Re-exports new callable-service utilities from services.
src/logicblocks/event/processing/__init__.py Re-exports CallableService from the top-level processing package.
tests/unit/logicblocks/event/processing/services/test_manager.py Renames test service attributes to avoid conflicting with Service.name.
tests/unit/logicblocks/event/processing/services/test_callable.py Adds unit tests for Service.name, CallableService, and as_callable_service.
changelog.d/20260427_105913_corin_cc_callable_service.md Documents the newly added abstractions and Service.name.
Comments suppressed due to low confidence (1)

src/logicblocks/event/processing/init.py:62

  • Top-level logicblocks.event.processing re-exports CallableService but not the other newly added public helpers (ServiceLike, as_callable_service) that are exported from logicblocks.event.processing.services and mentioned in the changelog. If these are intended to be part of the main processing API, add them to the imports and __all__ here for consistency with the other service-related exports.
from .services import (
    CallableService,
    ContinueErrorHandler,
    ContinueErrorHandlerDecision,
    ErrorHandler,
    ErrorHandlerDecision,
    ErrorHandlingService,
    ErrorHandlingServiceMixin,
    ExecutionMode,
    ExitErrorHandler,
    ExitErrorHandlerDecision,
    IsolationMode,
    PollingService,
    RaiseErrorHandler,
    RaiseErrorHandlerDecision,
    RetryErrorHandler,
    RetryErrorHandlerDecision,
    Service,
    ServiceManager,
    TypeMappingErrorHandler,
    continue_execution_type_mapping,
    error_handler_type_mappings,
    exit_fatally_type_mapping,
    raise_exception_type_mapping,
    retry_execution_type_mapping,
)

Comment thread tests/unit/logicblocks/event/processing/services/test_callable.py Outdated
Comment thread src/logicblocks/event/processing/services/types.py Outdated
Comment thread src/logicblocks/event/processing/services/callable.py Outdated
Comment thread src/logicblocks/event/processing/services/callable.py Outdated
@CorinChappy CorinChappy force-pushed the cc-callable-service branch from 76b1520 to 1cad7a3 Compare April 27, 2026 10:57
@CorinChappy CorinChappy force-pushed the cc-callable-service branch from 1cad7a3 to 8640453 Compare April 27, 2026 11:27
@CorinChappy CorinChappy force-pushed the cc-callable-service branch from 3506d72 to 15d0284 Compare April 29, 2026 15:49

if value_is_string and klass_is_class and issubclass(klass, str):
return cast(T, value)
if isinstance(value, str):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed to change this to get the new version of pyrefly to type narrow correctly

value_is_json_value = is_json_value(value)
if value_is_json_value and klass is JsonValueType:
return cast(T, value)
if is_json_value(value):
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed to change this to get the new version of pyrefly to type narrow correctly

@CorinChappy CorinChappy force-pushed the cc-callable-service branch from 15d0284 to d5ea026 Compare April 29, 2026 16:05
@tobyclemson tobyclemson merged commit fe51f70 into main Apr 29, 2026
3 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.

3 participants