-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from canvas-medical/ad/add-plugin-runner-process
Add the plugin runner process
- Loading branch information
Showing
17 changed files
with
690 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ | |
__pycache__/ | ||
|
||
dist/ | ||
|
||
# vim | ||
*.swp |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from google.protobuf import descriptor as _descriptor | ||
from google.protobuf import message as _message | ||
from typing import ClassVar as _ClassVar, Optional as _Optional | ||
|
||
DESCRIPTOR: _descriptor.FileDescriptor | ||
|
||
class Effect(_message.Message): | ||
__slots__ = ("type", "payload") | ||
TYPE_FIELD_NUMBER: _ClassVar[int] | ||
PAYLOAD_FIELD_NUMBER: _ClassVar[int] | ||
type: str | ||
payload: str | ||
def __init__(self, type: _Optional[str] = ..., payload: _Optional[str] = ...) -> None: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
from generated.messages import effects_pb2 as _effects_pb2 | ||
from google.protobuf.internal import containers as _containers | ||
from google.protobuf.internal import enum_type_wrapper as _enum_type_wrapper | ||
from google.protobuf import descriptor as _descriptor | ||
from google.protobuf import message as _message | ||
from typing import ClassVar as _ClassVar, Iterable as _Iterable, Mapping as _Mapping, Optional as _Optional, Union as _Union | ||
|
||
DESCRIPTOR: _descriptor.FileDescriptor | ||
|
||
class EventType(int, metaclass=_enum_type_wrapper.EnumTypeWrapper): | ||
__slots__ = () | ||
UNKNOWN: _ClassVar[EventType] | ||
ALLERGY_INTOLERANCE_CREATED: _ClassVar[EventType] | ||
ALLERGY_INTOLERANCE_UPDATED: _ClassVar[EventType] | ||
APPOINTMENT_BOOKED: _ClassVar[EventType] | ||
APPOINTMENT_CANCELED: _ClassVar[EventType] | ||
APPOINTMENT_CHECKED_IN: _ClassVar[EventType] | ||
APPOINTMENT_CREATED: _ClassVar[EventType] | ||
APPOINTMENT_NO_SHOWED: _ClassVar[EventType] | ||
APPOINTMENT_RESCHEDULED: _ClassVar[EventType] | ||
APPOINTMENT_RESTORED: _ClassVar[EventType] | ||
APPOINTMENT_UPDATED: _ClassVar[EventType] | ||
BILLING_LINE_ITEM_CREATED: _ClassVar[EventType] | ||
BILLING_LINE_ITEM_UPDATED: _ClassVar[EventType] | ||
CONDITION_ASSESSED: _ClassVar[EventType] | ||
CONDITION_CREATED: _ClassVar[EventType] | ||
CONDITION_RESOLVED: _ClassVar[EventType] | ||
CONDITION_UPDATED: _ClassVar[EventType] | ||
CONSENT_CREATED: _ClassVar[EventType] | ||
CONSENT_DELETED: _ClassVar[EventType] | ||
CONSENT_UPDATED: _ClassVar[EventType] | ||
COVERAGE_CREATED: _ClassVar[EventType] | ||
COVERAGE_UPDATED: _ClassVar[EventType] | ||
ENCOUNTER_CREATED: _ClassVar[EventType] | ||
ENCOUNTER_UPDATED: _ClassVar[EventType] | ||
EXTERNAL_EVENT_CREATED: _ClassVar[EventType] | ||
EXTERNAL_EVENT_UPDATED: _ClassVar[EventType] | ||
IMAGING_REPORT_CREATED: _ClassVar[EventType] | ||
IMAGING_REPORT_UPDATED: _ClassVar[EventType] | ||
IMMUNIZATION_CREATED: _ClassVar[EventType] | ||
IMMUNIZATION_STATEMENT_CREATED: _ClassVar[EventType] | ||
IMMUNIZATION_STATEMENT_UPDATED: _ClassVar[EventType] | ||
IMMUNIZATION_UPDATED: _ClassVar[EventType] | ||
INSTRUCTION_CREATED: _ClassVar[EventType] | ||
INSTRUCTION_UPDATED: _ClassVar[EventType] | ||
INTERVIEW_CREATED: _ClassVar[EventType] | ||
INTERVIEW_UPDATED: _ClassVar[EventType] | ||
LAB_ORDER_CREATED: _ClassVar[EventType] | ||
LAB_ORDER_UPDATED: _ClassVar[EventType] | ||
LAB_REPORT_CREATED: _ClassVar[EventType] | ||
LAB_REPORT_UPDATED: _ClassVar[EventType] | ||
MEDICATION_LIST_ITEM_CREATED: _ClassVar[EventType] | ||
MEDICATION_LIST_ITEM_UPDATED: _ClassVar[EventType] | ||
MESSAGE_CREATED: _ClassVar[EventType] | ||
PATIENT_CREATED: _ClassVar[EventType] | ||
PATIENT_UPDATED: _ClassVar[EventType] | ||
PRESCRIPTION_CREATED: _ClassVar[EventType] | ||
PRESCRIPTION_UPDATED: _ClassVar[EventType] | ||
REFERRAL_REPORT_CREATED: _ClassVar[EventType] | ||
REFERRAL_REPORT_UPDATED: _ClassVar[EventType] | ||
TASK_ASSIGNED: _ClassVar[EventType] | ||
TASK_CLOSED: _ClassVar[EventType] | ||
TASK_COMMENT_CREATED: _ClassVar[EventType] | ||
TASK_COMMENT_UPDATED: _ClassVar[EventType] | ||
TASK_COMPLETED: _ClassVar[EventType] | ||
TASK_CREATED: _ClassVar[EventType] | ||
TASK_LABELS_ADJUSTED: _ClassVar[EventType] | ||
TASK_UNASSIGNED: _ClassVar[EventType] | ||
TASK_UPDATED: _ClassVar[EventType] | ||
VITAL_SIGN_CREATED: _ClassVar[EventType] | ||
VITAL_SIGN_UPDATED: _ClassVar[EventType] | ||
CHART_OPENED: _ClassVar[EventType] | ||
COMMAND_ORIGINATED: _ClassVar[EventType] | ||
UNKNOWN: EventType | ||
ALLERGY_INTOLERANCE_CREATED: EventType | ||
ALLERGY_INTOLERANCE_UPDATED: EventType | ||
APPOINTMENT_BOOKED: EventType | ||
APPOINTMENT_CANCELED: EventType | ||
APPOINTMENT_CHECKED_IN: EventType | ||
APPOINTMENT_CREATED: EventType | ||
APPOINTMENT_NO_SHOWED: EventType | ||
APPOINTMENT_RESCHEDULED: EventType | ||
APPOINTMENT_RESTORED: EventType | ||
APPOINTMENT_UPDATED: EventType | ||
BILLING_LINE_ITEM_CREATED: EventType | ||
BILLING_LINE_ITEM_UPDATED: EventType | ||
CONDITION_ASSESSED: EventType | ||
CONDITION_CREATED: EventType | ||
CONDITION_RESOLVED: EventType | ||
CONDITION_UPDATED: EventType | ||
CONSENT_CREATED: EventType | ||
CONSENT_DELETED: EventType | ||
CONSENT_UPDATED: EventType | ||
COVERAGE_CREATED: EventType | ||
COVERAGE_UPDATED: EventType | ||
ENCOUNTER_CREATED: EventType | ||
ENCOUNTER_UPDATED: EventType | ||
EXTERNAL_EVENT_CREATED: EventType | ||
EXTERNAL_EVENT_UPDATED: EventType | ||
IMAGING_REPORT_CREATED: EventType | ||
IMAGING_REPORT_UPDATED: EventType | ||
IMMUNIZATION_CREATED: EventType | ||
IMMUNIZATION_STATEMENT_CREATED: EventType | ||
IMMUNIZATION_STATEMENT_UPDATED: EventType | ||
IMMUNIZATION_UPDATED: EventType | ||
INSTRUCTION_CREATED: EventType | ||
INSTRUCTION_UPDATED: EventType | ||
INTERVIEW_CREATED: EventType | ||
INTERVIEW_UPDATED: EventType | ||
LAB_ORDER_CREATED: EventType | ||
LAB_ORDER_UPDATED: EventType | ||
LAB_REPORT_CREATED: EventType | ||
LAB_REPORT_UPDATED: EventType | ||
MEDICATION_LIST_ITEM_CREATED: EventType | ||
MEDICATION_LIST_ITEM_UPDATED: EventType | ||
MESSAGE_CREATED: EventType | ||
PATIENT_CREATED: EventType | ||
PATIENT_UPDATED: EventType | ||
PRESCRIPTION_CREATED: EventType | ||
PRESCRIPTION_UPDATED: EventType | ||
REFERRAL_REPORT_CREATED: EventType | ||
REFERRAL_REPORT_UPDATED: EventType | ||
TASK_ASSIGNED: EventType | ||
TASK_CLOSED: EventType | ||
TASK_COMMENT_CREATED: EventType | ||
TASK_COMMENT_UPDATED: EventType | ||
TASK_COMPLETED: EventType | ||
TASK_CREATED: EventType | ||
TASK_LABELS_ADJUSTED: EventType | ||
TASK_UNASSIGNED: EventType | ||
TASK_UPDATED: EventType | ||
VITAL_SIGN_CREATED: EventType | ||
VITAL_SIGN_UPDATED: EventType | ||
CHART_OPENED: EventType | ||
COMMAND_ORIGINATED: EventType | ||
|
||
class Event(_message.Message): | ||
__slots__ = ("type", "target") | ||
TYPE_FIELD_NUMBER: _ClassVar[int] | ||
TARGET_FIELD_NUMBER: _ClassVar[int] | ||
type: EventType | ||
target: str | ||
def __init__(self, type: _Optional[_Union[EventType, str]] = ..., target: _Optional[str] = ...) -> None: ... | ||
|
||
class EventResponse(_message.Message): | ||
__slots__ = ("success", "effects") | ||
SUCCESS_FIELD_NUMBER: _ClassVar[int] | ||
EFFECTS_FIELD_NUMBER: _ClassVar[int] | ||
success: bool | ||
effects: _containers.RepeatedCompositeFieldContainer[_effects_pb2.Effect] | ||
def __init__(self, success: bool = ..., effects: _Optional[_Iterable[_Union[_effects_pb2.Effect, _Mapping]]] = ...) -> None: ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from generated.messages import events_pb2 as _events_pb2 | ||
from google.protobuf import descriptor as _descriptor | ||
from typing import ClassVar as _ClassVar | ||
|
||
DESCRIPTOR: _descriptor.FileDescriptor |
66 changes: 66 additions & 0 deletions
66
plugin_runner/generated/services/plugin_runner_pb2_grpc.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! | ||
"""Client and server classes corresponding to protobuf-defined services.""" | ||
import grpc | ||
|
||
from generated.messages import events_pb2 as generated_dot_messages_dot_events__pb2 | ||
|
||
|
||
class PluginRunnerStub(object): | ||
"""Missing associated documentation comment in .proto file.""" | ||
|
||
def __init__(self, channel): | ||
"""Constructor. | ||
Args: | ||
channel: A grpc.Channel. | ||
""" | ||
self.HandleEvent = channel.unary_stream( | ||
'/canvas.PluginRunner/HandleEvent', | ||
request_serializer=generated_dot_messages_dot_events__pb2.Event.SerializeToString, | ||
response_deserializer=generated_dot_messages_dot_events__pb2.EventResponse.FromString, | ||
) | ||
|
||
|
||
class PluginRunnerServicer(object): | ||
"""Missing associated documentation comment in .proto file.""" | ||
|
||
def HandleEvent(self, request, context): | ||
"""Missing associated documentation comment in .proto file.""" | ||
context.set_code(grpc.StatusCode.UNIMPLEMENTED) | ||
context.set_details('Method not implemented!') | ||
raise NotImplementedError('Method not implemented!') | ||
|
||
|
||
def add_PluginRunnerServicer_to_server(servicer, server): | ||
rpc_method_handlers = { | ||
'HandleEvent': grpc.unary_stream_rpc_method_handler( | ||
servicer.HandleEvent, | ||
request_deserializer=generated_dot_messages_dot_events__pb2.Event.FromString, | ||
response_serializer=generated_dot_messages_dot_events__pb2.EventResponse.SerializeToString, | ||
), | ||
} | ||
generic_handler = grpc.method_handlers_generic_handler( | ||
'canvas.PluginRunner', rpc_method_handlers) | ||
server.add_generic_rpc_handlers((generic_handler,)) | ||
|
||
|
||
# This class is part of an EXPERIMENTAL API. | ||
class PluginRunner(object): | ||
"""Missing associated documentation comment in .proto file.""" | ||
|
||
@staticmethod | ||
def HandleEvent(request, | ||
target, | ||
options=(), | ||
channel_credentials=None, | ||
call_credentials=None, | ||
insecure=False, | ||
compression=None, | ||
wait_for_ready=None, | ||
timeout=None, | ||
metadata=None): | ||
return grpc.experimental.unary_stream(request, target, '/canvas.PluginRunner/HandleEvent', | ||
generated_dot_messages_dot_events__pb2.Event.SerializeToString, | ||
generated_dot_messages_dot_events__pb2.EventResponse.FromString, | ||
options, channel_credentials, | ||
insecure, call_credentials, compression, wait_for_ready, timeout, metadata) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import asyncio | ||
|
||
from concurrent import futures | ||
import logging | ||
|
||
import grpc | ||
|
||
from generated.messages.effects_pb2 import Effect | ||
from generated.messages.events_pb2 import EventResponse, EventType | ||
from generated.services.plugin_runner_pb2_grpc import PluginRunnerServicer, add_PluginRunnerServicer_to_server | ||
|
||
|
||
class PluginRunner(PluginRunnerServicer): | ||
async def HandleEvent(self, request, context): | ||
event_name = EventType.Name(request.type) | ||
logging.info(f'Handling event: {event_name}') | ||
yield EventResponse(success=True, effects=[Effect(type='Log', payload=f'Handled Event: "{event_name}"')]) | ||
|
||
async def serve(): | ||
port = "50051" | ||
server = grpc.aio.server() | ||
add_PluginRunnerServicer_to_server(PluginRunner(), server) | ||
server.add_insecure_port("[::]:" + port) | ||
logging.info("Starting server, listening on " + port) | ||
await server.start() | ||
await server.wait_for_termination() | ||
|
||
|
||
if __name__ == "__main__": | ||
logging.basicConfig(level=logging.INFO) | ||
asyncio.run(serve()) |
Oops, something went wrong.