Skip to content

Commit f25ab64

Browse files
authored
Document links and improve failure documentation (#43)
1 parent 37755b4 commit f25ab64

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

Diff for: README.md

+31
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,37 @@ operation failures and framework level HTTP request errors.
391391

392392
The `Details` field is encoded and it is up to the library user to encode to and decode from it.
393393

394+
A failure can be either directly attached to `HandlerError` and `OperationError` instances by providing `FailureError`
395+
as the `Cause`, or indirectly by implementing the `FailureConverter` interface, which can translate arbitrary user
396+
defined errors to `Failure` instances and back.
397+
398+
### Links
399+
400+
Nexus operations can bi-directionally link the caller and handler for tracing the execution path. A caller may provide
401+
a set of `Link` objects via `StartOperationOptions` that the handler may log or attach to any underlying resources
402+
backing the operation. A handler may attach backlinks when responding to a `StartOperation` request via the a
403+
`AddHandlerLinks` method.
404+
405+
#### Handler
406+
407+
```go
408+
func (h *myArbitraryLengthOperation) Start(ctx context.Context, input MyInput, options nexus.StartOperationOptions) (nexus.HandlerStartOperationResult[MyOutput], error) {
409+
output, backlinks, _ := createMyBackingResourceAndAttachCallerLinks(ctx, input, options.Links)
410+
nexus.AddHandlerLinks(ctx, backlinks)
411+
return output, nil
412+
}
413+
414+
result, _ := nexus.StartOperation(ctx, client, operation, MyInput{Field: "value"}, nexus.StartOperationOptions{
415+
Links: []nexus.Link{
416+
{
417+
Type: "org.my.MyResource",
418+
URL: &url.URL{/* ... */},
419+
},
420+
},
421+
})
422+
fmt.Println("got result with backlinks", result.Links)
423+
```
424+
394425
## Contributing
395426

396427
### Prerequisites

0 commit comments

Comments
 (0)