feat(interceptors): added Interceptor page for .NET#4603
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📖 Docs PR preview links
|
brianmacdonald-temporal
left a comment
There was a problem hiding this comment.
Just a couple of small notes
afe9d24 to
1e042d8
Compare
|
|
||
| ### Register on the Client | ||
|
|
||
| Pass interceptors in the `Interceptors` argument of `TemporalClient.ConnectAsync`. Client interceptors modify outbound calls such |
There was a problem hiding this comment.
Technically not correct. Interceptors is a property on TemporalClientConnectOptions (which is what the new() is creating in the following example).
There was a problem hiding this comment.
I'm going to pick on this just a little bit more. Interceptors is a property, not an argument and not a field (like it is in Python). Properties are first class constructs in C# and this is how C# developers would expect them to be described: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/properties
67ed390 to
ef23af7
Compare
| public override Task<WorkflowHandle<TWorkflow, TResult>> | ||
| StartWorkflowAsync<TWorkflow, TResult>(StartWorkflowInput input) | ||
| { | ||
| input.Headers["user-id"] = new Payload |
There was a problem hiding this comment.
input.Headers is nullable, so if the Headers property is not set, this will throw a NullReferenceException. You'll want to probably defend against it with something like:
var headers = input.Headers ?? new Dictionary<string, Payload>();
headers["user-id"] = new Payload
{
Metadata = { ["encoding"] = ByteString.CopyFromUtf8("plain/text") },
Data = ByteString.CopyFromUtf8(UserContext.UserId),
};
return base.StartWorkflowAsync<TWorkflow, TResult>(input with { Headers = headers });| input.Headers["user-id"] = new Payload | ||
| { | ||
| Metadata = { ["encoding"] = ByteString.CopyFromUtf8("plain/text") }, | ||
| Data = ByteString.CopyFromUtf8(UserContext.UserId), |
There was a problem hiding this comment.
Where is UserContext coming from? Do we need to import something or change it to something else?
What does this PR do?
Addresses #3875. .NET didn't have a page for interceptors and it's a request that's been brought up in the community a few times.
Notes to reviewers
┆Attachments: EDU-6406 feat(interceptors): added Interceptor page for .NET