Skip to content

Commit 159018f

Browse files
committed
feat: Device functions ADR
Specify asynchronous operation via MessageBus rather than synchronous REST Signed-off-by: Iain Anderson <[email protected]>
1 parent e36fc1a commit 159018f

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

docs_src/design/adr/device-service/0020-invoking-functions.md

+34-11
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,43 @@ this is unintuitive.
6363

6464
Note: the `attributes` structure is analagous to `attributes` in a `deviceResource`. Each device service should document and implement a scheme of required attributes that will allow for selection of the relevant funtion. The function's `name` is intended for UI and logging purposes and should not be used for actual function selection on the device.
6565

66-
**Add a REST endpoint to the device service for performing functions**
66+
**Define MessageBus topics on which function call requests and replies are to be made**
6767

68-
`api/v2/device-funtion/<device-name>/<function-name>`
68+
`edgex/function-calls/device/[profile-name]/[device-name]/[function-name]`
6969

70-
This shold accept POST requests with parameters sent in a JSON (or CBOR) payload
70+
The payload for messages on these topics should be of the form
71+
```
72+
{
73+
requestId: "184b894f-a7b7-4d6c-b400-99961d462419",
74+
parameters: { (a map of parameter values keyed by parameter name) }
75+
}
76+
```
77+
78+
The `requestId` may be any string but UUIDs are recommended.
7179

72-
A successful invocation should return HTTP 200 with the out values in JSON
73-
or CBOR format.
80+
`edgex/function-responses/device/[profile-name]/[device-name]/[function-name]`
81+
82+
The device service will provide responses to function calls on this topic. The payload will be
83+
84+
```
85+
{
86+
requestId: "184b894f-a7b7-4d6c-b400-99961d462419",
87+
status: 0,
88+
returnValues: { (a map of return values keyed by value name) }
89+
}
90+
```
91+
92+
or if a call fails
93+
94+
```
95+
{
96+
requestId: "184b894f-a7b7-4d6c-b400-99961d462419",
97+
status: (nonzero),
98+
errorMessage "Message indicating the nature of the failure"
99+
}
100+
```
74101

75-
Returnable errors should be
102+
TODO: define status codes for common errors eg not found, locked etc
76103

77-
* BAD REQUEST: parameters were missing, wrong type, or out-of-range
78-
* INTERNAL SERVER ERROR: the DS implementation was unable to fulfill the request
79-
* NOT FOUND: no such device, or no such function
80-
* LOCKED: device or service is locked or down (adminstate, operating state)
104+
** The device SDKs will provide an API for the service implementations to implement these operations **
81105

82-
**Add a REST endpoint to core-command for performing functions**

0 commit comments

Comments
 (0)