|
2 | 2 |
|
3 | 3 | This document describes breaking changes and how to upgrade. For a complete list of changes including minor and patch releases, please refer to the [changelog](CHANGELOG.md). |
4 | 4 |
|
| 5 | +## 0.9.0 |
| 6 | + |
| 7 | +Note that SDK 0.9.0 is completely incompatible with any version <0.9.0 , due to backend message structure changes. |
| 8 | + |
| 9 | +### Event declaration change |
| 10 | + |
| 11 | +The SDK no longer use the `@intersect_event` decorator for event, and also does not use the `events` attribute on the `@intersect_message` decorator anymore. Instead, create a dictionary of event names to `IntersectEventDefinitions` as the class variable `intersect_sdk_events` on your Capability. This class variable should not be mutated after the IntersectService has been initialized with the Capability. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +An example of the old way of doing events: |
| 16 | + |
| 17 | +```python |
| 18 | +from intersect_sdk import intersect_event, intersect_message, IntersectBaseCapabilityImplementation, IntersectEventDefinition |
| 19 | + |
| 20 | +class Capability(IntersectBaseCapabilityImplementation): |
| 21 | + intersect_sdk_capability_name = 'example_capability' |
| 22 | + |
| 23 | + @intersect_event(events={'integer_event': IntersectEventDefinition(event_type=int)}) |
| 24 | + def response_event_function_1(self): |
| 25 | + self.intersect_sdk_emit_event('integer_event', 1) |
| 26 | + |
| 27 | + @intersect_event(events={'integer_event': IntersectEventDefinition(event_type=int)}) # note event duplication |
| 28 | + def response_event_function_2(self): |
| 29 | + self.intersect_sdk_emit_event('integer_event', 2) |
| 30 | + |
| 31 | + @intersect_message(events={'pig_latin': IntersectEventDefinition(event_type=str)}) |
| 32 | + def emit_event_from_message(self, input_val: str) -> str: |
| 33 | + if len(input_val) < 2: |
| 34 | + resp = f'{input_val}ay' |
| 35 | + else: |
| 36 | + resp = f'{input_val[1:]}{input_val[0]}ay' |
| 37 | + self.intersect_sdk_emit_event('pig_latin', resp) |
| 38 | + return resp |
| 39 | +``` |
| 40 | + |
| 41 | +Changed to the new way, this becomes: |
| 42 | + |
| 43 | +```python |
| 44 | +from intersect_sdk import intersect_message, IntersectBaseCapabilityImplementation, IntersectEventDefinition |
| 45 | + |
| 46 | +class Capability(IntersectBaseCapabilityImplementation): |
| 47 | + intersect_sdk_capability_name = 'example_capability' |
| 48 | + intersect_sdk_events = { |
| 49 | + 'integer_event': IntersectEventDefinition(event_type=int), |
| 50 | + 'pig_latin': IntersectEventDefinition(event_type=str), |
| 51 | + } |
| 52 | + |
| 53 | + # decorators are no longer needed |
| 54 | + def response_event_function_1(self): |
| 55 | + self.intersect_sdk_emit_event('integer_event', 1) |
| 56 | + |
| 57 | + def response_event_function_2(self): |
| 58 | + self.intersect_sdk_emit_event('integer_event', 2) |
| 59 | + |
| 60 | + # "events" property no longer needed |
| 61 | + @intersect_message() |
| 62 | + def emit_event_from_message(self, input_val: str) -> str: |
| 63 | + if len(input_val) < 2: |
| 64 | + resp = f'{input_val}ay' |
| 65 | + else: |
| 66 | + resp = f'{input_val[1:]}{input_val[0]}ay' |
| 67 | + self.intersect_sdk_emit_event('pig_latin', resp) |
| 68 | + return resp |
| 69 | +``` |
| 70 | + |
| 71 | +Also note that this change allows you to use a Capability object and call `capability.intersect_sdk_emit_event('integer_event', 1)` without explicitly creating a function to doing so; the old way had a bug which prevented this pattern. |
| 72 | + |
| 73 | +### Content-Type specification |
| 74 | + |
| 75 | +The `IntersectMimeType` enumerated class requirement for the `request_content_type` and `response_content_type` properties of the `@intersect_message` decorator, and the `content_type` field of the `IntersectEventDefinition` class, has been removed and replaced with a freeform string value; by default, this value is always `application/json`. Unless you are returning binary data, you do not need to set these fields yourself. |
| 76 | + |
| 77 | +The SDK no longer requires single values to be JSON serializable; however, receiving/returning multiple values simultaneously still has the expectation that all binary values are Base64-encoded. |
| 78 | + |
| 79 | +If you are using a value _other_ than `application/json` (i.e. you are just returning raw image data), then the return type or `event_type` of the IntersectEventDefinition MUST be `bytes`. Also note that no automatic validation of inputs will occur, you will have to do manual validation yourself. |
| 80 | + |
| 81 | +### Installing optional dependencies |
| 82 | + |
| 83 | +The `amqp` optional dependency group has been removed, by default AMQP support is required and included when installing `intersect-sdk`. |
| 84 | + |
| 85 | +### Dropped Python 3.8 and 3.9 support |
| 86 | + |
| 87 | +Older Python versions which are officially end-of-life are not supported by INTERSECT-SDK. Please update your Python version to at least 3.10 . |
| 88 | + |
| 89 | +### MQTT support change |
| 90 | + |
| 91 | +We no longer support MQTT 3.1.1 and now support MQTT 5.0 instead; for any `IntersectServiceConfig` or `IntersectClientConfig` configurations, you will need to change `mqtt3.1.1` to `mqtt5.0` . |
| 92 | + |
5 | 93 | ## 0.8.0 |
6 | 94 |
|
7 | 95 | ### Service-2-Service callback function |
|
0 commit comments