forked from INTERSECT-SDK/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfaces.py
More file actions
51 lines (40 loc) · 1.78 KB
/
interfaces.py
File metadata and controls
51 lines (40 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from __future__ import annotations
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any
if TYPE_CHECKING:
from uuid import UUID
from ..service_callback_definitions import (
INTERSECT_SERVICE_RESPONSE_CALLBACK_TYPE,
)
from ..shared_callback_definitions import (
IntersectDirectMessageParams,
)
class IntersectEventObserver(ABC):
"""Abstract definition of an entity which observes an INTERSECT event (i.e. IntersectService).
Used as the common interface for event emitters (i.e. CapabilityImplementations).
"""
@abstractmethod
def _on_observe_event(self, event_name: str, event_value: Any, operation: str) -> None:
"""How to react to an event being fired.
Args:
event_name: The key of the event which is fired.
event_value: The value of the event which is fired.
operation: The source of the event (generally the function name, not directly invoked by application devs)
"""
...
@abstractmethod
def create_external_request(
self,
request: IntersectDirectMessageParams,
response_handler: INTERSECT_SERVICE_RESPONSE_CALLBACK_TYPE | None = None,
timeout: float = 300.0,
) -> UUID:
"""Observed entity (capability) tells observer (i.e. service) to send an external request.
Params:
- request: the request we want to send out, encapsulated as an IntersectDirectMessageParams object
- response_handler: optional callback for how we want to handle the response from this request.
- timeout: optional value for how long we should wait on the request, in seconds (default: 300 seconds)
Returns:
- generated RequestID associated with your request
"""
...