Skip to content

Conversation

@xingsy97
Copy link
Contributor

@xingsy97 xingsy97 commented Feb 18, 2025

Summary of the changes (Less than 80 chars)

@xingsy97 xingsy97 marked this pull request as draft February 18, 2025 08:40
@xingsy97 xingsy97 marked this pull request as ready for review February 19, 2025 06:48
@xingsy97 xingsy97 force-pushed the siy/fix-invocation-bug branch from 427b44c to 0f8a61e Compare February 19, 2025 07:24
@xingsy97 xingsy97 force-pushed the siy/fix-invocation-bug branch from 6f3059e to 9431689 Compare February 19, 2025 07:39
if (serviceMessage is ClientInvocationMessage invocationMessage)
{
// Accroding to target endpoints in method `WriteMultiEndpointMessageAsync`
_clientInvocationManager.Caller.SetAckNumber(invocationMessage.InvocationId, TargetEndpoints.Length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when TargetEndpoints.Length is 0, the result is OK?

Copy link
Contributor Author

@xingsy97 xingsy97 Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class AckHandler could handle such condition correctly. Refer to its method SetExpectedCount

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xingsy97 xingsy97 force-pushed the siy/fix-invocation-bug branch from 075f8ed to 68b7aa7 Compare February 24, 2025 04:58
if (serviceMessage is ClientInvocationMessage invocationMessage)
{
// Accroding to target endpoints in method `WriteMultiEndpointMessageAsync`
_clientInvocationManager.Caller.SetAckNumber(invocationMessage.InvocationId, TargetEndpoints.Length);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we still need to SetAck if Length == 0?

// The ack number of invocation will be set inside `WriteAsync`. So adding invocation should be first.
var task = _clientInvocationManager.Caller.AddInvocation<T>(_hub, connectionId, invocationId, cancellationToken);
await WriteAsync(message);
if (ServiceConnectionContainer is not MultiEndpointServiceConnectionContainer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds tricky, a ServiceLifttimeManager should not have knowledge of what the container type is, it looks like a strong assumption and is fragile. What if we later change to use other container?

if (ServiceConnectionContainer is not MultiEndpointServiceConnectionContainer)
{
// `WriteAsync` in test class `TestServiceConnectionHandler` does not set ack number. Set the number manually.
_clientInvocationManager.Caller.SetAckNumber(invocationId, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't want such logic spread into multiple layers, choose one place for such logic

var invocationId = clientInvocationManager.Caller.GenerateInvocationId(TestConnectionIds[0]);
var cts = new CancellationTokenSource();
var task = clientInvocationManager.Caller.AddInvocation<string>("TestHub", TestConnectionIds[0], invocationId, cts.Token);
clientInvocationManager.Caller.SetAckNumber(invocationId, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the test set acknumber manually? how we test if this SetAckNumber logic works well with invocation?

@vicancy
Copy link
Member

vicancy commented Mar 4, 2025

I am not sure if I like this approach. How about having WriteAsync return the successful write count? @vwxyzh any thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants