Skip to content

Need more docs #4

@flier268

Description

@flier268

After reading the entire Readme.md file, I still don't understand how to use this library.
I'm confused about how to use this library on both the client-side and server-side.
So I'm reviewing your source code to try to understand the logic.

Is this implementation correct?

On the Client side, add:

// Define Custom IMediator Interface
public interface IGrpcMediator : IRemoteMediator;

public class GrpcMediator(IMediator mediator) : RemoteMediator(mediator), IGrpcMediator
{
    public override string ProtocolName => "grpc";
}

services.AddRemoteMediatR<IGrpcMediator, GrpcMediator>("public-api", "grpc", remoteBuilder =>
{
    remoteBuilder.AddGrpcStrategy("internal-api1", client => client.Address = new Uri("http://localhost:5011"));
});

public class SomeService(IRemoteMediator mediator) 
{
    public async Task SendRequest() 
    {
        await mediator.Send(new SomeRequest());    
    }
}

On the Server side, add:

// Configure Service
services.AddGrpc();

// Configure Middleware
app.UseRemoteMediatR(applicationBuilder => applicationBuilder.UseGrpcListener());

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions