Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented Service Endpoint Registration using Source Generation #445

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

adamreed90
Copy link

@adamreed90 adamreed90 commented Mar 16, 2024

This is an example of implementing a Source Generated Service Endpoint helper for registering endpoints using Attributes.

See the example project in tests/EndpointRegistrationTest

Usage:

await using var nats = new NatsConnection();
var svc = new NatsSvcContext(nats);
await svc.AddEndpointControllers();

Declarations:

[NatsServiceController(Name = "Name", Version = "Version", QueueGroup = "QueueGroup")]
public class PingController : NatsServiceControllerBase
{
    [NatsServiceEndpoint("Ping", "Subject", "QueueGroup")]
    public async ValueTask Ping(NatsSvcMsg<string> arg)
    {
        if (arg.Data == "Ping!")
            await arg.ReplyAsync("Pong!");
    }
}

@adamreed90
Copy link
Author

Still working at this, updated my example, some issues I've had so far are that Attributes can't support the use of Metadata and Serializer configuration as those types aren't supported in attributes.

@adamreed90
Copy link
Author

@rickdotnet Have a look at this, something I'm working on.

@adamreed90
Copy link
Author

Hoping to get back to work on this at the end of the month, had some things come up.

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.

None yet

1 participant