Callback Definitions¶
Client¶
Data types used in regard to client callbacks. Only relevant for Client authors.
See shared_callback_definitions for additional typings which are also shared by service authors.
- intersect_sdk.client_callback_definitions.INTERSECT_CLIENT_EVENT_CALLBACK_TYPE¶
This is a callable function type which should be defined by the user.
Note: DO NOT handle serialization/deserialization yourself, the SDK will take care of this.
- Params
- The SDK will send the function four arguments:
The message source (the SOS representation of the Service) - this is mostly useful for your own control flow loops you write in the function
The name of the capability from the service that fired the event.
The name of the event.
The response, as a Python object - the type should be based on the corresponding Service’s event response. The Python object will already be deserialized for you (unless you are expecting binary data, then it will be base64). This will be either an integer, boolean, float, string, None, a List[T], or a Dict[str, T], where “T” represents any of the 7 aforementioned types.
- Returns
If you want to send one or many messages in reaction to a message, or change which services you’re listening to for events, the function should return an IntersectClientCallback object.
If you are DONE listening to messages, raise a generic Exception from your function.
If you DON’T want to send another message or modify your events, but want to continue listening for messages, you can just return None.
- Raises
Any uncaught or raised exceptions the callback function throws will terminate the INTERSECT lifecycle.
alias of
Callable[[str,str,str,list[INTERSECT_JSON_VALUE] |dict[str, INTERSECT_JSON_VALUE] |str|bool|int|float|None|bytes],IntersectClientCallback|None]
- intersect_sdk.client_callback_definitions.INTERSECT_CLIENT_RESPONSE_CALLBACK_TYPE¶
This is a callable function type which should be defined by the user.
Note: DO NOT handle serialization/deserialization yourself, the SDK will take care of this.
- Params
- The SDK will send the function four arguments:
The message source - this is mostly useful for your own control flow loops you write in the function
The name of the operation that triggered the response from your ORIGINAL message - needed for your own control flow loops if sending multiple messages.
A boolean - if True, there was an error; if False, there was not.
The response, as a Python object - the type should be based on the corresponding Service’s schema response. The Python object will already be deserialized for you (unless you are expecting binary data, then it will be a base64). If parameter 3 was “True”, then this will be the error message, as a string. If parameter 3 was “False”, then this will be either an integer, boolean, float, string, None, a List[T], or a Dict[str, T], where “T” represents any of the 7 aforementioned types.
- Returns
If you want to send one or many messages in reaction to a message, or change which services you’re listening to for events, the function should return an IntersectClientCallback object.
If you are DONE listening to messages, raise a generic Exception from your function.
If you DON’T want to send another message or modify your events, but want to continue listening for messages, you can just return None.
- Raises
Any uncaught or raised exceptions the callback function throws will terminate the INTERSECT lifecycle.
alias of
Callable[[str,str,bool,list[INTERSECT_JSON_VALUE] |dict[str, INTERSECT_JSON_VALUE] |str|bool|int|float|None|bytes],IntersectClientCallback|None]
- intersect_sdk.client_callback_definitions.INTERSECT_RESPONSE_VALUE: TypeAlias = list['INTERSECT_JSON_VALUE'] | dict[str, 'INTERSECT_JSON_VALUE'] | str | bool | int | float | None | bytes¶
This is the actual response value you will get back from a Service. The type will already be serialized into Python for you, but will not be serialized into a precise value.
- final class intersect_sdk.client_callback_definitions.IntersectClientCallback(*, messages_to_send: list[IntersectDirectMessageParams] = [], services_to_start_listening_for_events: list[IntersectEventMessageParams] = [], services_to_stop_listening_for_events: list[IntersectEventMessageParams] = [])¶
The value a user should return from ALL client callback functions.
If you do not return a value of this type (or None), this will be treated as an Exception and will break the pub-sub loop.
- messages_to_send: list[IntersectDirectMessageParams]¶
Messages to send as a result of an event or a response from a Service.
- services_to_start_listening_for_events: list[IntersectEventMessageParams]¶
Start listening to events from these services as a result of an event or a response from a Service.
For each event in the list - if you are already listening to the event, the action will be a no-op.
- services_to_stop_listening_for_events: list[IntersectEventMessageParams]¶
Stop listening to events from these services as a result of an event or a response from a Service.
For each event in the list - if you are not already listening to the event, the action will be a no-op.
Service¶
Callback definitions used by Services and Capabilities.
Please see shared_callback_definitions for definitions which are also used by Clients.
- intersect_sdk.service_callback_definitions.INTERSECT_SERVICE_RESPONSE_CALLBACK_TYPE¶
Callback typing for the function which handles another Service’s response.
- Params
- The SDK will send the function four arguments:
The message source - this is mostly useful for your own control flow loops you write in the function
The name of the operation that triggered the response from your ORIGINAL message - needed for your own control flow loops if sending multiple messages.
A boolean - if True, there was an error; if False, there was not.
The response, as a Python object - the type should be based on the corresponding Service’s schema response. The Python object will already be deserialized for you. If parameter 3 was “True”, then this will be the error message, as a string. If parameter 3 was “False”, and you are expecting textual data, this will be either an integer, boolean, float, string, None, a List[T], or a Dict[str, T], where “T” represents any of the 7 aforementioned types. If parameter 3 was “False” but you are expecting binary data, this will be bytes.
This callback type should only be used on Capabilities - for client callback functions, use INTERSECT_CLIENT_RESPONSE_CALLBACK_TYPE .
alias of
Callable[[str,str,bool,list[INTERSECT_JSON_VALUE] |dict[str, INTERSECT_JSON_VALUE] |str|bool|int|float|None|bytes],None]